VBScript: How do I run a command that contains a object or variable?
Posted on 2009-04-07
I am trying to write a script that will help me to copy a large number of USB Disks. I have most of the code written but having trouble w/ a small section. I need to run a command that uses one of output from a WMI query. I have option explicit turned on and have "Dim'd" all necessary variables.
formatUSB = "cmd /c format " & objItem.DeviceID, "/FS:NTFS /Q"
WScript.Echo "Formatting USB Drive..."
Set objShell = CreateObject ("WScript.Shell")
Set objExec2 = objShell.Exec (formatUSB)
When I run this script, I get Expected ')" or Expected end of statement. Is this possible to do?