jbm Posted August 17, 2005 Posted August 17, 2005 How do you assign a commandline variable to environment variables?using this in a batch file if I don't type anything after mybatchI'm prompted and what is properly assigned the value. But if I type"mybatch doit" its not. Or is this not possible?mybatchset what = %1if Not DEFINED what set /P what=?echo %1echo %what%Thanks for any help
gunsmokingman Posted August 17, 2005 Posted August 17, 2005 Is This What You WantEcho Off && CLS && MODE 75,5 && Color f3 && Title Set New Varibleset what = Echo. && if Not DEFINED what set /P what= %UserName%, Type In The New Varible?-^>CLS && Color 3FEcho. && set /P = %UserName%, The Input Enter = %what%, Press Key To Exit
jbm Posted August 17, 2005 Author Posted August 17, 2005 I want to copy the command line variable to an environment variablebut something like set myvariable = %1doesn't work
jbm Posted August 19, 2005 Author Posted August 19, 2005 found my answer had to changeset what=%1 to set what=%~f1
Yzöwl Posted August 21, 2005 Posted August 21, 2005 actually your only problem was the additional spaces before and after the equals symbolset what=%1if Not DEFINED what set /P what=?echo %1echo %what%
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now