Jump to content

Sundance

Active Members
  • Posts

    191
  • Joined

  • Last visited

Everything posted by Sundance

  1. Hi Martin, I use your DLL for a little project where we are printing some labels with the help of a brother label printer. I create a QR code with createQRw.au3 and add some text to the right of it. There are two things I still have a problem. First of all I would like (also) have the ability to set the paper size to a specific value so that the user hasn't to do so. Cause when the length of the label isn't right the QR code has not a square size and won't be recognized by our scanner. The second thing is a problem I hope you have an idea. On some computers my script prints an empty second page and I don't know why. Even when the printer settings and the text to be printed and all computers are teh same. Do you have any hints for me Martin? (I'am using the _PrintImage function. It also prints a second page when printing a tiny pic which fits into the page bounderies) Is there an ability to force the printer to only print one page? many thanks in advance Martin Sundance
  2. Hi Lars, good to hear that it functions also on your side. There are some things to take into consideration when doing snapshots. It seems a good idea to clean up the code and post an example. Thanks for the info about the 64bit thingy of AddToSnapshotSet.
  3. @Lars: The AddToSnapshotSet under 64bit method definition. Does it look like this? (Can't test it at the moment) AddToSnapshotSet hresult(wstr; uint64; ptr); And would this the corresponding code? $tElem = DllStructCreate("uint64;", DllStructGetPtr($GUID_NULL)) $iResult = $oIVssBackupComponents.AddToSnapshotSet($sSource, DllStructGetData($tElem, 1), $pID)
  4. And here is i side where you can see how easy it is to get infos about the shadow copies with the help of WMI http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/computermanagement/shadow/ see you Sundance
  5. So I modified the script a little bit. Now the script will create to hardlinks on drive c called "shadowcopy_C" and "shadowcopy_D". They contain the shadowcopies. You can explore them and copy files from them. After acknowledge the messagebox the hardlinks and the shadow copies will be deleted. This is the WMI function which returns the shadow copy volume path of a given ID. Func ShowShadowcopyVolumepath($sGUID) Local $objWMIService = ObjGet('winmgmts:{impersonationLevel=impersonate}!\\' & @ComputerName & '\root\cimv2') $colItems = $objWMIService.ExecQuery("Select " & "*" & " from Win32_ShadowCopy") For $oItem In $colItems If $oItem.ID = $sGUID Then ConsoleWrite("original volume name : " & $oItem.VolumeName & @CRLF) ConsoleWrite("shadowcopy volumepath: " & $oItem.DeviceObject & @CRLF) ; volumepath of the shadowcopy Return $oItem.DeviceObject EndIf Next EndFunc COMshadow.au3
  6. With the help of the GUIDs from the drive letters we can use WMI to get the volume path. At work I can take a look for some WMI code. I can write a function which will show you the volume path of a given shadow copy GUID.
  7. Hi Lars, fine that it works also on Win7 64Bit. I'am not that far but I wanted to create shadow copies and then to give the user the possibility in showing the shadow copy within the normal windows explorer. There are also methods for showing the created set IDs and which shadow copies they contain. But this can also be achieved with WMI. Its much easier. Then when having the shadow copy volume path you enter it in the windows explorer. :-)
  8. Oh. Here is some additional code for deleting the shadow copys :-) "DeleteSnapshots hresult(uint64;uint64; int; BOOL; ptr; ptr);" ; method definition MsgBox(0,"","Press okay to delete snapshotset") Local $DelSnapShots = DllStructCreate("long") Local $pDelSnapShots = DllStructGetPtr($DelSnapShots) Local $NonDelSnapShotGUID = DllStructCreate($tagGUID) $tElem = DllStructCreate("uint64[2];", DllStructGetPtr($SetIdentifier)) $iResult = $oIVssBackupComponents.DeleteSnapshots( DllStructGetData($tElem, 1, 1), DllStructGetData($tElem, 1, 2), $VSS_OBJECT_SNAPSHOT_SET, 1, $pDelSnapShots, DllStructGetPtr($NonDelSnapShotGUID)) ConsoleWrite("deleting snapshotset " & _WinAPI_StringFromGUID(DllStructGetPtr($SetIdentifier,1)) & " returned with: " & Hex($iResult) & @CRLF) ConsoleWrite( "and " & DllStructGetData($DelSnapShots,1) & " deleted snapshots" & @CRLF ) 
  9. Hi John, yes. A shadowcopy is the base of a drive image. Even a running OS can be imaged with that. After making a shadowcopy you should open the given volumename of the snaphot with _WinAPI_CreateFile and then read the whole volume with WinAPI_ReadFile. So you can then write the read data to a file with WinAPI_WriteFile :-) Thats it :-) You also can copy single files which are in use by the operating system with the help of a shadowcopy.
  10. Hi John ;-) This COM thingy is really weird!? Thank you also for support!
  11. So master Lars. IT IS DONE! :-) After reading a nice sheet from MS which additional commands we need it now functions. The added script will take a shadow copy snapshot of drive C: and D: (under a 32Bit >=Vista operating system) I'am very thankfull of your valuable help Lars!!! Without you I hadn't no chance of doing this. Now we can do shadowcopies directly with AutoIt. Thanks! Sundance COMshadow.au3
  12. LOL Lars. Thanks for the nice words but I'am lightyears away from mastering. :-) The $sCLSID_IVssAsync GUID is wrong. I saw that its just the IID for Windows XP Async interface. So now I'am stuck. I can't call ObjCreateInterface cause I have no $sCLSID_IVssAsync value. I have no returned interface pointer to use. Its really disturbing but good to see I wasn't totally wrong...
  13. Hi Lars, how the hell got you that knowledge from? It is adding the drive to the snapshotset! How should I know to make the method with four parameters when under 32bit? Perfect!!! Now I'am with the last command DoSnapShot with the double indirect pointer. Hope that at least this I can achive.. See you later guys. Hopefully with a shadowcopy :-) happy sunday Sundance PS: 2 hours later: Puuhhh. I think I must create a Async interface cause the DoSnapShot returns a double indirect pointer to a Async interface. (C++ sample code) IVssAsync *async; result = backupComponents->DoSnapshotSet(&async); But I don't know how to create the interface without knowing the clsid. Or I'am completly on the wrong train. Can't imagine how to 'connect' the given double pointer to the interface which is an object type... This is really bad. Microsft isn't really a help here. In c++ its much easier but I don't wan't to learn c++ again :-) Hope that I get some light tomorrow... ; creating Async interface => WRONG => Global Const $sCLSID_IVssAsync = "{C7B98A22-222D-4e62-B875-1A44980634AF}" Global Const $sIID_IVssAsync = "{507C37B4-CF5B-4e95-B0AF-14EB9767467E}" Global Const $dtag_IVssAsync = _ "Cancel hresult();" & _ ; <-- Add parameters for all methods "QueryStatus hresult(ptr; ptr);" & _ "Wait hresult(int64);" $oIVssAsync = ObjCreateInterface( $sCLSID_IVssAsync, $sIID_IVSSAsync, $dtag_IVssAsync )
  14. Hi John, yes it is the same. I also played with a byte[16] structure. Cause I don't know when using DllStructGet with selected element 1 will see the whole GUID struct or only the first long value. Thanks for the tips John...!
  15. Hiho, so I'am back from work and kids are sleeping so I directly tried again. But it still throws AutoIt of the wall. I've found a webpage where they do the same thing in C++. http://wj32.org/wp/2012/12/13/how-to-backup-files-in-c-using-the-volume-shadow-copy-service-vss/ The line with the AddToSnapshotSet is like this: result = backupComponents->AddToSnapshotSet(L"D:\\", GUID_NULL, &snapshotId); I used "D:", DllStructGetData($GUID_NULL,1), $pID_D) with the method AddToSnapshotSet hresult(wstr; byte[16]; ptr);" This seems to make most sense to me but no success.... This is really tough stuff... COMshadow.au3
  16. Good morning. *gähn* Sorry John. I did change the code a little bid. I did define $pID_D as DllStructGetPtr($ID_D). Only to make reading the method call easier. And good morning Lars. Just woke up and bevore going to work to shut down all our servers cause of a service event from the electrical guys I thougth of looking into the forum. I will try your idea ASAP . Yesterday I was really tired after programming/trying 10hours with just minor success.... I will report back guys! Sundance
  17. The last step is to add a drive for shadowing. This is the original info from microsoft: HRESULT AddToSnapshotSet( [in] VSS_PWSZ pwszVolumeName, [in] VSS_ID ProviderId, [out] VSS_ID *pidSnapshot ); Parameters pwszVolumeName [in] Null-terminated wide character string containing the name of the volume or the UNC path of the remote file share to be shadow copied. ProviderId [in] The provider to be used. GUID_NULL can be used, in which case the default provider will be used. pidSnapshot [out] Returned identifier of the added shadow copy. In the script I use this as the method definition: "AddToSnapshotSet hresult(wchar[250]; byte[16]; ptr);" Meanig I give it a wide char string, then the GUID which consists of 16 byte and a pointer targeting to the dll struct which should hold the new snapshotID. These are the definitions of the variables: Global $VolumeD = DllStructCreate("wchar[250]") DllStructSetData($VolumeD, 1, "d:\") Global $pVolumeD = DllStructGetPtr($VolumeD) Global $GUID_NULL = DllStructCreate("byte[16]") DllStructSetData($GUID_NULL, 1, _WinAPI_GUIDFromString("00000000-0000-0000-0000-000000000000")) And this is the call: $iResult = $oIVssBackupComponents.AddToSnapshotSet(DllStructGetData($VolumeD,1), DllStructGetData($GUID_NULL,1), $pID_D) I also tried using the $tagGUID when creating the $GUID_NULL structure but I think that DllStructGetData then will only grab the first 4 bytes of the ulong Data1 !? Thats where I'am hanging now. The last command $oIVssBackupComponents.DoSnapshotSet seems to work. So this is the last peace of the puzzle :-) Going to sleep and hope to find tommorow the light... Good night and I will report what I have come up with....
  18. Okay. Now I have the guid in the console output. Just a little error: ConsoleWrite("starting snapshot set done. ( " & _WinAPI_StringFromGUID(DllStructGetData($SetIdentifier,1)) & " )" & @CRLF) Should be: ConsoleWrite("starting snapshot set done. ( " & _WinAPI_StringFromGUID(DllStructGetPtr($SetIdentifier,1)) & " )" & @CRLF) So next fight is the next command AddToSnapshotSet. Till now it kills AutoIt. Digging again :-)
  19. Hi Lars, this is nearly the code I posted at 2:51pm. I tried then to output the GUID with ConsoleWrite("starting snapshot set done. ( " & _WinAPI_StringFromGUID(DllStructGetData($SetIdentifier,1)) & " )" & @CRLF) This throws an exception of AutoIt. Going to dig further... Really complex thingy :-)
  20. Hi John, I also read the note ( Note This function is exported as CreateVssBackupComponentsInternal, but you should call CreateVssBackupComponents, not CreateVssBackupComponentsInternal.) but I think you can only use the name CreateVssBackupComponents when using the VssAPI.lib within C cause there is the 'alias' set. So on my Win7 prof its working with CreateVssBackupComponentsInternal but I think it could be a problem on other Operating Systems. But thanks for looking at the code. Still trouble with the StartSnapshotSet method. Still won't function. Its really a hell with this COM stuff but there is no other way of making ShadowCopies without a third party program. :-(
  21. Oh man. Thanks LArs. How should I know about the star? Is there some manual/side to look for such an info? Thanks again Lars!!! Sundance
  22. Hi Lars, I really hate it when people asking everything and all and wanting step by step help and it seems they haven't done there homework. I think you could think the same about me but I really tried now for 5 hours to get the call .StartSnapshotSet running but it won't I looked at the other post containing some COM related questions but haven't found a solution. Can I post my code so far? I hope so. :-) Possibly you can help my again? So here is the code I have so far. Global $iEventError = 0 ; to be checked to know if com error occurs. Must be reset after handling. $oMyError = ObjEvent("AutoIt.Error", "ErrFunc") ; Install a custom error handler Local $hVSS = DllOpen("c:\windows\system32\vssapi.dll") Local $aResult $aResult = DllCall($hVSS, "handle", "CreateVssBackupComponentsInternal", "ptr*", 0) ConsoleWrite("CreateVssBackupComponentsInternal: " & @error & " " & $aResult[0] & " " & $aResult[1] & @CRLF) Local $pIVssBackupComponents = $aResult[1] Global $VolumeD = DllStructCreate("wchar[250]") DllStructSetData($VolumeD, 1, "d:\") Global $GUID_NULL = DllStructCreate($tagGUID ) DllStructSetData($GUID_NULL, 1, _WinAPI_GUIDFromString("{00000000-0000-0000-0000-000000000000}")) Global $SetIdentifier = DllStructCreate($tagGUID ) Global $pSI = DllStructGetPtr($SetIdentifier,1) Global $ID_D = DllStructCreate("char[64]") Global $ID_J = DllStructCreate("char[64]") Global $ppAsync = DllStructCreate("ptr") Global Const $sIID_IVssBackupComponents = "{665C1D5F-C218-414D-A05D-7FEF5F9D5C86}" Global Const $dtag_IVssBackupComponents = _ "GetWriterComponentsCount hresult();" & _ ; <-- Add parameters for all methods "GetWriterComponents hresult();" & _ "InitializeForBackup hresult(ptr);" & _ ; <-- InitializeForBackup "SetBackupState hresult(boolean; boolean; int; boolean);" & _ "InitializeForRestore hresult();" & _ "SetRestoreState hresult();" & _ "GatherWriterMetadata hresult();" & _ "GetWriterMetadataCount hresult();" & _ "GetWriterMetadata hresult();" & _ "FreeWriterMetadata hresult();" & _ "AddComponent hresult();" & _ "PrepareForBackup hresult();" & _ "AbortBackup hresult();" & _ "GatherWriterStatus hresult();" & _ "GetWriterStatusCount hresult();" & _ "FreeWriterStatus hresult();" & _ "GetWriterStatus hresult();" & _ "SetBackupSucceeded hresult();" & _ "SetBackupOptions hresult();" & _ "SetSelectedForRestore hresult();" & _ "SetRestoreOptions hresult();" & _ "SetAdditionalRestores hresult();" & _ "SetPreviousBackupStamp hresult();" & _ "SaveAsXML hresult();" & _ "BackupComplete hresult();" & _ "AddAlternativeLocationMapping hresult();" & _ "AddRestoreSubcomponent hresult();" & _ "SetFileRestoreStatus hresult();" & _ "AddNewTarget hresult();" & _ "SetRangesFilePath hresult();" & _ "PreRestore hresult();" & _ "PostRestore hresult();" & _ "SetContext hresult(long);" & _ "StartSnapshotSet hresult(ptr);" & _ "AddToSnapshotSet hresult(char[250]; char[250]; ptr);" & _ "DoSnapshotSet hresult(ptr);" & _ "DeleteSnapshots hresult();" & _ "ImportSnapshots hresult();" & _ "BreakSnapshotSet hresult();" & _ "GetSnapshotProperties hresult();" & _ "Query hresult();" & _ "IsVolumeSupported hresult();" & _ "DisableWriterClasses hresult();" & _ "EnableWriterClasses hresult();" & _ "DisableWriterInstances hresult();" & _ "ExposeSnapshot hresult();" & _ "RevertToSnapshot hresult();" & _ "QueryRevertStatus hresult();" $oIVssBackupComponents = ObjCreateInterface( $pIVssBackupComponents, $sIID_IVssBackupComponents, $dtag_IVssBackupComponents ) If IsObj( $oIVssBackupComponents ) Then ConsoleWrite( "$oIVssBackupComponents OK" & @CRLF ) $iResult = $oIVssBackupComponents.InitializeForBackup(0) If $iResult Then ConsoleWrite("error Initializing (" & Hex($iResult) & ")" & @CRLF) Exit(1) Else ConsoleWrite("Initializing done." & @CRLF) EndIf $iResult = $oIVssBackupComponents.SetBackupState(0, 0, 1, 0) If $iResult Then ConsoleWrite("error setting backup state (" & Hex($iResult) & ")" & @CRLF) Exit(1) Else ConsoleWrite("setting backup state done." & @CRLF) EndIf $iResult = $oIVssBackupComponents.SetContext(BitOR(1,8,10)) If $iResult Then ConsoleWrite("error setting context (" & Hex($iResult) & ")" & @CRLF) Exit(1) Else ConsoleWrite("setting context done." & @CRLF) EndIf $iResult = $oIVssBackupComponents.StartSnapshotSet($pSI) If $iResult > 0 Then ConsoleWrite("error starting snapshot set (" & Hex($iResult) & ")" & @CRLF) Exit(1) Else ConsoleWrite("starting snapshot set done. ( " & _WinAPI_StringFromGUID(DllStructGetData($SetIdentifier,1)) & " )" & @CRLF) EndIf $iResult = $oIVssBackupComponents.AddToSnapshotSet(DllStructGetData($VolumeD, 1), DllStructGetData($GUID_NULL, 1), DllStructGetPtr($ID_D)) If $iResult Then ConsoleWrite("error adding d:\ to snapshot set (" & Hex($iResult) & ")" & @CRLF) Exit(1) Else ConsoleWrite("adding d:\ to snapshot set done." & " (" & DllStructGetData($ID_D,1) & ")" & @CRLF) EndIf ;~ $iResult = $oIVssBackupComponents.AddToSnapshotSet("j:\", "{00000000-0000-0000-0000-000000000000}", DllStructGetPtr($ID_J)) ;~ If $iResult Then ;~ ConsoleWrite("error adding j:\ to snapshot set (" & Hex($iResult) & ")" & @CRLF) ;~ Exit(1) ;~ Else ;~ ConsoleWrite("adding j:\ to snapshot set done." & " (" & DllStructGetData($ID_J,1) & ")" & @CRLF) ;~ EndIf $iResult = $oIVssBackupComponents.DoSnapshotSet(DllStructGetPtr($ppAsync)) If $iResult Then ConsoleWrite("error doing snapshot set (" & Hex($iResult) & ")" & @CRLF) Exit(1) Else ConsoleWrite("doing snapshot set done." & @CRLF) EndIf ;~ $oIVssBackupComponents.StartSnapshotSet( DllStructGetPtr($SetIdentifier,1) ) ConsoleWrite("SetIdentifier: " & DllStructGetData($SetIdentifier, 1) & @CRLF) Else ConsoleWrite( "$oIVssBackupComponents ERR" & @CRLF ) EndIf ; This is a custom error handler Func ErrFunc() $HexNumber = Hex($oMyError.number, 8) MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "WinDescription is: " & $oMyError.windescription) $iEventError = 1 ; Use to check when a COM Error occurs EndFunc ;==>ErrFunc Its doing the calls of : $oIVssBackupComponents.InitializeForBackup $oIVssBackupComponents.SetBackupState $oIVssBackupComponents.SetContext They are returning with the value S_OK. Then comes $oIVssBackupComponents.StartSnapshotSet and this throws my AutoIt against a wall. It errors out that Autoit doesn't function anymore... puuuhhh. The call needs a pointer to a VSS_ID HRESULT StartSnapshotSet( [out] VSS_ID *pSnapshotSetId ); I created a dll structure with the $tagGUID structure and gave the $oIVssBackupComponents.StartSnapshotSet call the pointer to it. Also I defined the method as "StartSnapshotSet hresult(ptr);" Its only one parameter but its giving me a big headache :-| again some ~17°C warm greetings from germany Sundance
  23. Thanks Lars. I allready have a COM error handler in the code :-) I had InitializeForBackup(0) also tried but not with the definition of hresult(ptr). Many thanks again Lars !!!1 greetings from sunny germany Sundance
  24. Hi Lars, its me again :-) I did to do a InitializeForBackup. When using it for non transported shadow copies it is to be called without a parameter. I did now try doing this but getting errors. I did change "InitializeForBackup hresult(bstr);" into "InitializeForBackup hresult();" but COM error is 80020010 . Can you help me one more time Lars? thanks in advance!! Sundance
  25. Hi Lars, thanks for your post! I tried the ObjCreateInterface but hadn't any luck and also I was a little bit irritated by the help file which says that the command could be deleted in the next version of Autoit... I will try your sample code. Where did you get the IID Lars? Many thanks again Lars!!! sincerely yours Sundance
×
×
  • Create New...