| Author |
Message |
Amanda George
Guest
|
Posted:
Tue Jan 04, 2005 9:11 pm Post subject:
Scheduled Task Cannot Run a VBScript |
|
|
Does anyone know why I wouldn't be able to run a VBScript as a scheduled task
on a Win 2000 Terminal Server w/ SP4? The VBScript is stored on the local C
drive. The scheduled task uses a domain account to run the script. No one
is logged onto the server when the scheduled task runs. It seems as if the
task runs and runs and the task never really kicks off the script. If I run
the script manually, it works fine. I don't see any errors in the event log.
I am using cscript as my default script client. Below is the content of my
script:
'UltraBridge Terminal Server Reboot Script
'Created by Wade Laye 6-1-04
'Last update by AG on 01-04-05
'Option Explicit
On Error Resume Next
'The ADO connection is being made to the MasterServer spreadsheet to a
defined range named "OMserverIPs"
'A DSN on MDXX1 defines the connection to the MasterServer spreadsheet
Set objConn = CreateObject("ADODB.Connection")
objConn.Open "ADOExcelServerIP"
Set objRS = CreateObject("ADODB.Recordset")
objRS.ActiveConnection = objConn
objRS.CursorType = 3 'Static cursor.
objRS.LockType = 2 'Pessimistic Lock.
objRS.Source = "Select * from OMserverIPs"
objRS.Open
strTSCounter = 0 ' Counter used to count the total number of
Terminal Servers
Dim strIPValue ' Terminal Server IP address parsed from Master
Server Spreadsheet via ADO
Dim sClient
Dim oLocator
'wscript.echo "UltraBridge Terminal Server Collection"
'Printing out original spreadsheet headings and values.
'Note that the first recordset does not have a "value" property
'just a "name" property. This will spit out the column headings.
'For X = 0 To objRS.Fields.Count - 1
'wscript.echo objRS.Fields.Item(X).Name
'Next
objRS.MoveFirst
While Not objRS.EOF
For X = 0 To objRS.Fields.Count - 1
strIPValue = objRS.Fields.Item(X).Value
If Not strIPValue = "null" Then
If Instr(1, strIPValue ,"10.122.102") Then
wscript.echo strIPValue
strTSCounter = strTSCounter + 1
'ServerReboot(strIPValue)
End If
End If
Next
objRS.MoveNext
Wend
ServerReboot("10.122.102.14")
wscript.echo "Total number of Terminal Servers: " & strTSCounter
'ADO Object clean up.
objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing
Set objShell = Nothing
Set oLocator = Nothing
Set oConnection = Nothing
Set oWindows = Nothing
Sub ServerReboot(sClient)
Const EVENT_SUCCESS = 0
Const EVENT_WARNING = 1
'Create scripting host shell objectto wrote log message to event viewer
remotely
Set objShell = Wscript.CreateObject("Wscript.Shell")
'get WMI locator
Set oLocator = CreateObject("WbemScripting.SWbemLocator")
'Connect to remote WMI
Set oConnection = oLocator.ConnectServer(sClient, _
"root\cimv2")
'issue shutdown to OS
' 4 = force logoff
' 5 = force shutdown
' 6 = force rebooot
' 12 = force power off
Set oWindows = oConnection.ExecQuery("Select " & _
"Name From Win32_OperatingSystem")
For Each oSys In oWindows
nStatus = oSys.Win32ShutDown(6)
Next
If nStatus = 0 Then
'Wscript.echo ExecClient & " rebooted successfully."
objShell.LogEvent EVENT_SUCCESS, "The server reboot has been triggered by
the Terminal Server reboot script from MDXX1." , "\\" & sClient
Else
'Wscript.echo ExecClient & " reboot returned error: " & nStatus
objShell.LogEvent EVENT_WARNING, "The Terminal Server reboot script was
not able to reboot this server from MDXX1." , "\\" & sClient
subShutDownMgr(sClient)
End If
End Sub
Sub subShutDownMgr(strSrvToReboot)
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
Error = objWMIService.Create("C:\Program Files\Resource Kit\shutdown.exe "
& _
strSrvToReboot & " /R /C", null, null, intProcessID)
'If Error = 0 Then
' Wscript.Echo "shutdown.exe was started with a process ID of " _
' & intProcessID & "."
'Else
' Wscript.Echo "shutdown.exe could not be started due to error " & _
' Error & "."
'End If
End Sub |
|
| Back to top |
|
 |
Guest
|
Posted:
Tue Jan 04, 2005 9:41 pm Post subject:
Re: Scheduled Task Cannot Run a VBScript |
|
|
i keep seeing reviews and raves about this naturalisproducts.com and
organiconline.com.sg . many people are discussing in beauty forums and
magazines have positive reviews on this . but this thing ain't new, its
been around for 20 years! anyone tried can feedback to me on exactly
how good it is?
----------------------------------------
<quote>
g...@raterenterprise.com
can anyone help me please, am looking for the local distributor or any
shop selling the naturalis range of skin and body care products, from
this company http://www.naturalisproducts.com . looking for this
urgently. for those who have not come across it, its some foodbased
anti-aging products. i googled for this and received result
showing its available at http://www.organiconline.com.sg. i need this
urgently but shipping from singapore will take some time, if anyone is
distributing this please contact me at g...@raterenterprise.com
urgently. i have a group of us looking to buy this. thanks! |
|
| Back to top |
|
 |
SubnetJO
Guest
|
Posted:
Wed Jan 05, 2005 3:47 am Post subject:
RE: Scheduled Task Cannot Run a VBScript |
|
|
Hello Amanda...
Not every user may start batch jobs...
To watch (and configure) the users allowed to do that, you need to enter the
"Group Policy Editor" (gpedit.msc).
Find the policy "Logon as a batch job" in:
"Computer Configuration" -> "Windows Settings" -> "Security Settings" ->
"Local Policies" -> "User Rights Assignment"
Configure there the user account that starts the events.
Delete that user account if present in the "Deny logon as a batch job"
policy configuration.
I hope this may help.
Bye,
SubnetJO
Italy |
|
| Back to top |
|
 |
Amanda George
Guest
|
Posted:
Thu Jan 06, 2005 12:51 am Post subject:
RE: Scheduled Task Cannot Run a VBScript |
|
|
I checked those policy settings and they have the correct user accounts
defined. "Deny logon as a batch job" had no users defined. I can run this
script on another 2000 terminal server successfully with the same domain
logon account to start the job as I am trying to use on the server I am
having problems with. It starts and stops correctly. Any other ideas?
"SubnetJO" wrote:
| Quote: | Hello Amanda...
Not every user may start batch jobs...
To watch (and configure) the users allowed to do that, you need to enter the
"Group Policy Editor" (gpedit.msc).
Find the policy "Logon as a batch job" in:
"Computer Configuration" -> "Windows Settings" -> "Security Settings" -
"Local Policies" -> "User Rights Assignment"
Configure there the user account that starts the events.
Delete that user account if present in the "Deny logon as a batch job"
policy configuration.
I hope this may help.
Bye,
SubnetJO
Italy |
|
|
| Back to top |
|
 |
|
|
|
|