Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Enable WoL after sysprep x64

07 Jun 2011   #1
knschroe

Window 7 Professional x64
 
 
Enable WoL after sysprep x64

Hope someone can help with this. I'm creating a windows 7 x64 image for work. I want to enable WoL. I've checked all of the necessary power management options to 'allow nic to wake the computer' and 'only with magic packet' etc. but after sysprep, since the NIC drivers are reinstalled after windows performs sysprep, those settings are not saved. There are three checkboxes that I need to check on the Wired NIC. Does anyone have a script, or the knowledge of how to accomplish this after sysprep? I have tried several windows xp scripts, but those don't work with this new onboard nic. It's a NIC on the optiplex 790.


My System SpecsSystem Spec
.
07 Jun 2011   #2
brady

 

VBS Script will do that for you, once image has been set:

Code:
Option Explicit 

Dim colNetworkAdapters 
Dim objNetworkAdapter 

Dim strDevInstanceName 
Dim strNetworkAdapterID 

'Query for all of the Win32_NetworkAdapters that are wired Ethernet (AdapterTypeId=0 corresponds to Ethernet 802.3) 
Set colNetworkAdapters = GetObject("WinMgmts:{impersonationLevel=impersonate}//./root/Cimv2")_ 
.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE AdapterTypeId=0") 

'WScript.Echo "Enabling WoL for the following adapters:" 

For Each objNetworkAdapter In colNetworkAdapters 
' WScript.Echo " " & objNetworkAdapter.Name & " [" & objNetworkAdapter.MACAddress & "]" 

strNetworkAdapterID = UCase(objNetworkAdapter.PNPDeviceID) 

'Query for all of the MSPower_DeviceWakeEnable classes 
Dim colPowerWakeEnables 
Dim objPowerWakeEnable 

Set colPowerWakeEnables = GetObject("WinMgmts:{impersonationLevel=impersonate}//./root/wmi")_ 
.ExecQuery("SELECT * FROM MSPower_DeviceWakeEnable") 
'Compare the PNP Device ID from the network adapter against the MSPower_DeviceEnabled instances 
For Each objPowerWakeEnable In colPowerWakeEnables 
'We have to compare the leftmost part as MSPower_DeviceEnabled.InstanceName contains an instance suffix 
strDevInstanceName = UCase(Left(objPowerWakeEnable.InstanceName, Len(strNetworkAdapterID))) 
'Match found, enable WOL 
If StrComp(strDevInstanceName, strNetworkAdapterID)=0 Then 
objPowerWakeEnable.Enable = True 
objPowerWakeEnable.Put_ 'Required to write the value back to the object 
End If 
Next 
'Query for all of the MSNdis_DeviceWakeOnMagicPacketOnly classes 
Dim colMagicPacketOnlys 
Dim objMagicPacketOnly 
Set colMagicPacketOnlys = GetObject("WinMgmts:{impersonationLevel=impersonate}//./root/wmi")_ 
.ExecQuery("SELECT * FROM MSNdis_DeviceWakeOnMagicPacketOnly") 
'Compare the PNP Device ID from the network adapter against the MSNdis_DeviceWakeOnMagicPacketOnly instances 
For Each objMagicPacketOnly In colMagicPacketOnlys 
'We have to compare the leftmost part as MSNdis_DeviceWakeOnMagicPacketOnly.InstanceName contains an instance suffix 
strDevInstanceName = UCase(Left(objMagicPacketOnly.InstanceName, Len(strNetworkAdapterID))) 
'Match found, enable WOL for Magic Packets only 
If StrComp(strDevInstanceName, strNetworkAdapterID)=0 Then 
objMagicPacketOnly.EnableWakeOnMagicPacketOnly = True 'Set to false if you wish to wake on magic packets AND wake patterns 
objMagicPacketOnly.Put_ 'Required to write the value back to the object 
End If 
Next 
Next
My System SpecsSystem Spec
07 Jun 2011   #3
knschroe

Window 7 Professional x64
 
 
Not quite working, and admin rights

Thanks for such a quick response. I wasn't able to get it to work, however. The 3 checkboxes I need to check are:
Allow the computer to turn off this device to save power
Allow this device to wake the computer
Only allow a magic packet to wake the computer

The first issue I'm having with the script is that I have to run it as administrator for that to work. I'm using setupcomplete.cmd to run this script after sysprep, and i'm not sure if I can run as administrator without typing the password in the .cmd script.

The second issue i'm having is that the script doesn't check the boxes. I started the computer up, after sysprep, and unchecked all the boxes manually. I then ran the script. After running the script (with admin rights) the first box, "Allow the computer to turn off this device to save power" was not checked. Without changing anything, I restarted the computer. Upon restarting, I found that the first two checkboxes are now unchecked. Any thoughts on what could be my issue?

Thanks for such a quick response.
My System SpecsSystem Spec
.

10 Jun 2011   #4
brady

 

first issue addressed by running as "System" - no password necessary. you can set it as a scheduled task if you really need to.

