Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows Scheduler

Status
Not open for further replies.

ekbranson

Programmer
Jan 12, 2004
52
US
Hello, I have been reading alot of forums that sound similar to my situation but I still can't quite get a grasp. I have a simple vbs that I wish to execute at a specific time using the Windows Task scheduler. This works fine if I am loged in. However, when I log out of the computer the script will not run.

I have tried creating a user and assigning it to the admin group. When I do this and run the script through the scheduler, the scheduler displays the status as running, however the script will not execute.

Any ideas?
 
Schedule the script to execute using the AT Command.

Also, depending on how you have set things up, the script MAY be running but in a hidden Window. Open up the task list to see if Wscript or Cscript is running.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Hello ekbronson,

It has to be noted, apart from the credential problem, some activex control's functionality collides with the scheduled task environment. Hence, even you have all the permissions set, when the user is not logged on, the scheduled task may fail.

To look into it, add the following line at some critical/suspicious locations and investigate where and what the problem happened. (I presume you've on error resume next at top.)
Code:
'... immediate below some suspicious functionality
if err.number<>0 then
    set wshshell=createobject("wscript.shell")
    wshshell.logevent 4, "0x" & hex(err.number) & vbtab & err.description
    wscript.quit err.number
end if
regards - tsuji
 
Thank you both for your help. I have found that in WinXP the scheduled task will not operate if using the windows interface to schedule to the script. However if you use code to schedule the task it works fine. I'm unsure why this is, it just seems to be that way.

Here is what I use to schedule a task with scripting.
Code:
set Service = GetObject("winmgmts:")
Set objNewJob = Service.Get("Win32_ScheduledJob")
e = objNewJob.Create _
	("wscript D:\Test\SoftwareInventory.vbs", "********133200.000000-420", _
	True, 8, , , JobId)

If Err.Number <> 0 then
	Wscript.Echo "Error: " & e
end if
 
Along the same lines of using a vbscript to schedule a task, I am trying to schedule a task to run an inventory application from across the network. I can schedule the task to run, but it always fails due to the fact that it is using the SYSTEM account. Is there anyway to schedule a task and force it to use a specific user account & password? The following is what I have thus far:

**********************
strComputer = "."
strApp = "\\10.135.10.18\appl1\trackit\audit32.exe"
strTime = "********165000.000000-420"

Set objService = GetObject("winmgmts:\\" & strComputer)
Set objNewJob = objService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create _
(strApp, strTime, _
False , 0, , True , JobID)
If Err.Number = 0 Then
Wscript.Echo "New Job ID: " & JobID
Else
Wscript.Echo "An error occurred: " & errJobCreated
End If
**********************

Any help on this would be greatly appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top