Page 1 of 1

Shutdown Script

Posted: Tue May 01, 2012 8:15 pm
by octoj2011
Hi All,

Getting an error when running this script but don't quite know where to go.

I orginally was using it as a plain vbs file, but after discovering SCCM doesnt run these properly I converted it to a wsf file. However, it know doesnt work and comes up with the error:

Could not locate automation class named "Wscript.Shell".

Was wondering if anybody has any ideas?


<job id="main">
<script language="VBScript">


Const wshYes = 6
Const wshNo = 7
Const wshYesNoDialog = 4
Const wshQuestionMark = 32

Set objShell = CreateObject("Wscript.Shell")

intReturn = objShell.Popup("System maintainence shutdown, are you sure you wish to shutdown? If no response within 5 minutes system will automatically shutdown", _
300, "System maintainence shutdown", wshYesNoDialog + wshQuestionMark)

If intReturn = wshYes Then

Set WSHShell = WScript.CreateObject("WScript. Shell")
WSHShell.Run "%windir%system32shutdown.exe -s -t 360"


ElseIf intReturn = wshNo Then
Wscript.Echo "Shutdown Cancelled."
Else

Set WSHShell = WScript.CreateObject("WScript. Shell")
WSHShell.Run "%windir%system32shutdown.exe -s -t 360"


End If


</script>
</job>

Shutdown Script

Posted: Tue May 01, 2012 8:15 pm
by octoj2011
Hi All,

Getting an error when running this script but don't quite know where to go.

I orginally was using it as a plain vbs file, but after discovering SCCM doesnt run these properly I converted it to a wsf file. However, it know doesnt work and comes up with the error:

Could not locate automation class named "Wscript.Shell".

Was wondering if anybody has any ideas?


<job id="main">
<script language="VBScript">


Const wshYes = 6
Const wshNo = 7
Const wshYesNoDialog = 4
Const wshQuestionMark = 32

Set objShell = CreateObject("Wscript.Shell")

intReturn = objShell.Popup("System maintainence shutdown, are you sure you wish to shutdown? If no response within 5 minutes system will automatically shutdown", _
300, "System maintainence shutdown", wshYesNoDialog + wshQuestionMark)

If intReturn = wshYes Then

Set WSHShell = WScript.CreateObject("WScript. Shell")
WSHShell.Run "%windir%system32shutdown.exe -s -t 360"


ElseIf intReturn = wshNo Then
Wscript.Echo "Shutdown Cancelled."
Else

Set WSHShell = WScript.CreateObject("WScript. Shell")
WSHShell.Run "%windir%system32shutdown.exe -s -t 360"


End If


</script>
</job>

Shutdown Script

Posted: Wed May 02, 2012 8:37 pm
by jvierra
Sorry but that cannot be done by a script remotely.

SCCM cannot instantiate certain objects. The shell cannot be remoted.

There are third party products that you can use to accomplish this. You can also write a custom shutdown service.