surreal Posted November 11, 2009 Posted November 11, 2009 (edited) below is my code, i have at this time two process local backup $temp and network backup $temp2 are the locations, all in at this time c:temp. i was going to try and add a restore from backup local backup $temp3, not created yet do to i found a problem with my code. im going to try and explain this as best as posable, if you have any question please ask. checkboxes if $GUI_CHECKED then do local or network or restore depending on whats checked. the code that i have provided will do local or network no matter if checkbox is checked or not. expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <Array.au3> #include <HKCUReg.au3> #include <WinCopy.au3> ;===Checks Local OSVersion Create Var User Friendly================================================ $OS = @OSVersion $OS = StringReplace($OS, "WIN_VISTA", "Windows Vista") $OS = StringReplace($OS, "WIN_XP", "Windows XP") $OS = StringReplace($OS, "WIN_2000", "Windows 2000") ;===Determines Documents Location According To OS++================================================ $OSDOC = @OSVersion If $OSDOC = "WIN_VISTA" Then $DOC = "\Users\" If $OSDOC = "WIN_XP" Then $DOC = "\Documents and Settings\" EndIf $OSDF = @OSVersion If $OSDF = "WIN_VISTA" Then $DF = "Documents" If $OSDF = "WIN_XP" Then $DF = "My Documents" EndIf Local $Temp = "\Migrate_Local\" Local $Temp2 = "\Migrate_Network\" Local $LogFile = "c:\Temp\LogFile.txt" Local $Separator = "------------------------------" ;===GUI Start and File Menu======================================================================== $ParentWin = GUICreate("", 330, 165, -1, -1) $FileMenu = GUICtrlCreateMenu("&File") $BKItem = GUICtrlCreateMenuItem("Backup Only", $FileMenu) $RSItem = GUICtrlCreateMenuItem("Restore Only", $FileMenu) GUICtrlSetState($BKItem, $GUI_UNCHECKED) GUICtrlSetState($RSItem, $GUI_UNCHECKED) $ExitItem = GUICtrlCreateMenuItem("Exit", $FileMenu) $ViewMenu = GUICtrlCreateMenu("&View") $LogItem = GUICtrlCreateMenuItem("Log File", $ViewMenu) $ProMenu = GUICtrlCreateMenu("&Programs") $RDItem = GUICtrlCreateMenuItem("Remote Desktop", $ProMenu) $CMItem = GUICtrlCreateMenuItem("Computer Management", $ProMenu) $CPItem = GUICtrlCreateMenuItem("Command Prompt", $ProMenu) $HelpMenu = GUICtrlCreateMenu("&Help") $HelpItem = GUICtrlCreateMenuItem("Help", $HelpMenu) ;===GUI Network Computer To Tranfer From=========================================================== GUICtrlCreateGroup("System", 10, 10, 190, 75) GUICtrlCreateLabel("Computer Name:", 20, 25) $cnTarget = GUICtrlCreateInput(@ComputerName, 20, 40, 120, 20) $cnMessage = GUICtrlCreateLabel("Enter computer name or ip address", 20, 64, 175, 15) $cnButton = GUICtrlCreateButton("Connect", 145, 35, 50, 25, $WS_GROUP) ;===GUI Network User Profile======================================================================= GUICtrlCreateGroup("Profile:", 10, 90, 190, 45) $prCombo = GUICtrlCreateCombo("", 20, 105, 175, 20) ;===GUI Group What To Migrate====================================================================== GUICtrlCreateGroup("Tranfer", 210, 10, 110, 80) $BoxDocs = GUICtrlCreateCheckbox("My Documents", 220, 25) $BoxPrinter = GUICtrlCreateCheckbox("Network Printers", 220, 45) $BoxLotus = GUICtrlCreateCheckbox("Lotus Notes", 220, 65) GUICtrlSetState($BoxDocs, $GUI_CHECKED) GUICtrlSetState($BoxPrinter, $GUI_CHECKED) ;===GUI Start Function============================================================================= $StartButton = GUICtrlCreateButton("Start", 230, 100, 65, 30, $WS_GROUP) GUISetState(@SW_SHOW) ;===Start Of GUIGetMsg============================================================================= While 1 $msg = GUIGetMsg() Select ;===Case For Exit GUI============================================================================== Case $msg = $ExitItem Or $msg = $GUI_EVENT_CLOSE $FormClose = MsgBox(36, "", "Are you sure you want to exit?") If $FormClose = 6 Then GUIDelete() Exit EndIf ;===Case For File Menu Items======================================================================= Case $msg = $BKItem If BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($BKItem, $GUI_UNCHECKED) Else GUICtrlSetState($BKItem, $GUI_CHECKED) Local $BKtarget = FileSelectFolder("Choose the location you want to back up to:", "") If $BKtarget = '' Then GUICtrlSetState($BKItem, $GUI_UNCHECKED) EndIf Case $msg = $RSItem If BitAND(GUICtrlRead($RSItem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($RSItem, $GUI_UNCHECKED) Else GUICtrlSetState($RSItem, $GUI_CHECKED) Local $RStarget = FileSelectFolder("Choose the location you want to restore from:", "") If $RStarget = '' Then GUICtrlSetState($RSItem, $GUI_UNCHECKED) EndIf Case $msg = $HelpItem MsgBox(64, "", "Help File Coming Soon") Case $msg = $RDItem Run('mstsc.exe', @SystemDir) Case $msg = $CMItem ShellExecute('compmgmt.msc', @SystemDir, @SW_MAXIMIZE) Case $msg = $LogItem If FileExists($LogFile) Then ShellExecute($LogFile, "") Else MsgBox(48, "", "A Log File has not been created yet.") EndIf Case $msg = $CPItem Run('cmd.exe', @SystemDir) ;===Case For Lotus Notes CheckBox================================================================== Case $msg = $BoxLotus If GUICtrlRead($cnTarget) = '' Or GUICtrlRead($prCombo) = '' Then MsgBox(16, "", 'Target machine and a profile must be entered') GUICtrlSetState($BoxLotus, $GUI_UNCHECKED) EndIf If BitAND(GUICtrlRead($BoxLotus), $GUI_UNCHECKED) = $GUI_UNCHECKED Then GUICtrlSetState($BoxLotus, $GUI_UNCHECKED) Else Lotus() GUICtrlSetState($BoxLotus, $GUI_CHECKED) EndIf ;===Case For Connect=============================================================================== Case $msg = $cnButton If GUICtrlRead($cnTarget) = '' Then GUICtrlSetData($cnMessage, 'Target machine must be entered') GUICtrlSetColor($cnMessage, 0xFF0000) ContinueLoop EndIf $Log = FileOpen($LogFile, 10) FileWriteLine($LogFile, "Started: " & @MON & "/" & @MDAY & "/" & @YEAR & " at " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF & @CRLF & "System Info" & @CRLF & $Separator & @CRLF) FileWriteLine($LogFile, "Operating System: " & $OS & @CRLF & "Computer Name: " & @ComputerName & @CRLF) FileClose($LogFile) Connect() Case $msg = $StartButton If GUICtrlRead($cnTarget) = '' Or GUICtrlRead($prCombo) = '' Then MsgBox(16, "", 'Target machine and a profile must be entered') Else StartButton() EndIf EndSelect WEnd ;===Function For Remote System InfoBox============================================================= Func Connect() SplashTextOn("", "Querying Network", 165, 40, -1, -1, 2, "", 9) Sleep(1000) If Ping(GUICtrlRead($cnTarget)) Then $strComputer = GUICtrlRead($cnTarget) $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") SplashOff() If Not IsObj($objWMIService) Then GUICtrlSetData($cnMessage, 'Failed to connect to system') GUICtrlSetColor($cnMessage, 0xFF0000) Return EndIf ;===WMI BIOS $colItems1 = $objWMIService.ExecQuery("SELECT * FROM Win32_Bios") $message = "System Info for " & $strComputer & @CRLF & $Separator & @CRLF & @CRLF For $objItem In $colItems1 $message &= "Dell Asset Number: " & $objItem.SerialNumber & @CRLF & _ "Manufacturer: " & $objItem.Manufacturer & @CRLF & @CRLF Global $surreal = $objItem.SerialNumber Global $RemoteName = $strComputer Next ;===WMI NETWORK $colItems2 = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") For $objItem In $colItems2 $message &= "IP Address: " & $objItem.IPAddress(0) & @CRLF & _ "IP Subnet: " & $objItem.IPSubnet(0) & @CRLF & @CRLF Next ;===WMI SYSTEM $colItems3 = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") For $objItem In $colItems3 $message &= "Model: " & $objItem.Model & @CRLF & _ "Computer Name: " & $objItem.Name & @CRLF & _ "Last User: " & $objItem.UserName & @CRLF Global $RemoteUser = $objItem.UserName Next GUICtrlSetData($cnMessage, 'Connected, select user profile') GUICtrlSetColor($cnMessage, 0x008000) MsgBox(64, "System Information", $message) Else SplashOff() GUICtrlSetData($cnMessage, 'Target system could not be contacted') GUICtrlSetColor($cnMessage, 0xFF0000) Return EndIf Profile() EndFunc ;==>Connect ;===Function For Remote Profile Load=============================================================== Func Profile() Local $combo_string = "" $FolderList = _FileListToArray("\\" & GUICtrlRead($cnTarget) & "\c$" & $DOC, "*", 2) For $i = 1 To $FolderList[0] Switch $FolderList[$i] Case "All Users", "Default User", "LocalService", "NetworkService" ContinueLoop Case Else If $i = $FolderList[0] Then $combo_string &= $FolderList[$i] Else $combo_string &= $FolderList[$i] & "|" EndIf EndSwitch Next GUICtrlSetData($prCombo, $combo_string) EndFunc ;==>Profile ;===Function For Checkbox Actions================================================================== Func StartButton() Local $Path = "\\" & GUICtrlRead($cnTarget) Local $rmdocs = $Path & "\c$" & $DOC & GUICtrlRead($prCombo) & "\" & $DF ;===My Documents If GUICtrlRead($BoxDocs) = $GUI_CHECKED Then GUICtrlSetData($cnMessage, 'Transferring: My Documents') GUICtrlSetColor($cnMessage, 0x008000) If BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then ;----------Local DirCreate($BKtarget & $Temp & $DF & "\" & GUICtrlRead($prCombo)) _CopyWithProgress($rmdocs & "\*.*", $BKtarget & $Temp & $DF & "\" & GUICtrlRead($prCombo)) FileWriteLine($LogFile, "My Documents" & @TAB & "(Backup Successful)" & @CRLF) Else ;----------Network DirCreate($Temp2 & $DF & "\" & GUICtrlRead($prCombo)) _CopyWithProgress($rmdocs & "\*.*", $BKtarget & $Temp2 & $DF & "\" & GUICtrlRead($prCombo)) FileWriteLine($LogFile, "My Documents" & @TAB & "(Successful)" & @CRLF) EndIf ;===Printers If GUICtrlRead($BoxPrinter) = $GUI_CHECKED Then GUICtrlSetData($cnMessage, 'Transferring: Printers') GUICtrlSetColor($cnMessage, 0x008000) If BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then DirCreate($BKtarget & $Temp & "Printers") Printers() FileWriteLine($LogFile, @CRLF & $Separator & "Lotus Notes:" & @TAB & "(:Local Successful)" & @CRLF) Else DirCreate($Temp2 & "Printers") Printers() FileWriteLine($LogFile, @CRLF & $Separator & "Lotus Notes:" & @TAB & "(Network Successful)" & @CRLF) EndIf ;===Lotus Notes If GUICtrlRead($BoxLotus) = $GUI_CHECKED Then GUICtrlSetData($cnMessage, 'Transferring: Lotus Notes') GUICtrlSetColor($cnMessage, 0x008000) If BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then DirCreate($BKtarget & $Temp & "Notes") _CopyWithProgress($Lotus_Location & "\*.id", $BKtarget & $Temp & "Notes") _CopyWithProgress($Lotus_Location & "\Desktop6.ndk", $BKtarget & $Temp & "Notes") _CopyWithProgress($Lotus_Location & "\Names.nsf", $BKtarget & $Temp & "Notes") _CopyWithProgress($Lotus_Location & "\User.dic", $BKtarget & $Temp & "Notes") DirCreate($BKtarget & $Temp & "Notes\Archive") _CopyWithProgress($Lotus_Location & "\Archive", $BKtarget & $Temp & "Notes\Archive") FileWriteLine($LogFile, @CRLF & $Separator & "Lotus Notes:" & @TAB & "(Local Successful)" & @CRLF) Else DirCreate($Temp2 & "Notes") _CopyWithProgress($Lotus_Location & "\*.id", $Temp2 & "Notes") _CopyWithProgress($Lotus_Location & "\Desktop6.ndk", $Temp2 & "Notes") _CopyWithProgress($Lotus_Location & "\Names.nsf", $Temp2 & "Notes") _CopyWithProgress($Lotus_Location & "\User.dic", $Temp2 & "Notes") DirCreate($Temp2 & "Notes\Archive") _CopyWithProgress($Lotus_Location & "\Archive", $Temp2 & "Notes\Archive") FileWriteLine($LogFile, @CRLF & $Separator & "Lotus Notes:" & @TAB & "(Network Successful)" & @CRLF) EndIf SoundPlay(@WindowsDir & "\media\tada.wav", 1) $Success = MsgBox(4, "", "Migration Was Successful. Do You Want To Exit?") If $Success = 6 Then Exit EndFunc ;==>StartButton ;===Function For Save Printer Info File============================================================ Func Printers() Local $passet = GUICtrlRead($cnTarget) If BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then Local $pLocation = $BKtarget & $Temp & "Printers\Printers.txt" Else Local $pLocation = $Temp2 & "Printers\Printers.txt" EndIf $pFile = FileOpen($pLocation, 10) For $i = 1 To 25 $p = _HKCU_EnumVal("\\\" & $passet & "\Software\Microsoft\Windows NT\CurrentVersion\Devices", $i) $iProdp = 1 For $n = 1 To $p[0][0] $iProdp *= $p[$n][2] If $p[$n][2] = 0 Then $ppath = _HKCU_Read("\\\" & $passet & "\\" & $p[$n][1], "Devices") EndIf If StringRegExp($p[$n][1], "^\\\\(?!\\)") Then FileWriteLine($pFile, $p[$n][1] & "," & $ppath[1][1]) EndIf Next If $iProdp <> 0 Then ExitLoop Next EndFunc ;==>Printers ;===Function For Lotus Notes Child Window========================================================== Func Lotus() $ChildWin = GUICreate("", 135, 110, -1, -1, $WS_EX_TOPMOST) GUISwitch($ChildWin) $Box_Single = GUICtrlCreateRadio("Single User Install", 10, 10) $Box_Multi = GUICtrlCreateRadio("Multi User Install", 10, 30) $Box_System = GUICtrlCreateRadio("Root System Install", 10, 50) GUISetState() While 1 $lnmsg = GUIGetMsg() Select Case $lnmsg = $Box_Single And BitAND(GUICtrlRead($Box_Single), $GUI_CHECKED) = $GUI_CHECKED Global $Lotus_Location = "\\" & GUICtrlRead($cnTarget) & "\c$\Program Files\Lotus\Notes\Data" GUIDelete($ChildWin) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) Case $lnmsg = $Box_Multi And BitAND(GUICtrlRead($Box_Multi), $GUI_CHECKED) = $GUI_CHECKED Global $Lotus_Location = "\\" & GUICtrlRead($cnTarget) & "\c$" & $DOC & GUICtrlRead($prCombo) & "\Local Settings\Application Data\Lotus\Notes\Data" GUIDelete($ChildWin) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) Case $lnmsg = $Box_System And BitAND(GUICtrlRead($Box_System), $GUI_CHECKED) = $GUI_CHECKED Global $Lotus_Location = "\\" & GUICtrlRead($cnTarget) & "\c$\Lotus\Notes\Data" GUIDelete($ChildWin) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) EndSelect WEnd EndFunc ;==>Lotus maybe i call a function checkboxes() that is something like: if checkbox1 checked then another function endif if checkbox2 checked then another function endif if checkbox3 checked then another function endif another function() if local checked then copy to local location else if network checked then copy to network location else if restore checked then copy to restore location endif endif endif not even sure if the above is right, do to i have each checkbox doing something different within it, pretty much looking for correct syntax, thank you everyone for your help. d@ve Edited November 11, 2009 by surreal
Herb191 Posted November 11, 2009 Posted November 11, 2009 Are you looking for something like this? If BitAND(GUICtrlRead($checkbox1), $GUI_CHECKED) Then _Function1() If BitAND(GUICtrlRead($checkbox2), $GUI_CHECKED) Then _Function2() If BitAND(GUICtrlRead($checkbox3), $GUI_CHECKED) Then _Function3()
EndFunc Posted November 11, 2009 Posted November 11, 2009 below is my code, i have at this time two process local backup $temp and network backup $temp2 are the locations, all in at this time c:temp. i was going to try and add a restore from backup local backup $temp3, not created yet do to i found a problem with my code. im going to try and explain this as best as posable, if you have any question please ask. checkboxes if $GUI_CHECKED then do local or network or restore depending on whats checked. the code that i have provided will do local or network no matter if checkbox is checked or not. expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <Array.au3> #include <HKCUReg.au3> #include <WinCopy.au3> ;===Checks Local OSVersion Create Var User Friendly================================================ $OS = @OSVersion $OS = StringReplace($OS, "WIN_VISTA", "Windows Vista") $OS = StringReplace($OS, "WIN_XP", "Windows XP") $OS = StringReplace($OS, "WIN_2000", "Windows 2000") ;===Determines Documents Location According To OS++================================================ $OSDOC = @OSVersion If $OSDOC = "WIN_VISTA" Then $DOC = "\Users\" If $OSDOC = "WIN_XP" Then $DOC = "\Documents and Settings\" EndIf $OSDF = @OSVersion If $OSDF = "WIN_VISTA" Then $DF = "Documents" If $OSDF = "WIN_XP" Then $DF = "My Documents" EndIf Local $Temp = "\Migrate_Local\" Local $Temp2 = "\Migrate_Network\" Local $LogFile = "c:\Temp\LogFile.txt" Local $Separator = "------------------------------" ;===GUI Start and File Menu======================================================================== $ParentWin = GUICreate("", 330, 165, -1, -1) $FileMenu = GUICtrlCreateMenu("&File") $BKItem = GUICtrlCreateMenuItem("Backup Only", $FileMenu) $RSItem = GUICtrlCreateMenuItem("Restore Only", $FileMenu) GUICtrlSetState($BKItem, $GUI_UNCHECKED) GUICtrlSetState($RSItem, $GUI_UNCHECKED) $ExitItem = GUICtrlCreateMenuItem("Exit", $FileMenu) $ViewMenu = GUICtrlCreateMenu("&View") $LogItem = GUICtrlCreateMenuItem("Log File", $ViewMenu) $ProMenu = GUICtrlCreateMenu("&Programs") $RDItem = GUICtrlCreateMenuItem("Remote Desktop", $ProMenu) $CMItem = GUICtrlCreateMenuItem("Computer Management", $ProMenu) $CPItem = GUICtrlCreateMenuItem("Command Prompt", $ProMenu) $HelpMenu = GUICtrlCreateMenu("&Help") $HelpItem = GUICtrlCreateMenuItem("Help", $HelpMenu) ;===GUI Network Computer To Tranfer From=========================================================== GUICtrlCreateGroup("System", 10, 10, 190, 75) GUICtrlCreateLabel("Computer Name:", 20, 25) $cnTarget = GUICtrlCreateInput(@ComputerName, 20, 40, 120, 20) $cnMessage = GUICtrlCreateLabel("Enter computer name or ip address", 20, 64, 175, 15) $cnButton = GUICtrlCreateButton("Connect", 145, 35, 50, 25, $WS_GROUP) ;===GUI Network User Profile======================================================================= GUICtrlCreateGroup("Profile:", 10, 90, 190, 45) $prCombo = GUICtrlCreateCombo("", 20, 105, 175, 20) ;===GUI Group What To Migrate====================================================================== GUICtrlCreateGroup("Tranfer", 210, 10, 110, 80) $BoxDocs = GUICtrlCreateCheckbox("My Documents", 220, 25) $BoxPrinter = GUICtrlCreateCheckbox("Network Printers", 220, 45) $BoxLotus = GUICtrlCreateCheckbox("Lotus Notes", 220, 65) GUICtrlSetState($BoxDocs, $GUI_CHECKED) GUICtrlSetState($BoxPrinter, $GUI_CHECKED) ;===GUI Start Function============================================================================= $StartButton = GUICtrlCreateButton("Start", 230, 100, 65, 30, $WS_GROUP) GUISetState(@SW_SHOW) ;===Start Of GUIGetMsg============================================================================= While 1 $msg = GUIGetMsg() Select ;===Case For Exit GUI============================================================================== Case $msg = $ExitItem Or $msg = $GUI_EVENT_CLOSE $FormClose = MsgBox(36, "", "Are you sure you want to exit?") If $FormClose = 6 Then GUIDelete() Exit EndIf ;===Case For File Menu Items======================================================================= Case $msg = $BKItem If BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($BKItem, $GUI_UNCHECKED) Else GUICtrlSetState($BKItem, $GUI_CHECKED) Local $BKtarget = FileSelectFolder("Choose the location you want to back up to:", "") If $BKtarget = '' Then GUICtrlSetState($BKItem, $GUI_UNCHECKED) EndIf Case $msg = $RSItem If BitAND(GUICtrlRead($RSItem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($RSItem, $GUI_UNCHECKED) Else GUICtrlSetState($RSItem, $GUI_CHECKED) Local $RStarget = FileSelectFolder("Choose the location you want to restore from:", "") If $RStarget = '' Then GUICtrlSetState($RSItem, $GUI_UNCHECKED) EndIf Case $msg = $HelpItem MsgBox(64, "", "Help File Coming Soon") Case $msg = $RDItem Run('mstsc.exe', @SystemDir) Case $msg = $CMItem ShellExecute('compmgmt.msc', @SystemDir, @SW_MAXIMIZE) Case $msg = $LogItem If FileExists($LogFile) Then ShellExecute($LogFile, "") Else MsgBox(48, "", "A Log File has not been created yet.") EndIf Case $msg = $CPItem Run('cmd.exe', @SystemDir) ;===Case For Lotus Notes CheckBox================================================================== Case $msg = $BoxLotus If GUICtrlRead($cnTarget) = '' Or GUICtrlRead($prCombo) = '' Then MsgBox(16, "", 'Target machine and a profile must be entered') GUICtrlSetState($BoxLotus, $GUI_UNCHECKED) EndIf If BitAND(GUICtrlRead($BoxLotus), $GUI_UNCHECKED) = $GUI_UNCHECKED Then GUICtrlSetState($BoxLotus, $GUI_UNCHECKED) Else Lotus() GUICtrlSetState($BoxLotus, $GUI_CHECKED) EndIf ;===Case For Connect=============================================================================== Case $msg = $cnButton If GUICtrlRead($cnTarget) = '' Then GUICtrlSetData($cnMessage, 'Target machine must be entered') GUICtrlSetColor($cnMessage, 0xFF0000) ContinueLoop EndIf $Log = FileOpen($LogFile, 10) FileWriteLine($LogFile, "Started: " & @MON & "/" & @MDAY & "/" & @YEAR & " at " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF & @CRLF & "System Info" & @CRLF & $Separator & @CRLF) FileWriteLine($LogFile, "Operating System: " & $OS & @CRLF & "Computer Name: " & @ComputerName & @CRLF) FileClose($LogFile) Connect() Case $msg = $StartButton If GUICtrlRead($cnTarget) = '' Or GUICtrlRead($prCombo) = '' Then MsgBox(16, "", 'Target machine and a profile must be entered') Else StartButton() EndIf EndSelect WEnd ;===Function For Remote System InfoBox============================================================= Func Connect() SplashTextOn("", "Querying Network", 165, 40, -1, -1, 2, "", 9) Sleep(1000) If Ping(GUICtrlRead($cnTarget)) Then $strComputer = GUICtrlRead($cnTarget) $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") SplashOff() If Not IsObj($objWMIService) Then GUICtrlSetData($cnMessage, 'Failed to connect to system') GUICtrlSetColor($cnMessage, 0xFF0000) Return EndIf ;===WMI BIOS $colItems1 = $objWMIService.ExecQuery("SELECT * FROM Win32_Bios") $message = "System Info for " & $strComputer & @CRLF & $Separator & @CRLF & @CRLF For $objItem In $colItems1 $message &= "Dell Asset Number: " & $objItem.SerialNumber & @CRLF & _ "Manufacturer: " & $objItem.Manufacturer & @CRLF & @CRLF Global $surreal = $objItem.SerialNumber Global $RemoteName = $strComputer Next ;===WMI NETWORK $colItems2 = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") For $objItem In $colItems2 $message &= "IP Address: " & $objItem.IPAddress(0) & @CRLF & _ "IP Subnet: " & $objItem.IPSubnet(0) & @CRLF & @CRLF Next ;===WMI SYSTEM $colItems3 = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") For $objItem In $colItems3 $message &= "Model: " & $objItem.Model & @CRLF & _ "Computer Name: " & $objItem.Name & @CRLF & _ "Last User: " & $objItem.UserName & @CRLF Global $RemoteUser = $objItem.UserName Next GUICtrlSetData($cnMessage, 'Connected, select user profile') GUICtrlSetColor($cnMessage, 0x008000) MsgBox(64, "System Information", $message) Else SplashOff() GUICtrlSetData($cnMessage, 'Target system could not be contacted') GUICtrlSetColor($cnMessage, 0xFF0000) Return EndIf Profile() EndFunc ;==>Connect ;===Function For Remote Profile Load=============================================================== Func Profile() Local $combo_string = "" $FolderList = _FileListToArray("\\" & GUICtrlRead($cnTarget) & "\c$" & $DOC, "*", 2) For $i = 1 To $FolderList[0] Switch $FolderList[$i] Case "All Users", "Default User", "LocalService", "NetworkService" ContinueLoop Case Else If $i = $FolderList[0] Then $combo_string &= $FolderList[$i] Else $combo_string &= $FolderList[$i] & "|" EndIf EndSwitch Next GUICtrlSetData($prCombo, $combo_string) EndFunc ;==>Profile ;===Function For Checkbox Actions================================================================== Func StartButton() Local $Path = "\\" & GUICtrlRead($cnTarget) Local $rmdocs = $Path & "\c$" & $DOC & GUICtrlRead($prCombo) & "\" & $DF ;===My Documents If GUICtrlRead($BoxDocs) = $GUI_CHECKED Then GUICtrlSetData($cnMessage, 'Transferring: My Documents') GUICtrlSetColor($cnMessage, 0x008000) If BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then ;----------Local DirCreate($BKtarget & $Temp & $DF & "\" & GUICtrlRead($prCombo)) _CopyWithProgress($rmdocs & "\*.*", $BKtarget & $Temp & $DF & "\" & GUICtrlRead($prCombo)) FileWriteLine($LogFile, "My Documents" & @TAB & "(Backup Successful)" & @CRLF) Else ;----------Network DirCreate($Temp2 & $DF & "\" & GUICtrlRead($prCombo)) _CopyWithProgress($rmdocs & "\*.*", $BKtarget & $Temp2 & $DF & "\" & GUICtrlRead($prCombo)) FileWriteLine($LogFile, "My Documents" & @TAB & "(Successful)" & @CRLF) EndIf ;===Printers If GUICtrlRead($BoxPrinter) = $GUI_CHECKED Then GUICtrlSetData($cnMessage, 'Transferring: Printers') GUICtrlSetColor($cnMessage, 0x008000) If BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then DirCreate($BKtarget & $Temp & "Printers") Printers() FileWriteLine($LogFile, @CRLF & $Separator & "Lotus Notes:" & @TAB & "(:Local Successful)" & @CRLF) Else DirCreate($Temp2 & "Printers") Printers() FileWriteLine($LogFile, @CRLF & $Separator & "Lotus Notes:" & @TAB & "(Network Successful)" & @CRLF) EndIf ;===Lotus Notes If GUICtrlRead($BoxLotus) = $GUI_CHECKED Then GUICtrlSetData($cnMessage, 'Transferring: Lotus Notes') GUICtrlSetColor($cnMessage, 0x008000) If BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then DirCreate($BKtarget & $Temp & "Notes") _CopyWithProgress($Lotus_Location & "\*.id", $BKtarget & $Temp & "Notes") _CopyWithProgress($Lotus_Location & "\Desktop6.ndk", $BKtarget & $Temp & "Notes") _CopyWithProgress($Lotus_Location & "\Names.nsf", $BKtarget & $Temp & "Notes") _CopyWithProgress($Lotus_Location & "\User.dic", $BKtarget & $Temp & "Notes") DirCreate($BKtarget & $Temp & "Notes\Archive") _CopyWithProgress($Lotus_Location & "\Archive", $BKtarget & $Temp & "Notes\Archive") FileWriteLine($LogFile, @CRLF & $Separator & "Lotus Notes:" & @TAB & "(Local Successful)" & @CRLF) Else DirCreate($Temp2 & "Notes") _CopyWithProgress($Lotus_Location & "\*.id", $Temp2 & "Notes") _CopyWithProgress($Lotus_Location & "\Desktop6.ndk", $Temp2 & "Notes") _CopyWithProgress($Lotus_Location & "\Names.nsf", $Temp2 & "Notes") _CopyWithProgress($Lotus_Location & "\User.dic", $Temp2 & "Notes") DirCreate($Temp2 & "Notes\Archive") _CopyWithProgress($Lotus_Location & "\Archive", $Temp2 & "Notes\Archive") FileWriteLine($LogFile, @CRLF & $Separator & "Lotus Notes:" & @TAB & "(Network Successful)" & @CRLF) EndIf SoundPlay(@WindowsDir & "\media\tada.wav", 1) $Success = MsgBox(4, "", "Migration Was Successful. Do You Want To Exit?") If $Success = 6 Then Exit EndFunc ;==>StartButton ;===Function For Save Printer Info File============================================================ Func Printers() Local $passet = GUICtrlRead($cnTarget) If BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then Local $pLocation = $BKtarget & $Temp & "Printers\Printers.txt" Else Local $pLocation = $Temp2 & "Printers\Printers.txt" EndIf $pFile = FileOpen($pLocation, 10) For $i = 1 To 25 $p = _HKCU_EnumVal("\\\" & $passet & "\Software\Microsoft\Windows NT\CurrentVersion\Devices", $i) $iProdp = 1 For $n = 1 To $p[0][0] $iProdp *= $p[$n][2] If $p[$n][2] = 0 Then $ppath = _HKCU_Read("\\\" & $passet & "\\" & $p[$n][1], "Devices") EndIf If StringRegExp($p[$n][1], "^\\\\(?!\\)") Then FileWriteLine($pFile, $p[$n][1] & "," & $ppath[1][1]) EndIf Next If $iProdp <> 0 Then ExitLoop Next EndFunc ;==>Printers ;===Function For Lotus Notes Child Window========================================================== Func Lotus() $ChildWin = GUICreate("", 135, 110, -1, -1, $WS_EX_TOPMOST) GUISwitch($ChildWin) $Box_Single = GUICtrlCreateRadio("Single User Install", 10, 10) $Box_Multi = GUICtrlCreateRadio("Multi User Install", 10, 30) $Box_System = GUICtrlCreateRadio("Root System Install", 10, 50) GUISetState() While 1 $lnmsg = GUIGetMsg() Select Case $lnmsg = $Box_Single And BitAND(GUICtrlRead($Box_Single), $GUI_CHECKED) = $GUI_CHECKED Global $Lotus_Location = "\\" & GUICtrlRead($cnTarget) & "\c$\Program Files\Lotus\Notes\Data" GUIDelete($ChildWin) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) Case $lnmsg = $Box_Multi And BitAND(GUICtrlRead($Box_Multi), $GUI_CHECKED) = $GUI_CHECKED Global $Lotus_Location = "\\" & GUICtrlRead($cnTarget) & "\c$" & $DOC & GUICtrlRead($prCombo) & "\Local Settings\Application Data\Lotus\Notes\Data" GUIDelete($ChildWin) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) Case $lnmsg = $Box_System And BitAND(GUICtrlRead($Box_System), $GUI_CHECKED) = $GUI_CHECKED Global $Lotus_Location = "\\" & GUICtrlRead($cnTarget) & "\c$\Lotus\Notes\Data" GUIDelete($ChildWin) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) EndSelect WEnd EndFunc ;==>Lotus maybe i call a function checkboxes() that is something like: if checkbox1 checked then another function endif if checkbox2 checked then another function endif if checkbox3 checked then another function endif another function() if local checked then copy to local location else if network checked then copy to network location else if restore checked then copy to restore location endif endif endif not even sure if the above is right, do to i have each checkbox doing something different within it, pretty much looking for correct syntax, thank you everyone for your help. d@ve You mentioned that was your code but you don't have the correct syntax to an if/endif statement? Just asking. Are you trying to modify someone else's code? Not a problem if you are, but just seemed a bit in depth for you to be asking about a basic function. Anyway, check the help file for correct syntax. It's pretty good and even gives good examples. You can't have more than one else in an if statement or you will get an error unless it is within another nested If statement. You need to use ElseIf to check checking more conditions, Else is the final action if none match. EndFuncAutoIt is the shiznit. I love it.
surreal Posted November 11, 2009 Author Posted November 11, 2009 (edited) thank you everyone. sorry EndFunc for the simple question, yes this is my code been working on it for about 3 months now. this is actually a small version of the main project. i use this to not overwhelm helpers with so much code and hope to get to a final stage to be worthy of posting in examples. i was reading about the elseif but for some reason thought it would create the same result. and i was getting an error when using it ""elseif" is closing previous "func"" was playing with it as you guys replied. i have learned so much from writing this code, my third and largest project yet. but as i learn it has been nice to be able to help others within this forum as well. thanks again, and i will post the working code for others if i can get this working. d@ve Edited November 11, 2009 by surreal
surreal Posted November 11, 2009 Author Posted November 11, 2009 (edited) If GUICtrlRead($BoxDocs) = $GUI_CHECKED Then GUICtrlSetData($cnMessage, 'Transferring: My Documents') GUICtrlSetColor($cnMessage, 0x008000) ;----------Network DirCreate($Network & $DF & "\" & GUICtrlRead($prCombo)) _CopyWithProgress($rmdocs & "\*.*", $network & $DF & "\" & GUICtrlRead($prCombo)) FileWriteLine($LogFile, "My Documents" & @TAB & "(Network Successful)" & @CRLF) ElseIf BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then ;----------Backup DirCreate($BKtarget & $backup & $DF & "\" & GUICtrlRead($prCombo)) _CopyWithProgress($rmdocs & "\*.*", $BKtarget & $backup & $DF & "\" & GUICtrlRead($prCombo)) FileWriteLine($LogFile, "My Documents" & @TAB & "(Backup Successful)" & @CRLF) ElseIf BitAND(GUICtrlRead($RSItem), $GUI_CHECKED) = $GUI_CHECKED Then ;----------Restore DirCreate($RStarget & $restore & $DF & "\" & GUICtrlRead($prCombo)) _CopyWithProgress($rmdocs & "\*.*", $RStarget & $restore & $DF & "\" & GUICtrlRead($prCombo)) FileWriteLine($LogFile, "My Documents" & @TAB & "(Restore Successful)" & @CRLF) EndIf update: that didnt work, but the below code did! ;===My Documents If GUICtrlRead($BoxDocs) = $GUI_CHECKED And BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetData($cnMessage, 'Backup: My Documents') GUICtrlSetColor($cnMessage, 0x008000) ;----------Backup DirCreate($BKtarget & $backup & $DF & "\" & GUICtrlRead($prCombo)) _CopyWithProgress($rmdocs & "\*.*", $BKtarget & $backup & $DF & "\" & GUICtrlRead($prCombo)) FileWriteLine($LogFile, "My Documents" & @TAB & "(Backup Successful)" & @CRLF) ElseIf GUICtrlRead($BoxDocs) = $GUI_CHECKED And BitAND(GUICtrlRead($RSItem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetData($cnMessage, 'Restore: My Documents') GUICtrlSetColor($cnMessage, 0x008000) ;----------Restore DirCreate($RStarget & $restore & $DF & "\" & GUICtrlRead($prCombo)) _CopyWithProgress($rmdocs & "\*.*", $RStarget & $restore & $DF & "\" & GUICtrlRead($prCombo)) FileWriteLine($LogFile, "My Documents" & @TAB & "(Restore Successful)" & @CRLF) ElseIf GUICtrlRead($BoxDocs) = $GUI_CHECKED Then GUICtrlSetData($cnMessage, 'Transferring: My Documents') GUICtrlSetColor($cnMessage, 0x008000) ;----------Network DirCreate($network & $DF & "\" & GUICtrlRead($prCombo)) _CopyWithProgress($rmdocs & "\*.*", $network & $DF & "\" & GUICtrlRead($prCombo)) FileWriteLine($LogFile, "My Documents" & @TAB & "(Network Successful)" & @CRLF) EndIf Edited November 11, 2009 by surreal
whim Posted November 11, 2009 Posted November 11, 2009 I usually define myself a little function to make my code easier to read: Func IsChecked($control) If BitAND(GUICtrlRead($control), 1) = 1 Then ; $GUI_CHECKED = 1 Return 1 Else Return 0 EndIf EndFunc ;==>IsChecked cheers, whim
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