Jump to content

Rebooting script in WinPE 2005


dim

Recommended Posts

I am trying to use this Vbscript to reboot a server in WinPE 2005

Set ShutdownWMI = GetObject("winmgmts:{(Shutdown)}//./root/cimv2")

Set SySShutdown = ShutdownWMI.ExecQuery("select * from Win32_OperatingSystem")

For each Sys in SySShutdown

Sys.Reboot()

Next

Why will this not work in WinPE 2005. Is there not the proper allowance to that class?

Also, what other methods do people use to automatically reboot in WinPE. I have tried like 5 different tools.

Help!

Link to comment
Share on other sites


ISub reboot_onclick()

Ret = Msgbox("Are you sure you wish to reboot the PC?", vbYesNo)

If ret = vbNo then

Exit Sub

End if

Do

Do While Counter < 5

Counter = Counter + 1

If Counter = 6 Then

Check = False

Exit Do

End If

with createobject("wscript.shell")

.AppActivate ("X")

.sendkeys "exit"

.sendkeys "~"

self.close

end with

Loop

Loop Until Check = False

End sub

I have found this code and it works great, but i am trying to run it via an Altiris Job and it keeps erroring out that self isn't defined, but when I break this out and run it from a command prompt via cscript it runs flawlessly.. Totally wierd...

I don't quite understand the with .appActivate and send keys..

Link to comment
Share on other sites

The PEshutdown.exe tool works great..

Here is what I did with the script

Dim oWMI, StrManufacturer
strComputer = "."
Const HKEY_LOCAL_MACHINE = &H80000002
Const WaitOnReturn = True
Const ActivateWindow = 7
Set Wshshell = CreateObject("Wscript.Shell")
Set objEnv = WshShell.Environment("Process")
StrTempDir = objEnv("TEMP")
StrWinDir = objEnv("WINDIR")
strSysDrv = objEnv("SystemDrive")
unattend = Wshshell.ExpandEnvironmentStrings("%unattend%")
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")
Set ShutdownWMI = GetObject("winmgmts:{(Shutdown)}//./root/cimv2")


Set cComputerData = oWMI.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each oItem In cComputerData
strManufacturer = Ucase(oItem.Manufacturer)
Next

If Manufacturer() = "Dell" Then
MsgBox "Please insert x64 WinPE Disk to continue the unattended installation and then select OK to reboot server. Remember to Press AnyKey to boot back into WinPE upon reboot.",vbInformation,"Schering-Plough Unattended Installation for Dell Servers"
WScript.Echo "System is rebooting"
Wshshell.Run unattend & "\tools\peshutdown.exe /reboot",ActivateWindow,WaitOnReturn
End If


Function Manufacturer()
'Manufacturer specific task
Select Case ucase(left(StrManufacturer, 2))
Case "CO"
Manufacturer = "Compaq"
Case "HP"
Manufacturer = "HP"
Case "DE"
Manufacturer = "Dell"
Case "VM"
Manufacturer = "VM"
Case Else
MsgBox "Unsupported Hardware", , "RunOnce Hardware Check"
WScript.Quit
End Select

end Function

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...