VMware Communities
MPC_Engineering
Contributor
Contributor
Jump to solution

Windows batch file does not terminate

Hi there,

I am having trouble with a very simple windows .bat file when run from the dock, basically even though the correct commands are there and it runs and terminates fine when opened on the windows side, when running it from the dock (or opening the vmware package -> applications running it that way), it just doesnt terminate. The batch file pops up, does its job, completes and closes, but even after the window has gone, the command prompt still shows as running in the dock and wont run up again until you ctrl-click and quit it.

What I'm actually trying to achieve is just to run a windows program, but the problem is, I can't just run the .exe straight because it needs to be passed a seconds file as an argument to run correctly, so the path to the exe actually ends up being "C:\somepath\somefile.exe" "C:\somepath\someotherfile.pan" for a windows shortcut. So, as the only way I could work out to dock windows programs was with an executable, I created a simple batch to contain the path and compiled it to an exe - although the compiler hasnt created a 'proper' exe, its just made an exe 'wrapper' I think. I experimented with a 'proper' compiler and it worked fine, however we are not going to spend out for a one shot compiler that we may well not use again...

So, I guess if anyone knows how to get round the batch file not terminating in the dock problem, then thats great, otherwise another option could be ,can you put a windows shortcut in the dock. Or indeed any other solution anyone else anyone can think of!

Thanks in advance

Jon

0 Kudos
1 Solution

Accepted Solutions
WoodyZ
Immortal
Immortal
Jump to solution

Okay I had some time to play around and nothing I found for free on the internet would do what you wanted to so I wrote my own program to test with a Win32 app and the bottom like is what you see is not always what you get... in other words in Unity Mode when you execute a Windows application that has a GUI and an icon appears on the Dock that is not the actual windows application as represented on the Windows Taskbar. It is a special helper application to provide being able to execute the WinApp from the OS X Dock and this is why you must terminate it separately. At the present time I do not know of a work-a-round to automatically have that helper app automatically unload.

BTW These helper application are created on-the-fly and reside in the Applications folder within the Virtual Machine's Bundle package.

Bottom line as I see it at the moment you don't even need a batch file as you should be able to create a shortcut to the exe with the second file as an argument and place that shortcut in the Start Menu and access it from either the Fusion icon in the Dock or the Applications menu on the VMware Fusion menu bar.

Although I know you going to say but I really want to launch it from it's own icon on the Dock in which case you'll have to write your own OS X application that launches the helper Application and then terminates both. You may even be able to use AppleScript vs Objective-C. (Sorry, I don't have time to play anymore with this one.)

Edit: Well I couldn't leave this alone and I was able to use AppleScript to execute and unload the helper application in the Virtual Machine's Bundle Package with just 4 lines of code, save it as a App and put it in the Dock and it works as I believe you'd like or at the least settle for.

The 4 lines are as follows:

tell application "NAME_OF_HELPER_APPLICATION"

activate

quit

end tell

View solution in original post

0 Kudos
6 Replies
WoodyZ
Immortal
Immortal
Jump to solution

What is the name of this batch to executable program and a URL for it?

0 Kudos
MPC_Engineering
Contributor
Contributor
Jump to solution

Hi Woodyz,

The batch is just a simple one I created myself - it consists of a mighty 3 lines Smiley Happy

@ECHO OFF

START "" /B "C:\some path with spaces\somefile.exe" "C:\some path with spaces\somefile.pan"

GOTO :EOF

I then compiled that with this simple free program:

http://www.f2ko.de/English/b2e/download.php

However it doesnt make any difference if you run the .exe or the .bat, they both stay in the dock...

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

Jon,

I played around with the "Bat_To_Exe_Converter.exe" program a bit and the bottom line I found is that it often left a stub program loaded in memory and had to be killed via Task Manager. I tried many different scenarios including simply loading notepad with an argument pointing to a text file and it would still leave the stub program in memory.

Absolute bottom line is the Bat_To_Exe_Converter.exe is unreliable and worthless!

I'm going to check something else out and get back to you.

Woody

0 Kudos
MPC_Engineering
Contributor
Contributor
Jump to solution

Ah ok, thats interesting Woody, well I guess you can only expect so much with freeware! I couldn't find an alternative myself but if there is one that would be great. I did try quick batch file compiler here - http://www.abyssmedia.com/quickbfc/ and as I remember that terminated correctly. Rather not spend $50 to compile a 3 line bat tho :smileysilly:

Thanks for looking into it anyway, interested to see what you find.

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

Okay I had some time to play around and nothing I found for free on the internet would do what you wanted to so I wrote my own program to test with a Win32 app and the bottom like is what you see is not always what you get... in other words in Unity Mode when you execute a Windows application that has a GUI and an icon appears on the Dock that is not the actual windows application as represented on the Windows Taskbar. It is a special helper application to provide being able to execute the WinApp from the OS X Dock and this is why you must terminate it separately. At the present time I do not know of a work-a-round to automatically have that helper app automatically unload.

BTW These helper application are created on-the-fly and reside in the Applications folder within the Virtual Machine's Bundle package.

Bottom line as I see it at the moment you don't even need a batch file as you should be able to create a shortcut to the exe with the second file as an argument and place that shortcut in the Start Menu and access it from either the Fusion icon in the Dock or the Applications menu on the VMware Fusion menu bar.

Although I know you going to say but I really want to launch it from it's own icon on the Dock in which case you'll have to write your own OS X application that launches the helper Application and then terminates both. You may even be able to use AppleScript vs Objective-C. (Sorry, I don't have time to play anymore with this one.)

Edit: Well I couldn't leave this alone and I was able to use AppleScript to execute and unload the helper application in the Virtual Machine's Bundle Package with just 4 lines of code, save it as a App and put it in the Dock and it works as I believe you'd like or at the least settle for.

The 4 lines are as follows:

tell application "NAME_OF_HELPER_APPLICATION"

activate

quit

end tell

0 Kudos
MPC_Engineering
Contributor
Contributor
Jump to solution

Thanks for spending this much time on this Woodyz, sorry the late reply, not had much time at my desk the last few days. Very interesting to find out what you concluded about it all though, guess thats the kind of approach you might expect when trying to do crazy things like run windows on a mac Smiley Happy Anyway, I'll give your solution a crack (sounds exactly what I was after btw) at first opportunity and mark your post up as the answer.

Thanks again

Jon

0 Kudos