youtuber Posted February 26, 2019 Share Posted February 26, 2019 (edited) None of these codes work. I want to delete all restore points #RequireAdmin Global $SystemDrive = EnvGet('SystemDrive') & '\' Global $obj_SR Run("vssadmin delete shadows /all /quiet") ;or ShellExecuteWait(@SystemDir & "\vssadmin.exe", " delete shadows /all /quiet") ShellExecuteWait(@SystemDir & "\vssadmin.exe", " vssadmin delete shadows /all /quiet") ;or Local $SRP = ObjGet("winmgmts:\\" & @ComputerName & "\root\default:Systemrestore") $SRP.Disable($SystemDrive) $SRP.Enable($SystemDrive) ;or _SR_Disable() Func _SR_Disable($DriveL = $SystemDrive) If Not IsObj($obj_SR) Then $obj_SR = ObjGet("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore") If Not IsObj($obj_SR) Then Return 0 If $obj_SR.Disable($DriveL) = 0 Then Return 1 Return 0 EndFunc ;==>_SR_Disable _SR_Enable() Func _SR_Enable($DriveL = $SystemDrive) If Not IsObj($obj_SR) Then $obj_SR = ObjGet("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore") If Not IsObj($obj_SR) Then Return 0 If $obj_SR.Enable($DriveL) = 0 Then Return 1 Return 0 EndFunc ;==>_SR_Enable And ;vssadmin delete shadows /For=(drive letter): /all /quiet Run("vssadmin delete shadows /For=C: /all /quiet") Run("vssadmin delete shadows /For=" & $SystemDrive & "/all /quiet") Edited February 26, 2019 by youtuber Link to comment Share on other sites More sharing options...
TheXman Posted February 26, 2019 Share Posted February 26, 2019 (edited) 23 minutes ago, youtuber said: None of these codes work. Can you be a little more specific as to what doesn't work and maybe the error that you are getting? Edited February 26, 2019 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
youtuber Posted February 26, 2019 Author Share Posted February 26, 2019 specified section is not deleted Link to comment Share on other sites More sharing options...
TheXman Posted February 27, 2019 Share Posted February 27, 2019 I can't see the image that you posted. What happens when you manually run the appropriate vssadmin command from an elevated (Administrator) command prompt? CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
youtuber Posted February 27, 2019 Author Share Posted February 27, 2019 (edited) @TheXman Works smoothly with vssadmin command as cmd Seamless running manual cmd code vssadmin delete shadows /all /quiet Look here I have a udf works fine but I don't want to use udf for me too complex just to delete all the restore points in udf I could not extract the codes. #include <SystemRestore.au3> _SR_RemoveAllRestorePoints() Couldn't it be simpler and short codes? expandcollapse popup#include-once #RequireAdmin Global $__g_oSR = Null, $__g_oSR_WMI = Null Global $__g_sSR_SystemDrive = EnvGet('SystemDrive') & '\' ; #FUNCTION# ==================================================================================================================== ; Name...........: _SR_EnumRestorePoints ; Description ...: Enumerates all existing restore points. ; Syntax.........: _SR_EnumRestorePoints() ; Parameters ....: None ; Return values .: Success - An array with info on the restore points: ; $Array[0][0] => Number of restore points. ; $Array[n][1] => Restore point's sequence number. ; $Array[n][2] => Restore point's description. ; $Array[n][3] => Restore point's creation date. ; Failure - An empty bi-dimensinal array where $Array[0][0] = 0. ; Author ........: FredAI ; Modified.......: mLipok ; Remarks .......: ; Related .......: _SR_RemoveAllRestorePoints() ; Link ..........: ; Example .......: Local $aRestorePoints = _SR_EnumRestorePoints() ; =============================================================================================================================== Func _SR_EnumRestorePoints() Local $aRestorePoints[1][3], $iCounter = 0 $aRestorePoints[0][0] = $iCounter If Not IsObj($__g_oSR_WMI) Then $__g_oSR_WMI = ObjGet("winmgmts:root/default") If Not IsObj($__g_oSR_WMI) Then _ Return $aRestorePoints Local $RPSet = $__g_oSR_WMI.InstancesOf("SystemRestore") If Not IsObj($RPSet) Then _ Return $aRestorePoints For $RP In $RPSet $iCounter += 1 ReDim $aRestorePoints[$iCounter + 1][3] $aRestorePoints[$iCounter][0] = $RP.SequenceNumber $aRestorePoints[$iCounter][1] = $RP.Description $aRestorePoints[$iCounter][2] = __SR_WMIDateStringToDate($RP.CreationTime) Next $aRestorePoints[0][0] = $iCounter Return $aRestorePoints EndFunc ;==>_SR_EnumRestorePoints Func __SR_WMIDateStringToDate($dtmDate) Return _ (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & _ StringLeft($dtmDate, 4) & " " & _ StringMid($dtmDate, 9, 2) & ":" & _ StringMid($dtmDate, 11, 2) & ":" & _ StringMid($dtmDate, 13, 2)) EndFunc ;==>__SR_WMIDateStringToDate ; #FUNCTION# ==================================================================================================================== ; Name...........: _SR_RemoveRestorePoint ; Description ...: Deletes a system restore point. ; Syntax.........: _SR_RemoveRestorePoint($rpSeqNumber) ; Parameters ....: $rpSeqNumber - The system restore point's sequence number. can be obtained with _SR_EnumRestorePoints ; Return values .: Success - 1 ; Failure - 0 and sets @error ; Author ........: FredAI ; Modified.......: ; Remarks .......: The system restore takes a few seconds to update. According to MSDN, this function doesn't work in safe mode. ; Related .......: _SR_RemoveAllRestorePoints ; Link ..........: ; Example .......: _SR_RemoveRestorePoint(20) ; =============================================================================================================================== Func _SR_RemoveRestorePoint($rpSeqNumber) Local $aRet = DllCall('SrClient.dll', 'DWORD', 'SRRemoveRestorePoint', 'DWORD', $rpSeqNumber) If @error Then _ Return SetError(1, 0, 0) If $aRet[0] = 0 Then _ Return 1 Return SetError(1, 0, 0) EndFunc ;==>_SR_RemoveRestorePoint ; #FUNCTION# ==================================================================================================================== ; Name...........: _SR_RemoveAllRestorePoints ; Description ...: Deletes all existing system restore points. ; Syntax.........: _SR_RemoveAllRestorePoints() ; Parameters ....: None ; Return values .: Success - The number of deleted restore points. ; Failure - Returns 0 if no restore points existed or an error occurred. ; Author ........: FredAI ; Modified.......: ; Remarks .......: The system restore takes a few seconds to update. According to MSDN, this function doesn't work in safe mode. ; Related .......: _SR_RemoveRestorePoint ; Link ..........: ; Example .......: Local $iSR_Deleted = _SR_RemoveAllRestorePoints() ; =============================================================================================================================== Func _SR_RemoveAllRestorePoints() Local $aRP = _SR_EnumRestorePoints(), $ret = 0 For $i = 1 To $aRP[0][0] $ret += _SR_RemoveRestorePoint($aRP[$i][0]) Next Return $ret EndFunc ;==>_SR_RemoveAllRestorePoints Edited February 27, 2019 by youtuber Link to comment Share on other sites More sharing options...
TheXman Posted February 27, 2019 Share Posted February 27, 2019 (edited) The UDF looks pretty simple and straight forward to me. To do what you want to do, it's a single call to _SR_RemoveAllRestorePoints(). What could be more simple than that? Why would you try to extract parts of the UDF instead of just including it and using it as is? If the vssadmin command works flawlessly from the command line, then you shouldn't have an issue running it from the script. That's why I asked you what error did you get when you ran it in the script. Use RunWait or ShellExecuteWait so you can easily get the return code from the command's execution and see if it executed successfully. Edited February 27, 2019 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
youtuber Posted February 27, 2019 Author Share Posted February 27, 2019 $DeleteAll1 = RunWait("vssadmin delete shadows /all /quiet") $DeleteAll2 = Runwait(@ComSpec & ' /c vssadmin delete shadows /all /quiet') $DeleteAll3 = ShellExecuteWait(@SystemDir & "\vssadmin.exe", " delete shadows /all /quiet") $DeleteAll4 = ShellExecuteWait(@SystemDir & "\vssadmin.exe", " vssadmin delete shadows /all /quiet") ConsoleWrite($DeleteAll1 & " : " & @error & " : " & @extended & @CRLF) ConsoleWrite($DeleteAll2 & " : " & @error & " : " & @extended & @CRLF) ConsoleWrite($DeleteAll3 & " : " & @error & " : " & @extended & @CRLF) ConsoleWrite($DeleteAll4 & " : " & @error & " : " & @extended & @CRLF) Here is the console output 2 : 0 : 0 2 : 0 : 0 2 : 0 : 0 2 : 0 : 0 Link to comment Share on other sites More sharing options...
TheXman Posted February 27, 2019 Share Posted February 27, 2019 @error and @extended are reset with every new function call. So you are only showing the @error and @extended from the previous function. 3 of the 4 consolewrites are showing the @error and @extended from the ConsoleWrites. In any case, the return code from the vssadmin commands show that the commands were not successful. Are you using #RequireAdmin in your testing? CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
youtuber Posted February 27, 2019 Author Share Posted February 27, 2019 My system is interesting, x64, but now I've tried the x64 version. It works fine. But I don't know which script works :( #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** $DeleteAll1 = RunWait("vssadmin delete shadows /all /quiet") $DeleteAll2 = Runwait(@ComSpec & ' /c vssadmin delete shadows /all /quiet') $DeleteAll3 = ShellExecuteWait(@SystemDir & "\vssadmin.exe", " delete shadows /all /quiet") $DeleteAll4 = ShellExecuteWait(@SystemDir & "\vssadmin.exe", " vssadmin delete shadows /all /quiet") ConsoleWrite($DeleteAll1 & " : " & @error & " : " & @extended & @CRLF) ConsoleWrite($DeleteAll2 & " : " & @error & " : " & @extended & @CRLF) ConsoleWrite($DeleteAll3 & " : " & @error & " : " & @extended & @CRLF) ConsoleWrite($DeleteAll4 & " : " & @error & " : " & @extended & @CRLF) Link to comment Share on other sites More sharing options...
TheXman Posted February 27, 2019 Share Posted February 27, 2019 Great! With a little more trouble shooting, you should be all set. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
youtuber Posted February 27, 2019 Author Share Posted February 27, 2019 @TheXman All codes are working. But if there is this line code : #AutoIt3Wrapper_UseX64=y #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** $DeleteAll1 = RunWait("vssadmin delete shadows /all /quiet") $DeleteAll2 = Runwait(@ComSpec & ' /c vssadmin delete shadows /all /quiet') $DeleteAll3 = ShellExecuteWait(@SystemDir & "\vssadmin.exe", " delete shadows /all /quiet") But I need it in 32 bits, what should I do for it :( Link to comment Share on other sites More sharing options...
TheXman Posted February 27, 2019 Share Posted February 27, 2019 youtuber 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Dwalfware Posted February 27, 2019 Share Posted February 27, 2019 Better way to output ComSpec Local $iPID = Run(@ComSpec & " /c ipconfig /all, @SystemDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ProcessWaitClose($iPID) Local $sOutput &= StdoutRead($iPID) ; .................................................. If $sOutput = "" or @error or $iPID = 0 Then Consolewrite("error") Else Consolewrite($sOutput) Endif ; .................................................. youtuber and Skysnake 1 1 Link to comment Share on other sites More sharing options...
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