Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable into shell command

Status
Not open for further replies.

ajtsystems

IS-IT--Management
Jan 15, 2009
80
GB
Anyone know how to get a variable into a shell command.

I am trying to create a folder in 7zip with the name using the date function.

Here is my code

Set objShell = wscript.createObject("wscript.shell")

strCommand = "7z a -tzip c:\test.zip " & MyTargetFolder & "\"
wscript.echo strCommand
objShell.CurrentDirectory = InstallPath

strRun = objShell.Run(strCommand, 0, True)


Any ideas would be good.

Thanks

James
 
Code:
myvar = "C:\Temp"

Set WSHShell = Createobject("Wscript.Shell")
WSHShell.Run("CMD.EXE /C Dir " & myVar)

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top