Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

wscript.Run does not work in a scheduled environment

Posted on 2006-03-22
4
Medium Priority
?
1,109 Views
Last Modified: 2010-04-07
Folks:

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
         WScript.Quit(8)
     Else    
     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?

0
Comment
Question by:jflanner
  • 2
4 Comments
 
LVL 3

Expert Comment

by:ptan218
ID: 16264864
Try using the administrator as the user to run the task. I believe it is an issue with the permission.
0
 
LVL 23

Accepted Solution

by:
gecko_au2003 earned 2000 total points
ID: 16269030
0
 

Author Comment

by:jflanner
ID: 16273780
Thanks.  That did the trick.
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 16274140
np let me know how it goes :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

575 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