Discussion Locked

Make Windows PROMPT you for a variable?

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hopefully I'll be able to explain my question properly...

SCENARIO:

I have a batch file, lets call it RUNME.BAT that contains a %1 variable. Let's say it reads as follows:

ECHO %1 is the greatest!

Typing it from the command line poses no problem obviously. Simply enter RUNME JESPER and the batch file will echo "JESPER is the greatest!"

However, what I want to do is make a shortcut on my desktop, pointing to this batch file. I still want to be able to send it any variable I choose, at the time of running.

In Windows 9x, this was VERY simple. You would edit the properties of the shortcut, and put a ? at the end of the command line. When you would run the shortcut, a window would pop up, asking you what the variable was. I believe you could do multiple question marks, for multiple variables.

No such luck in Windows 2000, and my searching for the answer has proven futile. I think the problem may be that I don't know the proper terms to search for.

Anyways, I hope that one of you wonderful people will have the answer that I long for.

Have a nice day, folks.

3 replies

by jesper

I found the best (for me) solution yesterday (and it is touched on under that link as well).

Use the set /p command in the batch file.

This actually works out better, because I can have multiple variables!

It works like so...let's say I want to get the users name, so I can create a folder out of it, and I want their extension, so I can rename a file to that extension.

@echo off
set /p name=What is your first name?
set /p ext=What is your phone extension?
md c:\users\%name%
ren c:\users\a.txt c:\users\%ext%.txt

Nifty.

Anyways, it sure looks like the answer to the original question is "can't really be done in an easy way at all".

But what the hell, you can have the points anyways.

This discussion is closed to new replies.