vbScript Run Exe with Command Switches

Associate
Joined
7 Jul 2009
Posts
2,399
Location
Wiltshire
Hi,

I wonder if anyone can help?

I've got the following vbScript: -

Code:
sub shell(cmd)
	' Run a command as if you were running from the command line#
	dim objShell
	Set objShell = WScript.CreateObject( "WScript.Shell" )
	objShell.Run(cmd)
	Set objShell = Nothing
end sub

shell "C:\Users\Andrew\Downloads\putty\PUTTY.EXE"

This works fine and launches putty.

However, I need to launch it with some command switches and this has got me stumped. Each time I add these I get an error regardless of where I put the quotes and the number.

Has anyone got any idea how I can add the switches?

Thanks & Regards
 
Just realised I've posted this in the wrong Forum :o

Could someone please move it for me?

Thanks
 
I'm not sure what you've tried but the obvious way is the correct way:

Code:
shell "C:\Users\Andrew\Downloads\putty\PUTTY.EXE -ssh 127.0.0.1"

Make sure you're giving putty valid arguments.
 
Last edited:
Thanks for the reply.

I've tried many combinations. Something that might not be helping is that the current switches I'm using on the shortcut to launch it are: -

Code:
C:\Users\Andrew\Downloads\putty\PUTTY.EXE -L 9091:###.78.###.68:9090 -L 5051:###.78.###.68:5050 -load "AAAA" -l Login -pw Password

Possbily the quotes around the saved Session isn't helping?

Regards
 
Got it!!!!

The answer was to put double quotes around the Session that needed loading.

Code:
C:\Users\Andrew\Downloads\putty\PUTTY.EXE -L 9091:###.78.###.68:9090 -L 5051:###.78.###.68:5050 -load ""AAAA"" -l Login -pw Password

Regards
 
Back
Top Bottom