Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Batch problem - total noob.
08-05-2007, 04:52 PM #1
- Join Date
- Dec 2005
- Thanked 0 Times in 0 Posts
Batch problem - total noob.
I have a batch program which asks for some input, stores it in a variable, and uses it throughout.
Problem is, whenever I run it through double clicking it instead of at the prompt, it closes after I give it the input. This has also happened with several PAUSE commands.
How can I work around this, making it finish the entire program even when not run at the prompt?
It's similar in functionality to this:
@echo off ECHO What is your name? SET /p name= ECHO Welcome %name%!The Devil sold his soul to Bill Gates.
08-05-2007, 06:26 PM #2
- Join Date
- May 2005
- Southern tip of Silicon Valley
- Thanked 160 Times in 155 Posts
The problem is not with the batch file, it's how you're executing it. Your batch file is actually completing and then the window closes. In order to execute by "double clicking" and keep the window open after the batch file completes, you need to pass the batch file as a parameter to cmd. The easiest method would be to create a shortcut to cmd and pass your batch file in the command.
Assuming your batch file is named name.bat and is in C:\batch directory, the target for the shortcut would be:
%windir%\system32\cmd.exe /k C:\batch\name.bat