Batch Timeout

Questions about Wine on Linux
Locked
addeheed
Newbie
Newbie
Posts: 3
Joined: Tue Apr 01, 2014 1:24 pm

Batch Timeout

Post by addeheed »

Hello, I'm running Wine on an Ubuntu 12.10 64bit server.
I have a windows software that freezes after a while (it doesn't restart by itself) and I found a fix for it that works on my home computer.
I made a batch file that runs the software, then waits 20 minutes and then closes it and restarts.
I tried running it on the server with Wine but it doesn't work, I think it said that it's not an available command, I even tried the ping trick to make it sleep before restarting but without success.
Is there a way to make it wait in another way? Help appreciated! :)
The batch file:

@ECHO OFF
COLOR 57
CLS
:loop
START software.exe
TIMEOUT /t 600 >null
TASKKILL /f /im software.exe >nul
GOTO loop
:END
oiaohm
Level 8
Level 8
Posts: 1020
Joined: Fri Feb 29, 2008 2:54 am

Re: Batch Timeout

Post by oiaohm »

addeheed welcome to the world of nasty.

http://stackoverflow.com/questions/1672 ... mpt-or-dos

timeout is not implemented. choice timeout option is not implemented.

ping -n <number> should work in wine at the moment but this is a super big hack. Currently ping in wine is bogus and is basically sleep so many seconds.

I think the most correct answer is don't use a batch file. Wine batch file support is fairly basic and broken in many places. Instead use a Linux native bash/shell script.

Code: Select all

#!/bin/bash
while true; do
  echo "starting" 
  WINEPREFIX="applications prefix" wine start software.exe  &
  sleep 20m
  echo "killing"
  WINEPREFIX="applications prefix" wine taskkill /f /im software.exe &>/dev/null
done
Even so some applications don't like the & option when they detect running in background they suspend.

The bash or linux shell script solution is lighter on ram compared to using cmd in wine as well.
addeheed
Newbie
Newbie
Posts: 3
Joined: Tue Apr 01, 2014 1:24 pm

Re: Batch Timeout

Post by addeheed »

Thank you for the reply!

In the code, what would I use for "applications prefix", this confuses me a bit (I'm very new to Linux).
I will try to make the bash script when I wake up tomorrow since it's really late now :P
oiaohm
Level 8
Level 8
Posts: 1020
Joined: Fri Feb 29, 2008 2:54 am

Re: Batch Timeout

Post by oiaohm »

http://wiki.winehq.org/FAQ#wineprefix

I copied that example from my notes file. Sorry I included something a little more advanced. The FAQ gives a decent description.

I normally install each windows application in its own WINEPREFIX this prevents them from installing conflicting dlls or other parts. Default WINEPREFIX if you don't define something else is "~/.wine". If you have not used WINEPREFIX up until now deleting all the WINEPREFIX bit would not be a problem. But I would recommend getting to know the WINEPREFIX feature of wine. WINEPREFIX Solves so many headaches it not funny like how to run 32 bit only programs on 64 bit systems.
addeheed
Newbie
Newbie
Posts: 3
Joined: Tue Apr 01, 2014 1:24 pm

Re: Batch Timeout

Post by addeheed »

Thanks for the reply!

It's a simple .exe file, it only reads some files.
I will check out the WINEPREFIX for the future, sounds like it could come in handy sometime!

I made the bash script and made it executable, however it starts the program but then closes it after a while (5-10secs)
When executing the bash script, I get this message: fixme:exec:SHELL_execute flags ignored: 0x00000100.
Not sure if that is an error or if it's not harming anything.

I wrote the script from your example but I didn't include the WINEPREFIX thing, so it looks like this:

Code: Select all

#!/bin/bash
while true; do
echo "starting"
wine start eobot.exe &
sleep 15m
echo "killing"
wine taskkill /f /im eobot.exe &>/dev/null
done
What is the issue here? Thankful for help :)
oiaohm
Level 8
Level 8
Posts: 1020
Joined: Fri Feb 29, 2008 2:54 am

Re: Batch Timeout

Post by oiaohm »

Even so some applications don't like the & option when they detect running in background they suspend.
addeheed it could be this warning. Some windows programs in background suspend or close once they have completed performing their tasks.

If you swap you program out for notepad.exe you will see that the script is doing the restart function. In the sleep state the script appears stalled.
wine start eobot.exe &>wine.log &
Would be a good next step. Background is background. When you said not running you had checked the linux ps aux for it.

This might explain what is happening on windows why it does not stay running. Some application require active state under windows to remain running.

Yes you can double background. So the script can be started with & on the end as well so it not claiming the console input.
Locked