|
|
|
Batch file > auto close cmd window
|
Original Message
|
Name: jumpyg
Date: March 12, 2004 at 10:02:33 Pacific
Subject: Batch file > auto close cmd window OS: WinXP Home CPU/Ram: P4
|
Comment: 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" exit What am I doing wrong? Thanks very much for any help!
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: jam14online
Date: March 12, 2004 at 10:17:11 Pacific
|
Reply: (edit)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
|
|
Response Number 2
|
Name: pcfixinguy
Date: March 12, 2004 at 10:22:19 Pacific
|
Reply: (edit)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)
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: pcfixinguy
Date: March 12, 2004 at 10:24:56 Pacific
|
Reply: (edit)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)
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: pcfixinguy
Date: March 12, 2004 at 10:36:04 Pacific
|
Reply: (edit)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)
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: jumpyg
Date: March 12, 2004 at 10:42:07 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 7
|
Name: pcfixinguy
Date: March 12, 2004 at 10:57:49 Pacific
|
Reply: (edit)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)
Report Offensive Follow Up For Removal
|
|
Response Number 8
|
Name: pcfixinguy
Date: March 12, 2004 at 11:02:36 Pacific
|
Reply: (edit)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)
Report Offensive Follow Up For Removal
|
|
Response Number 9
|
Name: jumpyg
Date: March 12, 2004 at 11:10:47 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 10
|
Name: Sandman
Date: March 12, 2004 at 12:23:13 Pacific
|
Reply: (edit)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
|
|
Response Number 11
|
Name: Sandman
Date: March 12, 2004 at 12:26:55 Pacific
|
Reply: (edit)start "C:\Program Files\Sony Handheld" HOTSYNC.EXE _________________________________________________ Sandman
An Official Microsoft Minion. ÿ
Report Offensive Follow Up For Removal
|
|
Response Number 13
|
Name: jumpyg
Date: March 12, 2004 at 13:22:20 Pacific
|
Reply: (edit)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?
Report Offensive Follow Up For Removal
|
|
Response Number 14
|
Name: Sandman
Date: March 13, 2004 at 00:40:49 Pacific
|
Reply: (edit)*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
|
|
Response Number 15
|
Name: jumpyg
Date: March 13, 2004 at 07:57:27 Pacific
|
Reply: (edit)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?
Report Offensive Follow Up For Removal
|
|
Response Number 16
|
Name: pcfixinguy
Date: March 13, 2004 at 10:39:33 Pacific
|
Reply: (edit)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)
Report Offensive Follow Up For Removal
|
|
Response Number 17
|
Name: Sandman
Date: March 13, 2004 at 16:14:09 Pacific
|
Reply: (edit)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
|
|
Response Number 18
|
Name: JMcQuadeSr
Date: April 13, 2004 at 16:26:19 Pacific
|
Reply: (edit)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
Report Offensive Follow Up For Removal
|
Use following form to reply to current message:
|
|

|