Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to prompt for user imput in a shortcut

Status
Not open for further replies.

Niavlys

IS-IT--Management
Jun 3, 2002
197
CA
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.

Does someone have a solution?
Thanks!
 
I can't understand what do u need ? Mohamed Farid
Know Me No Pain , No Me Know Pain !!!
 
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!
 
Have you tried running the shortcut in the windows 98 compatability layer?
 
Futuretech204: yes I tried /?, ??, $$ $? and a bunch of *&%$ with the same results.

gpalmer711: yes I tried it with no good results

I think I'll have to write some vbs lines...
 
Hello Niavlys,

I have the same problem !
Do you have solving the problem ?

Please give me an answer.

M.Lübkemann
 
" Futuretech204: yes I tried /?, ??, $$ $? and a bunch of *&%$ with the same results. "

ROFLMAO ~ Can you PLEASE tell me what exactly did you mean by " a bunch of *&%$ " ?
 
Sorry, I meant a bunch a special characters (%, $...)
 
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..."
 
I can tell you how to do it

Create a new shortcut for the file: command.com

Afterwards take properties on the shortcut and insert the filename you want to execute. Put your "?" after like you used to.

It only works with .bat files not .cmd files
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top