can i set an Variable that is value will be a user input?
i Mean like i set an Variable:
set/p Password= :
and the value of Password will be the password that the user will choose?
hope i wrote everything well

Moderator: DosItHelp
Code: Select all
@echo off
set "password="
set /p "Password=Enter your password: "
echo your password is %password%
alontraitel wrote:tnx !
this is the first time i see the command set alone (not like set/p) LOL
what it does?
Code: Select all
set "password="
abc0502 wrote:alontraitel wrote:tnx !
this is the first time i see the command set alone (not like set/p) LOL
what it does?
ThisCode: Select all
set "password="
to prevent the crash of the batch when the user not entering any value just he press enter without any input
alontraitel wrote:abc0502 wrote:to prevent the crash of the batch when the user not entering any value just he press enter without any input
ok but it work the same with out the: set "password="
Code: Select all
and how can i do that the password wont delete after i exit ?
foxidrive wrote:alontraitel wrote:abc0502 wrote:to prevent the crash of the batch when the user not entering any value just he press enter without any input
ok but it work the same with out the: set "password="
Not always.Code: Select all
and how can i do that the password wont delete after i exit ?
Use the command SETX
foxidrive wrote:It is a command in Win7 and maybe Vista that sets the environment variable in the master environment. You need a resource kit to get it in XP and earlier I think.
Type this for help:
setx /?
alontraitel wrote:tnx !
this is the first time i see the command set alone (not like set/p) LOL
what it does?
Code: Select all
set variable=data
Code: Select all
set "variable=data"
Code: Select all
set variablename
foxidrive wrote:alontraitel wrote:tnx !
this is the first time i see the command set alone (not like set/p) LOL
what it does?
I didn't follow your question: this syntax sets the data in an environment variable called %variable%Code: Select all
set variable=data
You can also see it written like this when the data has poison characters in it:Code: Select all
set "variable=data"
And typing this will display the variable, if it is set in the environment:Code: Select all
set variablename
Try typing this:
set w
and this by itself to list all variables.
set
foxidrive wrote:I can't help further if I don't know which part you don't understand.