We help IT Professionals succeed at work.

wscript.Run does not work in a scheduled environment

jflanner asked
Medium Priority
Last Modified: 2010-04-07

I wrote a vbscript that works when called from the command line - that is:
cscript c:\MyScript.vbs

But does not work when called from a scheduler; where it is executing under an ID that does not have access to the console.  (In fact - the machine is logged off.)

My code is:

     Dim Shell
     Dim Command
     set Shell = WScript.createobject("wscript.shell")
     Command = "c:\sqldata\mssql\scripts\wget -q " & SourceFile & " -O " & TargetFile
     ReturnCode = Shell.run(Command, 0, TRUE)
     If ReturnCode > 0 Then
     End If    

The return code I am getting from shell.run is 1.

How can I do a shell command to run a task completely in the background?

Watch Question

Try using the administrator as the user to run the task. I believe it is an issue with the permission.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Thanks.  That did the trick.
Shane Russell2nd Line Desktop Support

np let me know how it goes :)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.