second issue addressed by lack of permissions to run the script to begin with. If you don't have the appropriate permissions to run against the image it won't check.

In corporate environment, I highly urge you to not allow power save mode on the NIC.
My System SpecsSystem Spec
12 Jun 2011   #5
knschroe

Window 7 Professional x64
 
 
ToBrady:

Brady,

I'm running a powershell script that runs as system on first boot after sysprep. It uses the "SetupComplete.cmd" command file to run as system. Upon booting the first time, the powershell script runs, but does not change the options I need. Upon restarting the machine once, and running the ps script as an admin, the script works perfectly. I have a feeling that it's not running correctly on the first boot because of UAC, but I'll have to test my theory first.

As far as your last comment, about allowing power save on the NIC, why do you recommend against this? The only reason I want this on, is because it's required in order to speicify wake on lan with a magic packet. If there's another way to do this, please let me know.

And as always , thanks for all of your time on this issue.
My System SpecsSystem Spec
13 Jun 2011   #6
brady

 

It's mostly habit. I don't allow any computer to sleep at any time, thus the wake on lan is not necessary for my company.
My System SpecsSystem Spec
19 Oct 2011   #7
Mateo63

Win7 Enterprise
 
 

what should I modify in that VB to uncheck the box "Allow the computer to turn off this device to save power"?
My System SpecsSystem Spec
19 Oct 2011   #8
Mateo63

Win7 Enterprise
 
 

Quote   Quote: Originally Posted by Mateo63 View Post
what should I modify in that VB to uncheck the box "Allow the computer to turn off this device to save power"?
found this and it worked perfectly:

How to disable power management for a Wireless/Wifi network adapter using VBScript | WorkStationTalk.com
My System SpecsSystem Spec
19 Oct 2011   #9
Mateo63

Win7 Enterprise
 
 

Quote   Quote: Originally Posted by Mateo63 View Post
Quote   Quote: Originally Posted by Mateo63 View Post
what should I modify in that VB to uncheck the box "Allow the computer to turn off this device to save power"?
found this and it worked perfectly:

How to disable power management for a Wireless/Wifi network adapter using VBScript | WorkStationTalk.com
Actually had to tweak it slightly:

on error resume next
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Dim objReg, objRegSub, WshShell
Dim strKeyPath
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
Set objRegSub = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
Set WshShell = WScript.CreateObject("Wscript.Shell")
' List all subkeys
objReg.EnumKey HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}", subKeys
' Loop through the list of subkeys
For Each subKey In subKeys
strKeyPath ="SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & subKey
'List values of a key
objRegSub.EnumValues HKEY_LOCAL_MACHINE,strKeyPath,arrEntryNames
'Loop through values of subkey
For Each entry in arrEntryNames
if entry="DriverDesc" then
WshShell.regwrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & subKey & "\PnPCapabilities", 24, "REG_DWORD"
end if
Next
Next
set objRegSub = Nothing
Set objReg = Nothing
Set WshShell = Nothing
My System SpecsSystem Spec
20 Oct 2011   #10
cluberti

Windows 10 Pro x64
 
 

If this is something you're setting on multiple machines, why not set it in a power plan you're pushing down via Group Policy preferences?
My System SpecsSystem Spec
Reply

 Enable WoL after sysprep x64




Thread Tools




Similar help and support threads
Thread Forum
SysPrep Help?
I made a sysprep file with Windows WAK and it giving us issues. We get a "A fatal error occurred while trying to sysprep the machine." This happens when it is "Processing cleanup phase Sysprep plugins..." Here is our file. <?xml version="1.0" encoding="UTF-8"?> -<unattend...
Installation & Setup
Sysprep - Windows 7 - unable to sysprep image that joins domain
Good morning all: Below is my unattend.xml. I am using the sysprep + win7 for creating virtual machines in Red Hat Enterprise Virtualization 3.0 but having difficulty getting them to auto-join the domain. My sysprep progression proceeds normally and completes. The initial boot of the image...
Virtualization
win7 after sysprep reboot always with sysprep box
hello, 1st sorry for my english (i'm french guy). I made a sysprep and all parameters are corrects. but after the reboot I have always the sysprep preparation tools box. for me the sysprep is correct but I don't know what's happended. in attachment my unattend.xml
Installation & Setup
Sysprep HELP
Hi i try to sysprep a Dell latitude E6400 i install from DVD (normal installation) i create my sysprep anwser file: <?xml version="1.0" encoding="utf-8"?> <unattend xmlns="urn:schemas-microsoft-com:unattend"> <settings pass="specialize"> <component...
General Discussion
Cache Writing - Enable or not to enable?
Hello, Could anyone tell me the advantages and disadvantages of disabling cache writing on the priming HDD? Thanks in advance :D
Hardware & Devices
Help with Sysprep!
Hi all, Has anyone been able to sysprep windows 7? I followed the MS site of sysprep (Vista deployment) but get an error saying this OS is not supported. Anyone know a fix? Thanks
Software


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 16:14.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App