dim Posted February 5, 2008 Share Posted February 5, 2008 I am trying to use this Vbscript to reboot a server in WinPE 2005Set ShutdownWMI = GetObject("winmgmts:{(Shutdown)}//./root/cimv2")Set SySShutdown = ShutdownWMI.ExecQuery("select * from Win32_OperatingSystem")For each Sys in SySShutdown Sys.Reboot()NextWhy 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 More sharing options...
gadget Posted February 5, 2008 Share Posted February 5, 2008 (edited) Sorry, double postpeshutdown.zip Edited February 5, 2008 by gadget Link to comment Share on other sites More sharing options...
gadget Posted February 5, 2008 Share Posted February 5, 2008 WMI support in pe1.x is really bad.I use a utility called peshutdown. This shuts down, restarts ect. Mine shuts down any system after 23 hours to stop pe rebooting itself.Canuse it in pe2 as well. Link to comment Share on other sites More sharing options...
dim Posted February 6, 2008 Author Share Posted February 6, 2008 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 subI 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 More sharing options...
dim Posted February 6, 2008 Author Share Posted February 6, 2008 The PEshutdown.exe tool works great.. Here is what I did with the scriptDim oWMI, StrManufacturerstrComputer = "."Const HKEY_LOCAL_MACHINE = &H80000002Const WaitOnReturn = TrueConst ActivateWindow = 7Set 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)NextIf Manufacturer() = "Dell" ThenMsgBox "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,WaitOnReturnEnd IfFunction 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 Selectend Function Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now