Wingens Posted August 9, 2014 Share Posted August 9, 2014 I am stuck with a progressbar...been on it al morning but can't seem to get it to work properly.The problem i have is that my progessbar wil not close and the script will not run.The progressbar is just for looks it does nothing to the script.Can anyone point me to what i am doing wrong?i will post my script later when this is running with the progressbar. ProgressOn("Program: B@CK-UP", "Unpacking Tools", "Loading...") For $i = 0 To 100 step 25 Sleep(1000) ProgressSet(25, "VHD2DISK") Sleep(2500) ProgressSet(50, "PRODUKEY") Sleep(2500) ProgressSet(75, "MAILPASSVIEW") Sleep(2500) ProgressSet(100, "Done") Sleep(2500) Next ProgressOff() Link to comment Share on other sites More sharing options...
Developers Jos Posted August 9, 2014 Developers Share Posted August 9, 2014 (edited) Progressbar shows fine and it will go from 0 to 100% each time you do the For-Next loop ...so 4 times as you coded. Jos Edited August 9, 2014 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Solution Wingens Posted August 9, 2014 Author Solution Share Posted August 9, 2014 Got it, thank you for the tip, my mind it nog working to fast today ProgressOn("Program: B@CK-UP", "Unpacking Tools", "Loading...") Sleep(1000) ProgressSet(25, "VHD2DISK") Sleep(2500) ProgressSet(50, "PRODUKEY") Sleep(2500) ProgressSet(75, "MAILPASSVIEW") Sleep(2500) ProgressSet(100, "Done") Sleep(2500) ProgressOff() Link to comment Share on other sites More sharing options...
Wingens Posted August 9, 2014 Author Share Posted August 9, 2014 Here is my total code a promised: I am creating a Backup script for my work, the scripts makes it possible for my less technicle colleague to make backups. It uses the Tool: DISK2VHD from Microsoft, Produkey from Nirsoft and MailpassView from Nirsoft. Hope this helps someone else and if you have any improvements they are allways welcome expandcollapse popup#RequireAdmin #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ProgressConstants.au3> #include <GuiEdit.au3> #include <Array.au3> #include <File.au3> ;========================================================================================================================== Do $PASS = InputBox("Enter password:", " ", "", "*", 200, 125) If (@error == 1) Then Exit EndIf If $PASS <> "getin" Then MsgBox(4096, "Warning!", "Incorrect Password" & @CRLF & "Closing now.") Exit EndIf Until $PASS == "getin" ;--------------------------------------------------------------------------------------------------- Password to enter backup-tool ;========================================================================================================================== ProgressOn("Program: B@CK-UP", "Unpacking Tools", "Loading...") Sleep(1000) ProgressSet(25, "VHD2DISK") Sleep(2500) ProgressSet(50, "PRODUKEY") Sleep(2500) ProgressSet(75, "MAILPASSVIEW") Sleep(2500) ProgressSet(100, "Done") Sleep(2500) ProgressOff() ;========================================================================================================================== $VERSION = "Version: VHD Final" ;========================================================================================================================== ; Including Tools in .exe ;========================================================================================================================== $EXTRACT = 0 Ping("TD") If @error Then $EXTRACT = 1 EndIf If $EXTRACT = 1 Then DirCreate("C:\Tools") DirCreate("C:\Tools\MailPV") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\MailPV\mailpv.cfg", "C:\Tools\MailPV\mailpv.cfg") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\MailPV\mailpv.chm", "C:\Tools\MailPV\mailpv.chm") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\MailPV\mailpv.exe", "C:\Tools\MailPV\mailpv.exe") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\MailPV\mailpv_lng.ini", "C:\Tools\MailPV\mailpv_lng.ini") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\MailPV\readme.txt", "C:\Tools\MailPV\readme.txt") DirCreate("C:\Tools\Disk2VHD") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\Disk2VHD\Disk2vhd.chm", "C:\Tools\Disk2VHD\Disk2vhd.chm") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\Disk2VHD\disk2vhd.exe", "C:\Tools\Disk2VHD\disk2vhd.exe") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\Disk2VHD\Eula.txt", "C:\Tools\Disk2VHD\Eula.txt") DirCreate("C:\Tools\Produkey") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\Produkey\Produkey.chm", "C:\Tools\Produkey\Produkey.chm") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\Produkey\ProduKey.exe", "C:\Tools\Produkey\Produkey.exe") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\Produkey\ProduKey_lng.ini", "C:\Tools\Produkey\ProduKey_lng.ini") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\Produkey\readme.txt", "C:\Tools\Produkey\readme.txt") DirCreate("C:\Tools\Wirelesskeyview") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\WirelessKeyView\readme.txt", "C:\Tools\WirelessKeyView\readme.txt") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\WirelessKeyView\WirelessKeyView.cfg", "C:\Tools\WirelessKeyView\WirelessKeyView.cfg") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\WirelessKeyView\WirelessKeyView.chm", "C:\Tools\WirelessKeyView\WirelessKeyView.chm") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\WirelessKeyView\WirelessKeyView.exe", "C:\Tools\WirelessKeyView\WirelessKeyView.exe") DirCreate("C:\Tools\Robocopy") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\Robocopy\Robocopy.exe", "C:\Tools\Robocopy\Robocopy.exe") FileInstall("C:\Users\Beheerder\CloudStation\Scripting\Backup\Tools\Robocopy\Robocopy.doc", "C:\Tools\Robocopy\Robocopy.doc") EndIf ;========================================================================================================================== ; Including Tools in .exe ;========================================================================================================================== $GUI = GUICreate("", 560, 412, -1, -1, $WS_POPUPWINDOW) $SOURCEDRIVEINPUT = GUICtrlCreateInput("Select Source Drive...", 54, 61, 121, 21) GUICtrlSetState($SOURCEDRIVEINPUT, $GUI_DISABLE) $SOURCEDRIVEBUTTON = GUICtrlCreateButton("...", 176, 61, 30, 17) GUICtrlSetState($SOURCEDRIVEBUTTON, $GUI_DISABLE) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetTip(-1, "Click here to select the source drive...") $SOURCELABEL = GUICtrlCreateLabel("Source Drive:", 54, 32, 82, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $FOUNDOS = GUICtrlCreateLabel("OS found on Source Drive:", 56, 96, 132, 17) $FOUNDOSINPUT = GUICtrlCreateInput("", 56, 115, 121, 21) GUICtrlSetState($FOUNDOSINPUT, $GUI_DISABLE) $TARGETDRIVEINPUT = GUICtrlCreateInput("Select Target Drive...", 344, 61, 121, 21) GUICtrlSetState($TARGETDRIVEINPUT, $GUI_DISABLE) $TARGETDRIVEBUTTON = GUICtrlCreateButton("...", 466, 61, 30, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetTip(-1, "Click here to select the target drive...") $CONNECT = 1 Ping("TD") If @error Then $CONNECT = 0 EndIf If $CONNECT = 1 Then $CMD = "net use \\td td /user:td" RunWait(@ComSpec & " /c " & $CMD, "", @SW_HIDE) GUICtrlSetData($TARGETDRIVEINPUT, "\\td\Backup\") GUICtrlSetState($TARGETDRIVEBUTTON, $GUI_DISABLE) EndIf $TARGETFOLDERLABEL = GUICtrlCreateLabel("Target Folder:", 344, 96, 82, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $TARGETFOLDERINPUT = GUICtrlCreateInput("", 344, 115, 121, 21, $ES_NUMBER) $TARGETLABEL = GUICtrlCreateLabel("Target Drive:", 344, 32, 79, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $VHD = GUICtrlCreateCheckbox("Create VHD - Selected Partition only", 56, 142) $VHDALL = GUICtrlCreateCheckbox("Create VHD - All Partitions", 56, 162) $HELP = GUICtrlCreateButton("Help", 8, 200, 75, 25) GUICtrlSetState($HELP, $GUI_DISABLE) $CLOSE = GUICtrlCreateButton("Close", 380, 200, 75, 25) $START = GUICtrlCreateButton("Start", 464, 200, 75, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $LOGGER = GUICtrlCreateEdit("", 8, 232, 545, 169, $ES_READONLY + $ES_AUTOVSCROLL + $ES_MULTILINE) LOGFILE("==========================================Info============================================") LOGFILE("Created by: Mark Wingens " & $VERSION) LOGFILE("=======================================Log-Screen=========================================") GUISetState(@SW_SHOW) ;========================================================================================================================== ; End Creating the GUI ;========================================================================================================================== While 1 $Msg = GUIGetMsg() Select Case $msg = $SOURCEDRIVEBUTTON SelectSource() Case $msg = $TARGETDRIVEBUTTON SelectTarget() Case $msg = $START Start() Case $msg = $GUI_EVENT_CLOSE If FileExists("C:\Tools") Then DirRemove("C:\Tools", 1) EndIf Exit Case $msg = $CLOSE If FileExists("C:\Tools") Then DirRemove("C:\Tools", 1) EndIf Exit Case $msg = $VHD If GUICtrlRead($VHD) = $GUI_CHECKED Then Sleep(50) GUICtrlSetState($SOURCEDRIVEBUTTON, $GUI_ENABLE) GUICtrlSetState($VHDALL, $GUI_DISABLE) EndIf If GUICtrlRead($VHD) = $GUI_UNCHECKED Then Sleep(50) GUICtrlSetState($SOURCEDRIVEBUTTON, $GUI_DISABLE) GUICtrlSetState($VHDALL, $GUI_ENABLE) EndIf Case $msg = $VHDALL If GUICtrlRead($VHDALL) = $GUI_CHECKED Then Sleep(50) GUICtrlSetState($VHD, $GUI_DISABLE) EndIf If GUICtrlRead($VHDALL) = $GUI_UNCHECKED Then Sleep(50) GUICtrlSetState($VHD, $GUI_ENABLE) EndIf EndSelect WEnd ;========================================================================================================================== ;========================================================================================================================== Func SelectSource() $SourceData = FileSelectFolder("Select Source Drive", "") GUICtrlSetData($SOURCEDRIVEINPUT, $SourceData) If FileExists($SourceData & "Program Files\Outlook Express") Then GUICtrlSetData($FOUNDOSINPUT, "Windows XP") EndIf If FileExists($SourceData & "Program Files\Windows Mail") Then GUICtrlSetData($FOUNDOSINPUT, "Vista or above") EndIf $EMPTY = GUICtrlRead($FOUNDOSINPUT) If $EMPTY = "" Then GUICtrlSetData($FOUNDOSINPUT, "Unknown") EndIf EndFunc ;========================================================================================================================== ;========================================================================================================================== Func SelectTarget() $TargetData = FileSelectFolder("Select Target Drive", "") GUICtrlSetData($TARGETDRIVEINPUT, $TargetData) EndFunc ;========================================================================================================================== ;========================================================================================================================== Func Start() $GO = 1 $WIN7 = 0 $WINXP = 0 $CHECKSOURCEDRIVE = GUICtrlRead($SOURCEDRIVEINPUT) $CHECKFOUNDOS = GUICtrlRead($FOUNDOSINPUT) $CHECKTARGETDRIVE = GUICtrlRead($TARGETDRIVEINPUT) $CHECKTARGETFOLDER = GUICtrlRead($TARGETFOLDERINPUT) If GUICtrlRead($VHD) = $GUI_CHECKED Then If $CHECKSOURCEDRIVE == "Select Source Drive..." Then MsgBox(4096, "Warning!", "Please select a source drive.") $GO = 0 EndIf EndIf If $CHECKTARGETDRIVE == "" Then MsgBox(4096, "Warning!", "Please select a target drive.") $GO = 0 EndIf If $CHECKTARGETDRIVE == "Select Target Drive..." Then MsgBox(4096, "Warning!", "Please select a target drive.") $GO = 0 EndIf If $CHECKSOURCEDRIVE == $CHECKTARGETDRIVE Then MsgBox(4096, "Warning!", "Source drive & Target drive can not be the same.") $GO = 0 EndIf If $CHECKTARGETFOLDER == "Input target folder name" Then MsgBox(4096, "Warning!", "Please put in a target folder name.") $GO = 0 EndIf If $CHECKTARGETFOLDER == "" Then MsgBox(4096, "Warning!", "Please put in a target folder name.") $GO = 0 EndIf If GUICtrlRead($VHD) = $GUI_UNCHECKED And GUICtrlRead($VHDALL) = $GUI_UNCHECKED Then MsgBox(4096, "Warning!", "Choose one VHD backup.") $GO = 0 EndIf If FileExists(@ScriptDir & "\BACKUPLOG.txt") Then FileDelete(@ScriptDir & "\BACKUPLOG.txt") EndIf If $GO == 1 Then $FILE = FileOpen(@ScriptDir & "\BACKUPLOG.txt", 2) If $FILE = -1 Then MsgBox(4096, "Warning!", "Unable to create the log file.") $GO = 0 EndIf EndIf If $GO == 1 Then ;========================================================================================================================== ; Start Disable the GUI ;========================================================================================================================== GUICtrlSetState($SOURCEDRIVEBUTTON, $GUI_DISABLE) GUICtrlSetState($TARGETDRIVEBUTTON, $GUI_DISABLE) GUICtrlSetState($TARGETFOLDERINPUT, $GUI_DISABLE) GUICtrlSetState($VHD, $GUI_DISABLE) GUICtrlSetState($VHDALL, $GUI_DISABLE) GUICtrlSetState($START, $GUI_DISABLE) GUICtrlSetData($START, "Running") GUICtrlSetState($CLOSE, $GUI_DISABLE) ;========================================================================================================================== ; End Disable the GUI ;========================================================================================================================== FileWriteLine($FILE, "=========================================================================================" & @CRLF) FileWriteLine($FILE, "Created by: Mark Wingens" & @CRLF) FileWriteLine($FILE, "=======================================Log-Screen========================================" & @CRLF) $READSOURCEDRIVE = GUICtrlRead($SOURCEDRIVEINPUT) LOGFILE("Source Drive: " & $READSOURCEDRIVE) FileWriteLine($FILE, "Source Drive: " & $READSOURCEDRIVE & @CRLF) $READSOURCEOS = GUICtrlRead($FOUNDOSINPUT) LOGFILE("Source OS: " & $READSOURCEOS) FileWriteLine($FILE, "Source OS: " & $READSOURCEOS & @CRLF) LOGFILE("=========================================================================================") FileWriteLine($FILE, "=========================================================================================" & @CRLF) $READTARGETDRIVE = GUICtrlRead($TARGETDRIVEINPUT) LOGFILE("Target Drive: " & $READTARGETDRIVE) FileWriteLine($FILE, "Target Drive: " & $READTARGETDRIVE & @CRLF) $READTARGETFOLDER = GUICtrlRead($TARGETFOLDERINPUT) LOGFILE("Target Folder: " & $READTARGETFOLDER) FileWriteLine($FILE, "Target Folder: " & $READTARGETFOLDER & @CRLF) LOGFILE("=========================================================================================") FileWriteLine($FILE, "=========================================================================================" & @CRLF) If GUICtrlRead($VHD) = $GUI_CHECKED Then LOGFILE("Selection option: Create VHD - Selection Partition only") FileWriteLine($FILE, "Selection option: Create VHD - Selection Partition only" & @CRLF) LOGFILE("=========================================================================================") FileWriteLine($FILE, "=========================================================================================" & @CRLF) EndIf If GUICtrlRead($VHDALL) = $GUI_CHECKED Then LOGFILE("Selection option: Create VHD - All Partitions") FileWriteLine($FILE, "Selection option: Create VHD - All Partitions" & @CRLF) LOGFILE("=========================================================================================") FileWriteLine($FILE, "=========================================================================================" & @CRLF) EndIf ;========================================================================================================================== ; START COPY ;========================================================================================================================== If GUICtrlRead($VHD) = $GUI_CHECKED Then $TARGETCOPY = $READTARGETDRIVE & $READTARGETFOLDER If Not FileExists($TARGETCOPY) Then DirCreate($TARGETCOPY) EndIf If FileExists("C:\Tools\Disk2VHD\disk2vhd.exe") Then $STRIPPED = StringTrimRight($READSOURCEDRIVE, 1) RunWait("C:\Tools\Disk2VHD\disk2vhd.exe " & $STRIPPED & " " & $READTARGETDRIVE & $READTARGETFOLDER & "\" & $READTARGETFOLDER & ".vhd") LOGFILE("Creating VHD") FileWriteLine($FILE, "Creating VHD") EndIf EndIf If GUICtrlRead($VHDALL) = $GUI_CHECKED Then $TARGETCOPY = $READTARGETDRIVE & $READTARGETFOLDER If Not FileExists($TARGETCOPY) Then DirCreate($TARGETCOPY) EndIf If FileExists("C:\Tools\Disk2VHD\disk2vhd.exe") Then $STRIPPED = StringTrimRight($READSOURCEDRIVE, 1) RunWait("C:\Tools\Disk2VHD\disk2vhd.exe * " & $READTARGETDRIVE & $READTARGETFOLDER & "\" & $READTARGETFOLDER & ".vhd") LOGFILE("Creating VHD @ " & $TARGETCOPY) FileWriteLine($FILE, "Creating VHD @ " & $TARGETCOPY) EndIf EndIf ;========================================================================================================================== ; END COPY ;========================================================================================================================== ;========================================================================================================================== ; START MAILPASSVIEW & PRODUKEY & WIRELESSKEYVIEW ;========================================================================================================================== If GUICtrlRead($SOURCEDRIVEINPUT) = "C:\" Then $TARGETCOPY = $READTARGETDRIVE & $READTARGETFOLDER LOGFILE("=========================================================================================") FileWriteLine($FILE, "=========================================================================================" & @CRLF) If FileExists("C:\Tools\mailpv\mailpv.exe") Then LOGFILE("Saving e-mail account settings") FileWriteLine($FILE, "Saving e-mail account settings") RunWait("C:\Tools\mailpv\mailpv.exe /stext " & $TARGETCOPY & "\E-mail.txt") EndIf LOGFILE("=========================================================================================") FileWriteLine($FILE, "=========================================================================================" & @CRLF) If FileExists("C:\Tools\Produkey\ProduKey.exe") Then LOGFILE("Saving license keys") FileWriteLine($FILE, "Saving license keys") RunWait("C:\Tools\Produkey\ProduKey.exe /IEKeys 0 /stext " & $TARGETCOPY & "\Keys.txt") EndIf LOGFILE("=========================================================================================") FileWriteLine($FILE, "=========================================================================================" & @CRLF) If FileExists("C:\Tools\wirelesskeyview\WirelessKeyView.exe") Then LOGFILE("Saving Wireless keys") FileWriteLine($FILE, "Saving Wireless keys") RunWait("C:\Tools\wirelesskeyview\WirelessKeyView.exe /stext " & $TARGETCOPY & "\WLAN.txt") LOGFILE("=========================================================================================") FileWriteLine($FILE, "=========================================================================================" & @CRLF) EndIf EndIf If GUICtrlRead($SOURCEDRIVEINPUT) <> "C:\" Then $TARGETCOPY = $READTARGETDRIVE & $READTARGETFOLDER $VAR = GUICtrlRead($SOURCEDRIVEINPUT) LOGFILE("=========================================================================================") FileWriteLine($FILE, "=========================================================================================" & @CRLF) If FileExists("C:\Tools\Produkey\ProduKey.exe") Then LOGFILE("Saving license keys") FileWriteLine($FILE, "Saving license keys") RunWait("C:\Tools\Produkey\ProduKey.exe /windir " & $VAR & "\Windows " & " /IEKeys 0 /stext " & $TARGETCOPY & "\Keys.txt") EndIf LOGFILE("=========================================================================================") FileWriteLine($FILE, "=========================================================================================" & @CRLF) EndIf ;========================================================================================================================== ; END MAILPASSVIEW & PRODUKEY & WIRELESSKEYVIEW ;========================================================================================================================== LOGFILE("=========================================================================================") FileCopy(@ScriptDir & "\BACKUPLOG.TXT", $TARGETCOPY, 1) If Not FileExists($TARGETCOPY & "\BACKUPLOG.TXT") Then MsgBox(4096, "Failed!", "Failed to copy log-file") EndIf If FileExists($TARGETCOPY & "\BACKUPLOG.TXT") Then FileDelete(@ScriptDir & "\BACKUPLOG.TXT") EndIf LOGFILE("Finished") FileWriteLine($FILE, "Finished") LOGFILE("=========================================================================================") FileWriteLine($FILE, "=========================================================================================" & @CRLF) FileClose($FILE) If FileExists("C:\Tools") Then DirRemove("C:\Tools", 1) EndIf Beep(1000, 200) Beep(1000, 120) Beep(1000, 120) MsgBox(4096, "Done", "Backup has been completed, press OK to open Backup-Folder.") Run("C:\Windows\explorer.exe " & $TARGETCOPY) Exit EndIf EndFunc Func LOGFILE($logtext) _GUICtrlEdit_AppendText($LOGGER, @CRLF & $logtext) EndFunc 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