MSFN Forum: assigning commandline variables - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

assigning commandline variables Rate Topic: -----

#1 User is online   jbm 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 626
  • Joined: 16-September 04
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 17 August 2005 - 12:40 AM

How do you assign a commandline variable to environment variables?
using this in a batch file if I don't type anything after mybatch
I'm prompted and what is properly assigned the value. But if I type
"mybatch doit" its not. Or is this not possible?
mybatch
set what = %1
if Not DEFINED what set /P what=?
echo %1
echo %what%


Thanks for any help


#2 User is offline   gunsmokingman 

  • MSFN Addict
  • Group: Super Moderator
  • Posts: 1,991
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 17 August 2005 - 08:04 AM

Is This What You Want

Quote

Echo Off && CLS && MODE 75,5 && Color f3 && Title Set New Varible
set what =
Echo. && if Not DEFINED what set /P what= %UserName%, Type In The New Varible?-^>
CLS && Color 3F
Echo. && set /P = %UserName%, The Input Enter = %what%, Press Key To Exit


#3 User is online   jbm 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 626
  • Joined: 16-September 04
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 17 August 2005 - 11:17 AM

I want to copy the command line variable to an environment variable
but something like
set myvariable = %1
doesn't work

#4 User is online   jbm 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 626
  • Joined: 16-September 04
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 19 August 2005 - 09:39 AM

found my answer had to change
set what=%1 to set what=%~f1

#5 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,117
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 21 August 2005 - 02:36 PM

actually your only problem was the additional spaces before and after the equals symbol
set what=%1
if Not DEFINED what set /P what=?
echo %1
echo %what%


#6 User is online   jbm 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 626
  • Joined: 16-September 04
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 21 August 2005 - 09:47 PM

Thanks it worked with out the extra space.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy