Jump to content

Recommended Posts

Posted

Hi all,

 

Just wondering if anyone can help me with a problem?

 

I'm running a vbs script via a shortcut with a switch on the end of the shortcut. I need to return the value of the switch within the script its self. e.g. if the target of the shortcut was:

 

C:\Shortcutmsg.vbs -HebronClientLauncher

 

I need to return "HebronClientLauncher" within the vbs file if its possible. I can return the script name using the WScript.ScriptName command but can't work out how to return the switch :(

 

Thanks

Posted

Hahaha

 

Yer, starting to feel my age... even tho I'm younger then you!!

 

I'll go with excuse no3. - I'm rather busy at the moment...

Posted
I used the script and it doesn't error so I suppose it thinks it's working correctly. The only problem is it still doesn't return the Argument. I just get 0 returned as the Argument is empty :mad: I'll have to play a bit more.
Posted

If you do

C:\Shortcutmsg.vbs -HebronClientLauncher

then

WScript.Arguments.Item(0)

gives you "-HebronClientLauncher" - not the "-" so if you're just checking for the text it won't work (and your script will error if there's no argument at all)

 

If you do:

C:\Shortcutmsg.vbs /name:HebronClientLauncher

and then in code do:

sName=wscript.arguments.named("name")

then sName will be set to HebronClientLauncher (or whatever) and no error if there's no argument.

  • Thanks 1
Posted

Thanks Steve,

 

I'll try that later... just struggling with office 2007 deployment at the moment which has taken presidents over this :doh:

Posted

If you wanted to specify a switch followed by switch value then you can use named arguments e.g.:

 

Set objArgs = WScript.Arguments
Set objArgNamed = objArgs.named
strSwitch = objNamed("Switch")

 

So you can call your script as follows:

 

foo.vbs /Switch:bar

 

Dont need to do it this way but is an option.

  • Thanks 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...