Page 1 of 1
Use User input
Posted: 18 Oct 2012 08:21
by alontraitel
hello, i'm new in batch codding and i have a question. (sorry for my english, i''m not from britain/usa)
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

Re: Use User input
Posted: 18 Oct 2012 08:24
by foxidrive
Code: Select all
@echo off
set "password="
set /p "Password=Enter your password: "
echo your password is %password%
Re: Use User input
Posted: 18 Oct 2012 08:26
by alontraitel
tnx !
this is the first time i see the command set alone (not like set/p) LOL
what it does?
Re: Use User input
Posted: 18 Oct 2012 08:31
by abc0502
alontraitel wrote:tnx !
this is the first time i see the command set alone (not like set/p) LOL
what it does?
This
to prevent the crash of the batch when the user not entering any value just he press enter without any input
Re: Use User input
Posted: 18 Oct 2012 08:33
by alontraitel
abc0502 wrote:alontraitel wrote:tnx !
this is the first time i see the command set alone (not like set/p) LOL
what it does?
This
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="
and how can i do that the password wont delete after i exit ?
Re: Use User input
Posted: 18 Oct 2012 08:41
by foxidrive
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
Re: Use User input
Posted: 18 Oct 2012 08:51
by alontraitel
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
sorry that i'm stupid xD
what is the SETX command ?
Re: Use User input
Posted: 18 Oct 2012 09:04
by foxidrive
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 /?
Re: Use User input
Posted: 18 Oct 2012 09:07
by alontraitel
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 /?
tnx !! you help me alot
Re: Use User input
Posted: 18 Oct 2012 09:08
by foxidrive
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%
You can also see it written like this when the data has poison characters in it:
And typing this will display the variable, if it is set in the environment:
Try typing this:
set w
and this by itself to list all variables.
set
Re: Use User input
Posted: 18 Oct 2012 09:12
by alontraitel
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%
You can also see it written like this when the data has poison characters in it:
And typing this will display the variable, if it is set in the environment:
Try typing this:
set w
and this by itself to list all variables.
set
i didn't understand... sorry
Re: Use User input
Posted: 18 Oct 2012 09:18
by foxidrive
I can't help further if I don't know which part you don't understand.
Re: Use User input
Posted: 18 Oct 2012 09:25
by alontraitel
foxidrive wrote:I can't help further if I don't know which part you don't understand.
for now its all

you answerd my question

tnx alot for the help

i now testing the SETX command, if i will have troubles i will open another topic