VBS script using WMI stop working after serveral hours if running using Task Scheduler on Windows Server 2016

I

Inteko76

Hello!
I use the VBS script to periodically check the availability of the remote IP host. The script runs on Windows 2016 Server and uses WMI calls.
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}")
Do
Set objPing = objWMIService.ExecQuery("select * from Win32_PingStatus where address = '192.168.1.1'")
For Each objStatus In objPing
If IsNull(objStatus.StatusCode) Or objStatus.StatusCode <> 0 Then
-----
Else
-----
End If
Next
WScript.Sleep 1000
Loop
I run it under a domain account that has local administrator rights on this machine, with privilege elevation. The script works without any problems if I log into this account and run it manually from the CMD with elevated privileges. But if I run it through Task Scheduler with elevated privileges under the same account, then after a few hours it stops working with various errors related to access to WMI. All restrictions on the time of the script in the settings of the Task Scheduler, I removed. It feels like the security token expires. What could be the problem?

Continue reading...
 
Back
Top Bottom