I have set up the following Sub to run shell commands quickly and easily. This script works for the login scripts at my company without fail. I am currently developing a script to add a large batch of users to our domain. When I used this Sub in my new script I receive an error saying that the file cannot be found. I have tried using the fix in this stackoverflow post, but I recieve the same error even with this code. VBScript WScript.Shell Run() - The system cannot find the file specified
The part I find puzzling is that this sub works just fine when run from the netlogon folder of our domain controller. What am I doing wrong?
Thanks,
Sub runcommand(strCommand)
Dim objWshShell, intRC
set objWshShell = WScript.CreateObject("WScript.Shell")
intRC = objWshShell.Run(strCommand, 0, TRUE)
call reportError(intRC,strCommand)
set objWshShell = nothing
end Sub
function reportError(intRC, command)
if intRC <> 0 then
WScript.Echo "Error Code: " & intRC
WScript.Echo "Command: " & command
end if
end function