punkwalrus (punkwalrus) wrote,
punkwalrus
punkwalrus

VB.NET - Command Line switches

Remember when VB6 just took a "Command()" argument for CLS?  Well, no more!  Now it's all Object oriented, and so I found out some interesting junk.  Now it's passed into an array. In this case, I wanted AwarLaunch to be able to take a different SlotID.ini as a command switch for "dual purpose" machines that we do from time to time (like for the toll free dialer). 

'# First, set up a String array (ArrayList and Array don't work)

'# This command will get all the arguments from the CommandLine.
'  There will always be at least one element in the String Array,

'  and the first e
lement at Index(0) is the actual location of

'  the executable, like
"C:\somedirectory\program.exe"

  Dim arrComLin As String()
  arrComLin = Environment.GetCommandLineArgs
 

'# I check to see if there is MORE than one element, and
'  if not, assume
the default value

  If arrComLin.Length > 1 Then
    strNewSlotID = arrComLin(1)
  Else
    strNewSlotID = "C:\SlotID.ini"
  End If

Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments