Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello, I was chastened about posting this in the DOS section, so I'll try here.
I'm creating a batch file that pauses, launches a program and then closes its command window. I can't get the window to close after the program launches--it just hangs there until I close it myself.
I've tried using "exit" and "cls" as the last line of the file, but neither has any effect.
Here is what my .bat file looks like:
@echo off
"C:\Program Files\Sony Handheld\HOTSYNC.exe"
exitWhat am I doing wrong?
Thanks very much for any help!
Have you tried typing:
start "C:\Program Files\Sony Handheld\HOTSYNC.exe"You don't even have to put this in a batch file, you can just make a shortcut that points to the above and it should work.
Report Offensive Follow Up For Removal
Jump,
You have to rename your .bat file with the .cmd extension. The old .bat does not work in XP. So,, if your file was named SONY.BAT, then rename it to SONY.CMD and it will work fine...:o)Safe Computing...:o)
Jump,
A PS, you don't need the "exit" line either. CMD will execute the line and then exit on it's own...:o)
Safe Computing..:o)
Jump,
wait one. BAT does work, I am sorry. I wonder if the EXE file you are trying to run is wanting a "parameter" after it? This would make the cmd window remain open I think. Oh, and I hope you don't have the "" in your batch file too!!!!All you need is this:-
C:\Program Files\Sony Handheld\HOTSYNC.exe
In fact, after messing about with what you are trying to do,, I think the SHORTCUT idea is MUCH MUCH better!!!!!!!!!!!!!!
Safe COmputing...:o)
Wow, pcfixingguy, nifty tip! I didn't know you could do that... I guess you learn something new every day! :-)
Report Offensive Follow Up For Removal
Hmm, thanks for the advice, but I'm still not getting it to work. I changed the extension to .cmd, but it seems to act the exact same way.
When I put the "start" in the line:
start "C:\Program Files\Sony Handheld\HOTSYNC.exe"
A command window opened up and gave me a prompt at the desktop, which is where the .cmd file is located. Hotsync.exe didn't start at all this time.I took out "start" and it ran fine, but it still just leaves the window there after my Hotsync.exe application launches. This happens with OR without "exit" on the last line.
I want to do this as a batch file because I need to insert a pause to start off the whole thing. However, I'm going to worry about that aspect after I figure out why the window isn't closing.
James and Jump,
I forgot. The CMD or batch file acts the same way as the old batch files in that the lines MUST NOT HAVE SPACES in them. It's been a while since I have played with batch files in Windows. I have now successfully run a windows program (I used Ad-Aware as a guinea pig) from the CMD box. However, the only time it exits is when the program that is run is actually terminated. I am working on it. Here is the command line for Jump's file:-
C:\Progra~1\Sony~1\HOTSYNC.exe
The spaces have gone. Hopefully there is only one SONY folder too, otherwise it gets a bit more complicated.
I will work on how to exit the box...:o)
Safe Computing...:o)
JUmp,
I am real puzzled as to how the batch file is actually working if you have spaces in the execution line? It should generate an error saying that PROGRA is not an internal or external command.Safe Computing..:o)
I don't know why, but it's working with the spaces! I tried using:
C:\Progra~1\Sony~1\HOTSYNC.exe
for the heck of it, but this didn't work. Unfortunately, I DO have two Sony folders: "Sony" and "Sony Handheld." Anyway, it works fine with the spaces, so that's not a problem.
Try using this command,
start "C:\Program Files\Sony Handheld" HOTSYNC.exe
Sony Handheld" & HOTSYNC.exe should be on the same line with one space between them.
Sandman
An Official Microsoft Minion. ÿ
Report Offensive Follow Up For Removal
start "C:\Program Files\Sony Handheld" HOTSYNC.exe
_________________________________________________
Sandman
An Official Microsoft Minion. ÿ
Report Offensive Follow Up For Removal
If start by itself doesn't work, try cmd /c start "C:\Program Files\Sony Handheld\HOTSYNC.exe"
Report Offensive Follow Up For Removal
Sandman, the first suggestion (all on one line, of course):
start "C:\Program Files\Sony Handheld" HOTSYNC.EXE
did not work. I got a dialog that read "Windows cannot find 'HOTSYNC.EXE', etc."The second command:
cmd /c start "C:\Program Files\Sony Handheld\HOTSYNC.exe"
Just opened a command window, again with the path set to the desktop.For what it's worth, when I execute any of these .bat or .cmd files, the command window shows the path C:\WINDOWS\System32\cmd.exe -- is that the right executable?
*Smacks forehead* I forgot to add the /d switch. Try this command and it should work.
start /d "C:\Program Files\Sony Handheld" HOTSYNC.exe
_________________________________________________Sandman
An Official Microsoft Minion. ÿ
Report Offensive Follow Up For Removal
Thanks Sandman. That worked. I also got an email from Ivo with another solution that worked:
start "" "C:\Program Files\Sony Handheld\HOTSYNC.exe"
Note that those are empty double quotes after start.So now that works. Next, I need to find a way to pause the execution of this file for about 10 seconds. The hotsync program does not seem to register properly when it launches right at boot time. I need to delay it for 10 seconds or so before executing the start line.
Any suggestions?
Jump,
If you were using NT, there was a SLEEP command in its CMD line! Who determines what is useful for the next generation of OP SyS's huh? That command would have been ideal! However, other than using a simple BASIC program containing a timed loop and CALLing it from your batch file, I have thought of an interesting and somewhat funny workaround...:o)Add this line to your batch file BEFORE the START line:-
dir /s c:\
Yes, it will open the CMD box, and proceed to list ALL the files in the C drive! Mine takes about 18 seconds! Once finished, it will run your program...:o)
sweet huh....lol
Safe Computing...:o)
You should be able to use this command to set a delay.
TYPE NUL | CHOICE.COM /N /CY /TY,10 >NUL
You can download choice.com from http://www22.brinkster.com/d104/CHOICE.zip
if you need to.Sandman
An Official Microsoft Minion. ÿ
Report Offensive Follow Up For Removal
Im working on a Open all IM's program batch file. Well trying to figure out. What I am tryign to do, is to allow, the batch fil;e to open tyhe IM programs no matter where there installed. Here is what i have so far. and yes its VERY basic. If i where to give this to frineds to mess with and there IM programs arent installed like mine, I'd like for it to stil be able to open them. Thansk in advance
@echo off
start /d "d:\program files\yahoo!\messenger" ypager.exe
Echo Yahoo! Started
start /d "d:\program files\aim" aim.exe
Echo Aim Started
start /d "C:\Program Files\MSN Messenger" msnmsgr.exe
Echo Msn Messenger started
start /d "c:\program files\messenger" msmsgs.exe
Echo Windows Messenger Started
Pause
exit
![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |