470,573 Members | 1,653 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,573 developers. It's quick & easy.

OT - calling batch files with parameters from GUI

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
it.

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

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

:DoExec
%ExecPrmString%
Nov 12 '05 #1
0 2403

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Vinod | last post: by
7 posts views Thread by erniedude | last post: by
7 posts views Thread by w.monthard | last post: by
6 posts views Thread by Charles Neitzel | last post: by
6 posts views Thread by =?Utf-8?B?VkIgSm9ubmll?= | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.