• 0

[VBS] Registry Editing


Question

I found this script online and assume i just copy it into a textpad and make it a .vbs, but it doesnt seem to be working, am i missing something? it's used to turn off the power management feature in network cards.

Dim $objWMISvc, $objNicGUID, $strNicInstanceID, $strNicComponentID
$objWMISvc = GetObject("winmgmts:\\.\root\cimv2")
For Each $objNicGUID In $objWMISvc.ExecQuery("select * from Win32_NetworkAdapter where AdapterType=" + Chr(34) + "Ethernet 802.3" + Chr(34))
  $strNicInstanceID = Right(("000" + $objNicGUID.DeviceID),4)
  $strNicComponentID = ReadValue("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\"+$strNicInstanceID,"ComponentId")
  If Left($strNicComponentID,3) = "pci"
	$=WriteValue("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\"+$strNicInstanceID,"PnPCapabilities","00000038","REG_DWORD")
  EndIf
Next

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

hmm.. although i don't profess to understand exactly what's going on there, what you are doing should work for a .vbs script.

is it creating the key at all and they just isnt working?

Link to comment
Share on other sites

  • 0

I got it, some functions were not part of the VBscript code so i rewrote it and got it to work.

Dim objWMISvc, objNicGUID, Reg, strNicInstanceID, strNicComponentID
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objWMISvc = GetObject("winmgmts:\\.\root\cimv2")
For Each objNicGUID In objWMISvc.ExecQuery("Select * from Win32_NetworkAdapter where AdapterType = 'Ethernet 802.3'")
	strNicInstanceID = Right(("000" + objNicGUID.DeviceID),4)
	strNicComponentID = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\"+strNicInstanceID+"\ComponentId")
		If Left(strNicComponentID,3) = "pci" Then
			Reg = WshShell.RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\"+strNicInstanceID+"\PnPCapabilities","00000056","REG_DWORD")
		end if
Next

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.