Jump to content

iprob

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by iprob

  1. Here is the function that worked for me. ; #FUNCTION# ==================================================================================================================== ; Name...........: _DeviceAPI_RemoveDevice ; Description ...: Get class name from class GUID ; Syntax.........: - ; Parameters ....: - ; Return values .: Success - String ; Failure - NULL String, @ERROR set ; Author ........: Matthew Horn (weaponx) ; Modified.......: - ; Remarks .......: - ; Related .......: - ; Link ..........; @@MsdnLink@@ - http://msdn.microsoft.com/en-us/library/ms792990.aspx ; Example .......; Yes ; =============================================================================================================================== Func _DeviceAPI_RemoveDevice() Local $result = DllCall($setupapi_dll,"int","SetupDiCallClassInstaller","dword", 5,"hwnd", $hDevInfo,"ptr", $pSP_DEVINFO_DATA) If @ERROR Then Return SetError(@ERROR,@EXTENDED,"") Else ;Check for WinAPI error $WinAPI_Error = _WinAPI_GetLastError() If $WinAPI_Error <> 0 Then ;ConsoleWrite("Error " & _WinAPI_GetLastError() & ": " & _WinAPI_GetLastErrorMessage()) ;Exit Return SetError(1,1,0) Else ;Debug($result) Return $result[3] EndIf EndIf EndFunc
  2. The error was an error in my code. I've actually posted this to the example scripts section under the deviceapi.au3 topic...so it probably should not be posted here. Rob
  3. I was trying to add the function SetupDiRemoveDevice. I'm using this amazing script to remove some orphaned volume shadow copies. The function I added was as follows: ; #FUNCTION# ==================================================================================================================== ; Name...........: _DeviceAPI_RemoveDevice ; Description ...: Get class name from class GUID ; Syntax.........: - ; Parameters ....: - ; Return values .: Success - String ; Failure - NULL String, @ERROR set ; Author ........: Matthew Horn (weaponx) ; Modified.......: - ; Remarks .......: - ; Related .......: - ; Link ..........; @@MsdnLink@@ - http://msdn.microsoft.com/en-us/library/ms792990.aspx ; Example .......; Yes ; =============================================================================================================================== Func _DeviceAPI_RemoveDevice() Local $result = DllCall($setupapi_dll,"int","SetupDiRemoveDevice","hwnd", $hDevInfo,"ptr", $pSP_DEVINFO_DATA) If @ERROR Then Return SetError(@ERROR,@EXTENDED,"") Else ;Check for WinAPI error $WinAPI_Error = _WinAPI_GetLastError() If $WinAPI_Error <> 0 Then ;ConsoleWrite("Error " & _WinAPI_GetLastError() & ": " & _WinAPI_GetLastErrorMessage()) ;Exit Return SetError(1,1,0) Else ;Debug($result) Return $result[1] EndIf EndIf EndFunc The function doesn't appear to be removing the device. Any suggestions? Does this function already exist in the code? Rob
  4. I've been using the DeviceAPI.au3 file extensively creating a list of devices to uninstall. I've been calling devcon via the Run() function to then remove these devices. Does anyone know how I can just delete the device from within the autoit script? I created the function as follows based on the other functions in deviceapi.au3. It returns an error: Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded. Anyone else using this script that may shed some light on this? Rob
  5. That resolved it. The script editor is a 32-bit application (not the aut2exe thing, looked at wrong process) and was attempting to run the query in 32-bit mode. Compiled as a 64-bit application and query works. Rob
  6. I think the issue is what version of autoit you are running. I found this article (http://technet.microsoft.com/en-us/library/ee264219(WS.10).aspx) which seems to indicate that there is an issue if you are running 32-bit version applications on a 64-bit machine. The odd thing is that when I check my processes, the application running is aut2exe_x64.exe. What process do you show running when you are executing autoit? Rob
  7. I tested your code and the code generated by Scriptomatic. Neither work on my test systems (multiple machines). I'm running this on Windows 7 and Server 2008 R2. It doesn't work on either of those operating systems. And yes, I've tested without UAC to make sure it wasn't a permissions issue. The VBScript code and vssadmin via command line work fine. What operating system are you using? Rob
  8. The scriptomatic shows the same query I have and gets the same results, nothing. Using other WMI classes works fine. It seems to be an issue with autoit interacting with the Win32_ShadowCopy class but I don't know what that would be. Rob
  9. I'm doing a very basic script trying to get the shadow copies on the system via WMI. Here is the script: Dim $objWMI = ObjGet("winmgmts://localhost/root/cimv2") Dim $objSet = $objWMI.ExecQuery("SELECT * FROM Win32_ShadowCopy") For $objItem in $objSet ConsoleWrite($objItem.DeviceObject) Next Nothing is returned. When I run the following vbscript, I get the two shadow copies on the system I created listed without a problem. Dim namespace Set namespace = GetObject("winmgmts://localhost/root/cimv2") Dim objSet Set objSet = namespace.ExecQuery("select * from Win32_ShadowCopy") Dim dateTime set dateTime = CreateObject("WbemScripting.SWbemDateTime") Dim vDate count = 0 for each obj in objSet count = count + 1 wscript.echo obj.ID wscript.echo obj.SetID wscript.echo obj.ProviderID wscript.echo obj.Count wscript.echo obj.DeviceObject wscript.echo obj.VolumeName wscript.echo obj.ServiceMachine wscript.echo obj.ExposedName wscript.echo obj.State wscript.echo obj.Persistent wscript.echo obj.ClientAccessible wscript.echo obj.NoAutoRelease wscript.echo obj.NoWriters wscript.echo obj.Transportable wscript.echo obj.NotSurfaced wscript.echo obj.HardwareAssisted wscript.echo obj.Differential wscript.echo obj.Plex wscript.echo obj.Imported wscript.echo obj.ExposedRemotely wscript.echo obj.ExposedLocally dateTime.Value = obj.InstallDate vDate = dateTime.GetVarDate(True) wscript.echo vDate next Any idea on why my autoit script is not working? I should also add that when I ran "vssadmin list shadows" using the Run() function it returns an error (class not registered) but when I run it from the command line it works fine. I also queried other WMI classes and there were no problems. Rob
×
×
  • Create New...