Hi, I need to prompt for a user imput on a desktop shortcut to transfer it to a batch file. On Win98, "program.exe ?" was working fine but won't work under W2k.
OK, on win9x computers, you can set, in the target area, the name of the program (or batch, in my case) + a parameter. If you put "?" as a parameter, than the shorcut prompts for user imput with the "comment" field as title. For example (program.bat ?). So you can pass the input text as a parameter in a batch file (cd %1) will change to the directory entered in the input box.
In W2K, the batch file interprets the ? as text. So if you have CD %1 in the batch and you call it (batch.bat ?), you will have as a result CD ?, wich doesn't work.
Hope to be clear enough, it is hard to explain.
Thanks!
For those who want:
In Windows 9x, entering a question mark as the lone argument in the Target field causes Windows to prompt for input just the way you've described. In Windows 2000, you can use the SET command's new /P switch to prompt for input, then you can relaunch the batch file and pass the input text on the command line:
@ECHO OFF
SET MyInput=
IF NOT '%1'=='' GOTO Ready
SET /P MyInput=Enter filename:
%0 %MyInput%
:Ready
Windows NT 4.0, however, does not support the /P switch, so you'll have to use the old-fashioned COPY CON technique to carry out the prompt-and-pass operation:
@ECHO OFF
IF NOT '%1'=='' GOTO Ready
ECHO Enter filename followed by Ctrl+Z and Enter
COPY CON TEMP$$$$.$$$ > nul
FOR /F "delims=" %%v IN (TEMP$$$$.$$$) DO %0 %%v
:Ready
This example works in either Windows 2000 or Windows NT 4.0, and it takes advantage of the enhanced FOR command that Microsoft introduced with NT 4.0.
Rhonin "too many questions, too little time..."
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.