Biatu Posted April 20, 2017 Posted April 20, 2017 (edited) Hello, I found this func in the forums, but it does not work. I keep getting errors. I could use devcon but I will be using the script in a limited space environment. ScanForHardwareChanges() Func ScanForHardwareChanges() Local Const $CM_LOCATE_DEVNODE_NORMAL = 0 Local Const $CR_SUCCESS = 0 $status = DLLCall("cfgmgr32.dll","int","CM_Locate_DevNode", _ "int*",0,"int",0,"int",$CM_LOCATE_DEVNODE_NORMAL) If Not ($status[0] = $CR_SUCCESS) Then MsgBox(4096,"","CM_Locate_DevNode failed: " & $status[0]) Return 0 EndIf $status = DLLCall("cfgmgr32.dll","int","CM_Reenumerate_DevNode","int",$status[1],"int",0) If Not ($status[0] = $CR_SUCCESS) Then MsgBox(4096,"","CM_Reenumerate_DevNode failed: " & $status[0]) printf("CM_Reenumerate_DevNode failed: %x\n", status)); Return 0 EndIf Return 1 EndFunc Edited April 20, 2017 by Biatu What is what? What is what.
spudw2k Posted April 20, 2017 Posted April 20, 2017 What errors are you receiving? Does it happen when you run the script with elevated perms (#RequireAdmin)? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Biatu Posted April 21, 2017 Author Posted April 21, 2017 yes, when running script as in on Win10 I get Error 51, on windows 7 I get error 5 (even with requireAdministrator set from Au3Wrapper), and... if I change this line back to what it originally was... $status = DLLCall("cfgmgr32.dll","int","CM_Locate_DevNode", _ "int_ptr",0,"int",0,"int",$CM_LOCATE_DEVNODE_NORMAL) I get error 3 What is what? What is what.
spudw2k Posted April 24, 2017 Posted April 24, 2017 Hmm, I'm not much help here. I couldn't get it to run on windows 7 either. I got the same error (5) which seems to indicate either an invalid DEVNODE or DEVINST from what I found an a header file (cfgmgr32.h) online. #define CR_INVALID_DEVNODE 0x00000005 #define CR_INVALID_DEVINST CR_INVALID_DEVNODE Error 51 seems to indicate an access denied error. #define CR_ACCESS_DENIED 0x00000033 I'm not too sure where to troubleshoot from here. Hopefully someone more familiar will chime in. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Subz Posted April 24, 2017 Posted April 24, 2017 It works for me in Windows 10 x64 Enterprise (required #RequireAdmin otherwise error 51), but not in Windows 7 x64 Enterprise (error 5). Same user account on both, with Admin rights.
Biatu Posted October 26, 2017 Author Posted October 26, 2017 Bump, I've come across this feature again. I thought to include SeDriverLoadPrivilege as MSDN suggests but still getting error 5 on Win7 and on Win10 I cannot tell if it works, however it does not throw an error. Script: expandcollapse popup#RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <WinAPI.au3> #include <WinAPIProc.au3> #include <SecurityConstants.au3> #RequireAdmin Global $aAdjust, $hToken $hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ALL_ACCESS, $TOKEN_QUERY)) MsgBox(64,@Error,@Extended) _WinAPI_AdjustTokenPrivileges($hToken, BitOR($SE_DEBUG_NAME,$SE_LOAD_DRIVER_NAME), $SE_PRIVILEGE_ENABLED, $aAdjust) MsgBox(64,@Error,@Extended) ScanForHardwareChanges() _WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust) MsgBox(64,@Error,@Extended) _WinAPI_CloseHandle($hToken) MsgBox(64,@Error,@Extended) ScanForHardwareChanges() Func ScanForHardwareChanges() Local Const $CM_LOCATE_DEVNODE_NORMAL = 0 Local Const $CR_SUCCESS = 0 $status = DLLCall("cfgmgr32.dll","int","CM_Locate_DevNode", _ "int*",0,"int",0,"int",$CM_LOCATE_DEVNODE_NORMAL) If Not ($status[0] = $CR_SUCCESS) Then MsgBox(4096,"","CM_Locate_DevNode failed: " & $status[0]) Return 0 EndIf $status = DLLCall("cfgmgr32.dll","int","CM_Reenumerate_DevNode","int",$status[1],"int",0) If Not ($status[0] = $CR_SUCCESS) Then MsgBox(4096,"","CM_Reenumerate_DevNode failed: " & $status[0]) ;printf("CM_Reenumerate_DevNode failed: %x\n", status)); Return 0 EndIf Return 1 EndFunc What is what? What is what.
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