View Full Version : Batch problem - total noob.

08-05-2007, 05:52 PM
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%!

Thanks in advance!

08-05-2007, 07:26 PM
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