By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,790 Members | 1,409 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,790 IT Pros & Developers. It's quick & easy.

OT - calling batch files with parameters from GUI

P: n/a
I remember that I used to set up utility batch files, and create Windows
shortcuts to them that would ask the user for parameters to supply to the
batch files. From what I can tell, this functionality simply doesn't exist
anymore in Windows 2000 or above. I did find a work-around to this that I
thought y'all might want to know about.

There are a number of new fetures in batch files available on Windows 2000
including an extended syntax for the Set command that asks the user to
supply a value for the environment variable. Using this, it is possible to
write one simple, universal batch file that takes as parameters, a batch
file or exe file name, and a list of parameter prompts. This batch file,
then assembles a command string containing all of the above, and executes

Using this, one can create a shorcut with a target like ...
c:\mytools\execprm.bat c:\mytools\foo.bat enter-param1 enter-param2

If you run this shortcut, you get prompted for [enter-param1], then
[enter-param2], then foo.bat gets called using the 2 user responses as
parameters. It works!

----- Listing of execprm.bat -----

@Echo Off
Set ExecPrmString=%1

If "%2"=="" goto DoExec
Set ExecPrm=
Set /P ExecPrm=[%2]
Set ExecPrmString=%ExecPrmString% %ExecPrm%
Goto GetNextPrm

Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.