I have a workflow that executes a windows script that reboots a PC when a certain process is killed (reboot PC does not work since there will always be a user logged on who has actually killed the process).
This was working fine yesterday when I deployed it to one test machine. This morning however when I tried to add more devices, when I clicked Save & Finish I received "Problem Occured While Updating Workflow".
If I remove my script, and replace it with something else, it saves fine. Try and re-add the script and it fails again. To repeat, this was working yesterday.
Can someone please advise of logs I can check to see where the issue is, or let me know if there is some line in my script that it is now having an issue with? I know the script itself is fine
cheers
A
Function RemoteExecute(strServer, strUser, strPassword, strCommand)
Dim objLocator , objWMIService
wbemImpersonationLevelImpersonate = 3
wbemAuthenticationLevelPktPrivacy = 6
RemoteExecute = -1
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
On Error Resume Next
Set objWMIService = objLocator.ConnectServer(strServer,"root\cimv2", strUser,strPassword)
objWMIService.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
objWMIService.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
If Err.Number <> 0 Then
WScript.Echo "Failed to connect to " &strServer, "Error # " & CStr(Err.Number) & " " & Err.Description & vbcrlf & _
"Please check if " & strServer & " is pingable from this client & credentials are correct"
Err.Clear
On Error GoTo 0
RemoteExecute = -1
Set objWMIService = nothing
Set objLocator = nothing
Exit function
end if
' Configure the process to show a window
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = SW_NORMAL
Set Process = objWMIService.Get("Win32_Process")
'Process.Create Syntax: '
' uint32 Create(
'[in] string CommandLine,
'[in] string CurrentDirectory,
'[in] Win32_ProcessStartup ProcessStartupInformation,
'[out] uint32 ProcessId
');
'Return code Description
'0 Successful Completion
'2 Access Denied
'3 Insufficient Privilege
'8 Unknown failure
'9 Path Not Found
'21 Invalid Parameter
intReturn = Process.Create(strCommand,NULL, objConfig, intProcessID)
If intReturn <> 0 Then
Wscript.Echo "Process could not be created." & _
vbNewLine & "Command line: " & strCommand & _
vbNewLine & "Return value: " & intReturn
Wscript.Quit
Else
Wscript.Echo "Process created." & _
vbNewLine & "Command line: " & strCommand & _
vbNewLine & "Process ID: " & intProcessID
RemoteExecute = intProcessID
End If
Set objWMIService = nothing
Set objLocator = nothing
End Function
Dim objShell
set objShell= Wscript.CreateObject("WScript.Shell")
RemoteExecute wScript.Arguments.Item(0),wScript.Arguments.Item(1),wScript.Arguments.Item(2),"shutdown -r -t 20 -f -c " & chr(34) & "Machine appears to have been tampered with. Restarting in 20 seconds" & chr(34)