wscript.Run does not work in a scheduled environment

Posted on 2006-03-22
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("")
     Command = "c:\sqldata\mssql\scripts\wget -q " & SourceFile & " -O " & TargetFile
     ReturnCode =, 0, TRUE)
     If ReturnCode > 0 Then
     End If    

The return code I am getting from is 1.

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

Question by:jflanner
    LVL 3

    Expert Comment

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

    Accepted Solution


    Author Comment

    Thanks.  That did the trick.
    LVL 23

    Expert Comment

    np let me know how it goes :)

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now