
surreal
Active Members-
Posts
91 -
Joined
-
Last visited
Everything posted by surreal
-
Multiple People running script [FileWrite]
surreal replied to surreal's topic in AutoIt General Help and Support
i can see that as an option. just not sure yet where to start for then getting each csv file into a masterfile. i will do some searches. d@ve -
Multiple People running script [FileWrite]
surreal posted a topic in AutoIt General Help and Support
hello all, and thanks to all for your help in advance. im going to be emailing this script to around 1200 users. it will copy a file to a created location. then save some info to a csv file on a network share. the below script works, im looking for best practice to code this script to not fail or hang when multiple users will write to the file at the same time. #NoTrayIcon Local $sDataFilePath = '\\servername\foldername\MasterFile.csv' Local $sUserFolderPath = '\\servername\foldername\' & @UserName Local $Input1 = $sUserFolderPath & '\Names.nsf' Local $sTitle = 'Comany Name' #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIPassword.au3> $Surreal = GUICreate($sTitle, 545, 230, -1, -1) GUISetBkColor(0xFFFFFF) $WhiteWavePic = GUICtrlCreatePic(@ScriptDir & '\image.jpg', 8, 55, 200, 121) GUICtrlCreateLabel("Network Password:", 225, 130, 120, 17) $InputPassword = _GUICtrlCreatePassword("", 225, 145, 300, 20) $Checkbox = GUICtrlCreateCheckbox("Show password", 225, 170, 100, 17) $Button = GUICtrlCreateButton("Submit", 370, 190, 120, 30) GUICtrlCreateLabel("User Name:", 225, 40, 115, 17) $InputUsername = GUICtrlCreateInput(@UserName, 225, 55, 300, 20) GUICtrlCreateLabel("Email Address:", 225, 85, 115, 17) $InputEmailAddress = GUICtrlCreateInput(@UserName & '@compantname.com', 225, 100, 300, 20) GUICtrlCreateLabel("Transfer your Lotus Notes Contacts into Office 365", 95, 10, 345, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE $FormClose = MsgBox(36, $sTitle, "Are you sure you want to exit?") If $FormClose = 6 Then Exit EndIf Case $Button If GUICtrlRead($InputEmailAddress) = '' Or GUICtrlRead($InputPassword) = '' Then MsgBox(16, $sTitle, 'All fields must be entered.') Else _Export() GUIDelete($Surreal) MsgBox(64, $sTitle, "Done.") Exit EndIf Case $Checkbox _GUICtrlPasswordCheckbox($InputPassword, $Checkbox) EndSwitch WEnd Func _Export() DirCreate('\\servername\foldername\' & @UserName) FileCopy('C:\Program Files\Lotus\Notes\Data\names.nsf', '\\servername\foldername\' & @UserName & '\names.nsf', 1) FileWrite($sDataFilePath, $Input1 & "," & GUICtrlRead($InputEmailAddress) & "," & GUICtrlRead($InputPassword) & ",") FileWriteLine($sDataFilePath, "") EndFunc ;==>_Export d@ve -
filedelete error checking and splash
surreal replied to surreal's topic in AutoIt General Help and Support
thank you Scriptonized@ve -
im trying to do the following delete all files in a folder, but if the user does not have permission to delete the files return an error message. (the files are different all the time) if the user can delete then display a splash screen during and then a success msg. below is the code i have but im having problems with where to include the splashtexton and success msg. it is deleting the files if they have access and it is displaying the error code if they do not have access. I may be just making this harder than it is. If @OSVersion = "WIN_7" Then _windows7() Exit Else _windowsXP() Exit EndIf Func _windows7() $sDir = "C:ProgramDataFolder" $sFiles = "*.*" $aFiles = StringSplit($sFiles, ",") For $j = 1 To $aFiles[0] $i = 50 While $i > 0 If StringLeft($aFiles[$j], 1) = "" Then If DirRemove($sDir & $aFiles[$j]) Then ExitLoop If FileExists($sDir & $aFiles[$j] & "*.*") Then If Not FileDelete($sDir & $aFiles[$j] & "*.*") Then MsgBox(262160, "Program", "You do not have the correct permissions. (Please contact the Server Desk)") ExitLoop EndIf EndIf Else If FileDelete($sDir & '' & $aFiles[$j]) Then ExitLoop EndIf Sleep(100) $i -= 1 If $i = 0 Then MsgBox(262160, "Program", "You do not have the correct permissions. (Please contact the Server Desk)") ExitLoop EndIf WEnd Next EndFunc ;==>_windows7 Func _windowsXP() $sDir = "C:Documents and SettingsAll UsersApplication DataFolder" $sFiles = "*.*" $aFiles = StringSplit($sFiles, ",") For $j = 1 To $aFiles[0] $i = 50 While $i > 0 If StringLeft($aFiles[$j], 1) = "" Then If DirRemove($sDir & $aFiles[$j]) Then ExitLoop If FileExists($sDir & $aFiles[$j] & "*.*") Then If Not FileDelete($sDir & $aFiles[$j] & "*.*") Then MsgBox(262160, "Program", "You do not have the correct permissions. (Please contact the Server Desk)") ExitLoop EndIf EndIf Else If FileDelete($sDir & '' & $aFiles[$j]) Then ExitLoop EndIf $i -= 1 If $i = 0 Then MsgBox(262160, "Program", "You do not have the correct permissions. (Please contact the Server Desk)") ExitLoop EndIf WEnd Next EndFunc ;==>_windowsXP i want to included: SplashTextOn("Program", "Clearing Cache. Please Wait...", 325, 45, -1, -1, 2, "", 10) Sleep(2000) SplashOff() MsgBox(0, "Program", "Cache has been cleared.") thank you everyone for your help. d@ve
-
i like the idea! i have also noticed from your website that you now have a working xp version. do you use diskpart to format the usb. im sure in the past xp's version on diskpart was giving you problems on making the usb bootable. how did you get over this? would you be willing to share the new code on the newer version? i am trying to do the same thing but just format the usb and then copy winpe files and wim images to it. would like it to work on xp do to the fact the techs that will be creating these are on xp systems. great work so far, with a great gui. d@ve
-
GUICtrlCreateListView & DriveMapAdd Help
surreal replied to surreal's topic in AutoIt General Help and Support
im getting alot closer, i had to remove the checkboxes. the below code works but only lets me do one at a time. any help with how to do this with the checkboxs and be able to map multi mappings would be great, im so close. ;===Function For Mapped Drives===================================================================== Func Drives() $List_Drives = GUICreate("Mapped Drives (" & $masset & ")", 320, 250, -1, -1, -1) GUISetBkColor(0xD4D0C8) $View = GUICtrlCreateListView("Drive | Path", 0, 0, 320, 200, -1) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 250) GUISetState() $MDButton = GUICtrlCreateButton("Map Drive(s)", 120, 210, 75, 30, $WS_GROUP) EndIf For $i = 1 To 25 $b = _HKCU_EnumKey("\\\" & $masset & "\Network", $i) $iProdm = 1 For $j = 1 To $b[0][0] $iProdm *= $b[$j][2] If $b[$j][2] = 0 Then $Path = _HKCU_Read("\\\" & $masset & "\\" & $b[$j][0] & "\Network\" & $b[$j][1], "RemotePath") GUICtrlCreateListViewItem("" & $b[$j][1] & "|" & $Path[1][1] & "", $View) EndIf Next If $iProdm <> 0 Then ExitLoop Next GUISetState(@SW_SHOW) While 1 $mdmsg = GUIGetMsg() Select Case $mdmsg = $MDButton $Column1 = _GUICtrlListView_GetItemTextArray($View, -1) ConsoleWrite("Column 1 Text = " & $Column1[1] & ":" & @CRLF) $Column2 = _GUICtrlListView_GetItemTextArray($View, -1) ConsoleWrite("Column 2 Text = " & $Column2[2] & @CRLF) SplashTextOn($sTitle, "Mapping Drive", 165, 40, -1, -1, 2, "", 9) DriveMapAdd($Column1[1] & ":", $Column2[2]) Sleep(1000) SplashOff() Case $mdmsg = $GUI_EVENT_CLOSE GUIDelete($List_Drives) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) EndSelect WEnd EndFunc ;==>Drives thanks d@ve -
While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete($ChildWin) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) EndSelect
-
i have a function that list all the local systems mapped drives or the mapped drives on a remote system. the drive letter and share will display in a GUICtrlCreateListView with checkboxes. i would like to be able to select a checkbox or checkboxes and then click the button to map the drives locally. below is the function and it seems that my first problem will be that when i use MsgBox as a test it displays with the pipe |. so it is making it hard to import the selected data into a drivemapadd. thanks for your help all... Func Drives() $List_Drives = GUICreate("Mapped Drives (" & $masset & ")", 320, 250, 350, 250, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE)) GUISetBkColor(0xD4D0C8) $View = GUICtrlCreateListView("Drive | Path", 0, 0, 320, 200, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 250) GUISetState() $MDButton = GUICtrlCreateButton("Map Drive(s)", 120, 210, 75, 30, $WS_GROUP) EndIf For $i = 1 To 25 $b = _HKCU_EnumKey("\\\" & $masset & "\Network", $i) $iProdm = 1 For $j = 1 To $b[0][0] $iProdm *= $b[$j][2] If $b[$j][2] = 0 Then $Path = _HKCU_Read("\\\" & $masset & "\\" & $b[$j][0] & "\Network\" & $b[$j][1], "RemotePath") GUICtrlCreateListViewItem(" " & $b[$j][1] & " | " & $Path[1][1] & "", $View) EndIf Next If $iProdm <> 0 Then ExitLoop Next GUISetState(@SW_SHOW) While 1 $mdmsg = GUIGetMsg() Select Case $mdmsg = $MDButton Local $item_count = _GUICtrlListView_GetItemCount($View) Local $is_checked, $items_checked, $file_array[1] For $i = 0 To $item_count - 1 $is_checked = _GUICtrlListView_GetItemChecked($View, $i) If Not @error Then $items_checked += $is_checked If ($is_checked) Then If ($items_checked = 1) Then _ArrayInsert($file_array, 0, _GUICtrlListView_GetItemTextString($View, $i)) _ArrayDelete($file_array, 1) Else _ArrayAdd($file_array, _GUICtrlListView_GetItemTextString($View, $i)) EndIf EndIf EndIf Next If ($items_checked <> 0) Then If Not @error Then For $i = 0 To $items_checked - 1 MsgBox(0, "Mapped Drive", $file_array[$i]) Next EndIf Else MsgBox(0, "Mapped Drive", "ERROR") EndIf Case $mdmsg = $GUI_EVENT_CLOSE GUIDelete($List_Drives) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) EndSelect WEnd EndFunc if you need the full code i have zipped it with all the #includes download
-
i now have the array working with the GUICtrlCreateListView with checkboxes. was wondering if anyone could point me in the right direction on how to now get the map drives button to work. i would like it to take the listitem that is checked or the items and install the mapped drives on the local system, using something like DriveMapAdd. just not sure how to code this with the gathered info. thanks... added: when trying to use DriveMapAdd("X:", "\\myserver\stuff") my problem comes in with the array grabbing the pipe "|". also im not sure if DriveMapAdd can handel more then one from the array? below is the working code updated fuction ;===Function For Mapped Drives===================================================================== Func Drives() Local $masset = GUICtrlRead($cnTarget) If GUICtrlRead($cnTarget) = '' Then MsgBox(16, "", 'Target machine must be entered') Return Else $List_Drives = GUICreate("Mapped Drives (" & $masset & ")", 320, 250, 350, 250, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE)) GUISetBkColor(0xD4D0C8) $View = GUICtrlCreateListView("Drive | Path", 0, 0, 320, 200, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 250) GUISetState() $MDButton = GUICtrlCreateButton("Map Drive(s)", 120, 210, 75, 30, $WS_GROUP) EndIf For $i = 1 To 25 $b = _HKCU_EnumKey("\\\" & $masset & "\Network", $i) $iProdm = 1 For $j = 1 To $b[0][0] $iProdm *= $b[$j][2] If $b[$j][2] = 0 Then $Path = _HKCU_Read("\\\" & $masset & "\\" & $b[$j][0] & "\Network\" & $b[$j][1], "RemotePath") GUICtrlCreateListViewItem(" " & $b[$j][1] & " | " & $Path[1][1] & "", $View) EndIf Next If $iProdm <> 0 Then ExitLoop Next GUISetState(@SW_SHOW) While 1 $mdmsg = GUIGetMsg() Select Case $mdmsg = $MDButton Local $item_count = _GUICtrlListView_GetItemCount($View) Local $is_checked, $items_checked, $file_array[1] For $i = 0 To $item_count - 1 $is_checked = _GUICtrlListView_GetItemChecked($View, $i) If Not @error Then $items_checked += $is_checked If ($is_checked) Then If ($items_checked = 1) Then _ArrayInsert($file_array, 0, _GUICtrlListView_GetItemTextString($View, $i)) _ArrayDelete($file_array, 1) Else _ArrayAdd($file_array, _GUICtrlListView_GetItemTextString($View, $i)) EndIf EndIf EndIf Next If ($items_checked <> 0) Then If Not @error Then For $i = 0 To $items_checked - 1 MsgBox(0, "Mapped Drive", $file_array[$i]) Next EndIf Else MsgBox(0, "Mapped Drive", "ERROR") EndIf Case $mdmsg = $GUI_EVENT_CLOSE GUIDelete($List_Drives) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) EndSelect WEnd EndFunc ;==>Drives full code #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <HKCUReg.au3> #include <Array.au3> #include <Surreal.au3> #include <GuiStatusBar.au3> #include <GuiListView.au3> #include <ListViewConstants.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 Global $Lotus_Location Local $sTitle = 'eMigrate' Local $backup = "\Migrate_Backup\" Local $network = "c:\Temp\Migrate_Network\" Local $restore = "\Migrate_Restore\" Local $LogFile = "c:\Temp\LogFile.txt" Local $Separator = "------------------------------" Local $LogFileLocation = @ProgramFilesDir & "\" & $sTitle & "\eMigrate.txt" ;===GUI Start and File Menu======================================================================== $ParentWin = GUICreate("", 330, 185, -1, -1) $FileMenu = GUICtrlCreateMenu("&File") $BKItem = GUICtrlCreateMenuItem("Backup Only", $FileMenu) $RSItem = GUICtrlCreateMenuItem("Restore Only", $FileMenu) $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) $PRItem = GUICtrlCreateMenuItem("Migrate Printers", $ProMenu) $MDItem = GUICtrlCreateMenuItem("Migrate Mapped Drives", $ProMenu) $CPItem = GUICtrlCreateMenuItem("Command Prompt", $ProMenu) $HelpMenu = GUICtrlCreateMenu("&Help") $HelpItem = GUICtrlCreateMenuItem($sTitle & " Help", $HelpMenu) GUICtrlSetState($BKItem, $GUI_UNCHECKED) GUICtrlSetState($RSItem, $GUI_UNCHECKED) ;===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) $Box_Documents = GUICtrlCreateCheckbox("My Documents", 220, 25) $Box_IEFav = GUICtrlCreateCheckbox("IE Favorites", 220, 45) $Box_Notes = GUICtrlCreateCheckbox("Lotus Notes", 220, 65) GUICtrlSetState($Box_Documents, $GUI_CHECKED) GUICtrlSetState($Box_IEFav, $GUI_CHECKED) GUICtrlSetState($Box_Notes, $GUI_UNCHECKED) ;===GUI Start Function============================================================================= $StartButton = GUICtrlCreateButton("Start", 230, 100, 65, 30, $WS_GROUP) $StatusBar = _GUICtrlStatusBar_Create($ParentWin) _GUICtrlStatusBar_SetMinHeight($StatusBar, 5) 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) _GUICtrlStatusBar_SetText($StatusBar, "") Else GUICtrlSetState($BKItem, $GUI_CHECKED) Local $BKtarget = FileSelectFolder("Choose the location you want to back up to:" & @CRLF & "A backup folder (eMigrate) will be created", "", 1) _GUICtrlStatusBar_SetText($StatusBar, " Backup Mode Enabled") GUICtrlSetData($cnTarget, @ComputerName) GUICtrlSetState($RSItem, $GUI_UNCHECKED) Connect() EndIf If $BKtarget = '' Then GUICtrlSetState($BKItem, $GUI_UNCHECKED) _GUICtrlStatusBar_SetText($StatusBar, "") EndIf Case $msg = $RSItem If BitAND(GUICtrlRead($RSItem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($RSItem, $GUI_UNCHECKED) _GUICtrlStatusBar_SetText($StatusBar, "") Else GUICtrlSetState($RSItem, $GUI_CHECKED) Local $RStarget = FileSelectFolder("Choose the location you want to restore from:" & @CRLF & "Select the (eMigrate) folder you created", "") _GUICtrlStatusBar_SetText($StatusBar, " Restore Mode Enabled") GUICtrlSetData($cnTarget, @ComputerName) GUICtrlSetState($BKItem, $GUI_UNCHECKED) Connect() EndIf If $RStarget = '' Then GUICtrlSetState($RSItem, $GUI_UNCHECKED) _GUICtrlStatusBar_SetText($StatusBar, "") EndIf Case $msg = $HelpItem MsgBox(64, $sTitle, "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($LogFileLocation) Then ShellExecute($LogFileLocation, "") Else MsgBox(48, $sTitle, "A Log File has not been created yet.") EndIf Case $msg = $CPItem Run('cmd.exe', @SystemDir) ;===Case For Mapped Drives and Printers not working yet============================================ Case $msg = $MDItem If GUICtrlRead($cnTarget) = '' Then MsgBox(16, "", 'Target machine must be entered') Else Drives() EndIf Case $msg = $PRItem If GUICtrlRead($cnTarget) = '' Then MsgBox(16, "", 'Target machine must be entered') Else Printers() FileClose("c:\Temp\Printers\Printers.txt") MsgBox(64, $sTitle, "File has been created (c:\Temp\Printers)") EndIf ;===Case For Lotus Notes CheckBox================================================================== Case $msg = $Box_Notes If GUICtrlRead($cnTarget) = '' Or GUICtrlRead($prCombo) = '' Then MsgBox(16, "", 'Target machine and a profile must be entered') GUICtrlSetState($Box_Notes, $GUI_UNCHECKED) EndIf If BitAND(GUICtrlRead($Box_Notes), $GUI_UNCHECKED) = $GUI_UNCHECKED Then GUICtrlSetState($Box_Notes, $GUI_UNCHECKED) Else Lotus() GUICtrlSetState($Box_Notes, $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 Local $rmfavs = $Path & "\c$" & $DOC & GUICtrlRead($prCombo) & "\Favorites" Local $LotusProgram = @ProgramFilesDir & "\Lotus\Notes\Data" ;====================My Documents If GUICtrlRead($Box_Documents) = $GUI_CHECKED And BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then ;-----Backup _GUICtrlStatusBar_SetText($StatusBar, " Backing Up My Documents") DirCreate($BKtarget & $backup & $DF & "\" & GUICtrlRead($prCombo)) _CopyWithProgress($rmdocs & "\*.*", $BKtarget & $backup & $DF & "\" & GUICtrlRead($prCombo)) FileWriteLine($LogFile, "My Documents" & @TAB & "(Backup Successful)" & @CRLF) ElseIf GUICtrlRead($Box_Documents) = $GUI_CHECKED And BitAND(GUICtrlRead($RSItem), $GUI_CHECKED) = $GUI_CHECKED Then ;-----Restore _GUICtrlStatusBar_SetText($StatusBar, " Restoring My Documents") _CopyWithProgress($RStarget & $DF & "\" & GUICtrlRead($prCombo) & "\*.*", "c:" & $DOC & GUICtrlRead($prCombo) & "\" & $DF) FileWriteLine($LogFile, "My Documents" & @TAB & "(Restore Successful)" & @CRLF) ElseIf GUICtrlRead($Box_Documents) = $GUI_CHECKED Then ;-----Network _GUICtrlStatusBar_SetText($StatusBar, " Transferring My Documents") _CopyWithProgress($rmdocs & "\*.*", "c:" & $DOC & GUICtrlRead($prCombo) & "\" & $DF) FileWriteLine($LogFile, "My Documents" & @TAB & "(Network Successful)" & @CRLF) EndIf ;====================Favorites If GUICtrlRead($Box_IEFav) = $GUI_CHECKED And BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then ;-----Backup _GUICtrlStatusBar_SetText($StatusBar, " Backing Up Favorites") GUICtrlSetColor($cnMessage, 0x008000) DirCreate($BKtarget & $backup & "Favorites") _CopyWithProgress($rmfavs & "\*.*", $BKtarget & $backup & "Favorites") FileWriteLine($LogFile, "Favorites" & @TAB & "(Backup Successful)" & @CRLF) ElseIf GUICtrlRead($Box_IEFav) = $GUI_CHECKED And BitAND(GUICtrlRead($RSItem), $GUI_CHECKED) = $GUI_CHECKED Then ;-----Restore _GUICtrlStatusBar_SetText($StatusBar, " Restoring Favorites") _CopyWithProgress($RStarget & "Favorites" & "\*.*", "c:" & $DOC & GUICtrlRead($prCombo) & "\Favorites") FileWriteLine($LogFile, "Favorites" & @TAB & "(Restore Successful)" & @CRLF) ElseIf GUICtrlRead($Box_IEFav) = $GUI_CHECKED Then ;-----Network _GUICtrlStatusBar_SetText($StatusBar, " Transferring Favorites") _CopyWithProgress($rmfavs & "\*.*", "c:" & $DOC & GUICtrlRead($prCombo) & "\Favorites") FileWriteLine($LogFile, "Favorites" & @TAB & "(Network Successful)" & @CRLF) EndIf ;====================Lotus Notes If GUICtrlRead($Box_Notes) = $GUI_CHECKED And BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then ;-----Backup _GUICtrlStatusBar_SetText($StatusBar, " Backing Up Lotus Notes") DirCreate($BKtarget & $backup & "Notes") _CopyWithProgress($Lotus_Location & "\*.id", $BKtarget & $backup & "Notes") _CopyWithProgress($Lotus_Location & "\Desktop6.ndk", $BKtarget & $backup & "Notes") _CopyWithProgress($Lotus_Location & "\Names.nsf", $BKtarget & $backup & "Notes") _CopyWithProgress($Lotus_Location & "\User.dic", $BKtarget & $backup & "Notes") DirCreate($BKtarget & $backup & "Notes\Archive") _CopyWithProgress($Lotus_Location & "\Archive\*.*", $BKtarget & $backup & "Notes\Archive") FileWriteLine($LogFile, "Lotus Notes" & @TAB & "(Backup Successful)" & @CRLF) ElseIf GUICtrlRead($Box_Notes) = $GUI_CHECKED And BitAND(GUICtrlRead($RSItem), $GUI_CHECKED) = $GUI_CHECKED Then ;-----Restore _GUICtrlStatusBar_SetText($StatusBar, " Restoring Lotus Notes") _CopyWithProgress($RStarget & "Notes" & "\*.*", $LotusProgram) FileWriteLine($LogFile, "Lotus Notes" & @TAB & "(Restore Successful)" & @CRLF) ElseIf GUICtrlRead($Box_Notes) = $GUI_CHECKED Then ;-----Network _GUICtrlStatusBar_SetText($StatusBar, " Transferring Lotus Notes") _CopyWithProgress($Lotus_Location & "\*.id", $LotusProgram) _CopyWithProgress($Lotus_Location & "\Desktop6.ndk", $LotusProgram) _CopyWithProgress($Lotus_Location & "\Names.nsf", $LotusProgram) _CopyWithProgress($Lotus_Location & "\User.dic", $LotusProgram) DirCreate($LotusProgram & "\Archive") _CopyWithProgress($Lotus_Location & "\Archive\*.*", $LotusProgram & "\Archive") FileWriteLine($LogFile, "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() If GUICtrlRead($cnTarget) = '' Then MsgBox(16, "", 'Target machine must be entered') Else SplashTextOn($sTitle, "Transfering Printers", 165, 40, -1, -1, 2, "", 9) Local $passet = GUICtrlRead($cnTarget) DirCreate("c:\Temp\Printers") Local $pLocation = "c:\Temp\Printers\Printers.txt" Local $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 SplashOff() EndIf Return EndFunc ;==>Printers ;===Function For Mapped Drives===================================================================== Func Drives() Local $masset = GUICtrlRead($cnTarget) If GUICtrlRead($cnTarget) = '' Then MsgBox(16, "", 'Target machine must be entered') Return Else $List_Drives = GUICreate("Mapped Drives (" & $masset & ")", 320, 250, 350, 250, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE)) GUISetBkColor(0xD4D0C8) $View = GUICtrlCreateListView("Drive | Path", 0, 0, 320, 200, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 250) GUISetState() $MDButton = GUICtrlCreateButton("Map Drive(s)", 120, 210, 75, 30, $WS_GROUP) EndIf For $i = 1 To 25 $b = _HKCU_EnumKey("\\\" & $masset & "\Network", $i) $iProdm = 1 For $j = 1 To $b[0][0] $iProdm *= $b[$j][2] If $b[$j][2] = 0 Then $Path = _HKCU_Read("\\\" & $masset & "\\" & $b[$j][0] & "\Network\" & $b[$j][1], "RemotePath") GUICtrlCreateListViewItem(" " & $b[$j][1] & " | " & $Path[1][1] & "", $View) EndIf Next If $iProdm <> 0 Then ExitLoop Next GUISetState(@SW_SHOW) While 1 $mdmsg = GUIGetMsg() Select Case $mdmsg = $MDButton Local $item_count = _GUICtrlListView_GetItemCount($View) Local $is_checked, $items_checked, $file_array[1] For $i = 0 To $item_count - 1 $is_checked = _GUICtrlListView_GetItemChecked($View, $i) If Not @error Then $items_checked += $is_checked If ($is_checked) Then If ($items_checked = 1) Then _ArrayInsert($file_array, 0, _GUICtrlListView_GetItemTextString($View, $i)) _ArrayDelete($file_array, 1) Else _ArrayAdd($file_array, _GUICtrlListView_GetItemTextString($View, $i)) EndIf EndIf EndIf Next If ($items_checked <> 0) Then If Not @error Then For $i = 0 To $items_checked - 1 MsgBox(0, "Mapped Drive", $file_array[$i]) Next EndIf Else MsgBox(0, "Mapped Drive", "ERROR") EndIf Case $mdmsg = $GUI_EVENT_CLOSE GUIDelete($List_Drives) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) EndSelect WEnd EndFunc ;==>Drives ;===Function For Lotus Notes Child Window========================================================== Func Lotus() $ChildWin = GUICreate("", 135, 110, -1, -1, $WS_EX_TOPMOST) GUISetBkColor(0xFFFFFF) 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 $Lotus_Location = "\\" & GUICtrlRead($cnTarget) & "\c$\Program Files\Lotus\Notes\Data" Sleep(200) GUIDelete($ChildWin) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) Case $lnmsg = $Box_Multi And BitAND(GUICtrlRead($Box_Multi), $GUI_CHECKED) = $GUI_CHECKED $Lotus_Location = "\\" & GUICtrlRead($cnTarget) & "\c$" & $DOC & GUICtrlRead($prCombo) & "\Local Settings\Application Data\Lotus\Notes\Data" Sleep(200) GUIDelete($ChildWin) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) Case $lnmsg = $Box_System And BitAND(GUICtrlRead($Box_System), $GUI_CHECKED) = $GUI_CHECKED $Lotus_Location = "\\" & GUICtrlRead($cnTarget) & "\c$\Lotus\Notes\Data" Sleep(200) GUIDelete($ChildWin) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) EndSelect WEnd EndFunc ;==>Lotus below are the includeds HKCUReg.au3 #include-once #include <File.au3> #include <Security.au3> #include ".\Reg.au3" ; #INDEX# ======================================================================================================================================= ; Title .........: HKCUReg ; AutoIt Version : 3.2.10++ ; Language ......: English ; Description ...: Perform registry operations on 'HKCU' for a specific or all user accounts on a computer ; =============================================================================================================================================== ; #CURRENT# ===================================================================================================================================== ;_HKCU_Delete ;_HKCU_EnumKey ;_HKCU_EnumVal ;_HKCU_Import ;_HKCU_Read ;_HKCU_Write ; =============================================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================================ ;GetProfile ;ProfileAdd ;Split_sKey ; =============================================================================================================================================== ; #FUNCTION# ==================================================================================================================================== ; Name...........: _HKCU_Delete ; Description ...: Deletes a key or value from the registry ; Syntax.........: _HKCU_Delete($sKey [, $sValue]) ; Parameters ....: $sKey - see RegDelete function for details (no 'HKCU' required) ; $sValue - [optional] see RegDelete function for details ; Requirement(s).: ; Return values .: Returns an Array where: ; Column 0 - User account name ; Column 1 - RegDelete function return value ; Column 2 - RegDelete function @error macro ; Author ........: engine ; Modified.......: ; Remarks .......: It is possible to access remote registries by using $sKey in the form "\\\computername\keyname" ; It is possible to access a specific user account by using $sKey in the form "\\username\keyname" ; It is possible to access both a remote registry and a specific user account by using $sKey in the form ; "\\\computername\\username\keyname" ; Related .......: ; Link ..........; ; Examples ......; _HKCU_Delete("Software\7-Zip", "Path") ; _HKCU_Delete("\\\computername\Software\7-Zip", "Path") ; _HKCU_Delete("\\username\Software\7-Zip", "Path") ; _HKCU_Delete("\\\computername\\username\Software\7-Zip", "Path") ; =============================================================================================================================================== Func _HKCU_Delete($sKey, $sValue = Default) Local $asSplit = Split_sKey($sKey) Local $avProfile = GetProfile($asSplit[1], $asSplit[0]) Local $avArray[$avProfile[0][0] + 1][3], $iLoaded, $iResult $avArray[0][0] = $avProfile[0][0] For $i = 1 To $avProfile[0][0] If $avProfile[$i][3] = 0 Then $iLoaded = _RegLoadHive($avProfile[$i][1] & "\NTUSER.DAT", $avProfile[$i][2]) EndIf If $sValue = Default Then $iResult = RegDelete($avProfile[$i][2] & "\" & $asSplit[2]) Else $iResult = RegDelete($avProfile[$i][2] & "\" & $asSplit[2], $sValue) EndIf $avArray[$i][0] = $avProfile[$i][0] $avArray[$i][1] = $iResult $avArray[$i][2] = @error If $iLoaded Then _RegUnloadHive($avProfile[$i][2]) Next Return $avArray EndFunc ;==> _HKCU_Delete ; #FUNCTION# ==================================================================================================================================== ; Name...........: _HKCU_EnumKey ; Description ...: Reads the name of a subkey according to it's instance ; Syntax.........: _HKCU_EnumKey($sKey, $iInstance) ; Parameters ....: $sKey - see RegEnumKey function for details (no 'HKCU' required) ; $iInstance - see RegEnumKey function for details ; Requirement(s).: ; Return values .: Returns an Array where: ; Column 0 - User account name ; Column 1 - RegEnumKey function return value ; Column 2 - RegEnumKey function @error macro ; Author ........: engine ; Modified.......: ; Remarks .......: It is possible to access remote registries by using $sKey in the form "\\\computername\keyname" ; It is possible to access a specific user account by using $sKey in the form "\\username\keyname" ; It is possible to access both a remote registry and a specific user account by using $sKey in the form ; "\\\computername\\username\keyname" ; Related .......: ; Link ..........; ; Example .......; ; #include <Array.au3> ; #include "HKCUReg.au3" ; ; $sComputer = @ComputerName ; ; For $i = 1 To 100 ; $b = _HKCU_EnumKey("\\\" & $sComputer & "\Software", $i) ; $iProd = 1 ; For $j = 1 To $b[0][0] ; $iProd *= $b[$j][2] ; Next ; If $iProd <> 0 Then ExitLoop ; _ArrayDisplay($b, $i) ; Next ; =============================================================================================================================================== Func _HKCU_EnumKey($sKey, $iInstance) Local $asSplit = Split_sKey($sKey) Local $avProfile = GetProfile($asSplit[1], $asSplit[0]) Local $avArray[$avProfile[0][0] + 1][3], $iLoaded $avArray[0][0] = $avProfile[0][0] For $i = 1 To $avProfile[0][0] If $avProfile[$i][3] = 0 Then $iLoaded = _RegLoadHive($avProfile[$i][1] & "\NTUSER.DAT", $avProfile[$i][2]) EndIf $avArray[$i][0] = $avProfile[$i][0] $avArray[$i][1] = RegEnumKey($avProfile[$i][2] & "\" & $asSplit[2], $iInstance) $avArray[$i][2] = @error If $iLoaded Then _RegUnloadHive($avProfile[$i][2]) Next Return $avArray EndFunc ;==> _HKCU_EnumKey ; #FUNCTION# ==================================================================================================================================== ; Name...........: _HKCU_EnumVal ; Description ...: Reads the name of a value according to it's instance ; Syntax.........: _HKCU_EnumVal($sKey, $iInstance) ; Parameters ....: $sKey - see RegEnumVal function for details (no 'HKCU' required) ; $iInstance - see RegEnumVal function for details ; Requirement(s).: ; Return values .: Returns an Array where: ; Column 0 - User account name ; Column 1 - RegEnumVal function return value ; Column 2 - RegEnumVal function @error macro ; Column 3 - RegEnumVal function @extended macro ; Author ........: engine ; Modified.......: ; Remarks .......: It is possible to access remote registries by using $sKey in the form "\\\computername\keyname" ; It is possible to access a specific user account by using $sKey in the form "\\username\keyname" ; It is possible to access both a remote registry and a specific user account by using $sKey in the form ; "\\\computername\\username\keyname" ; Related .......: ; Link ..........; ; Example .......; ; #include <Array.au3> ; #include "HKCUReg.au3" ; ; $sComputer = @ComputerName ; ; For $i = 1 To 100 ; $b = _HKCU_EnumVal("\\\" & $sComputer & "\Software\AutoIt v3\Aut2Exe", $i) ; $iProd = 1 ; For $j = 1 To $b[0][0] ; $iProd *= $b[$j][2] ; Next ; If $iProd <> 0 Then ExitLoop ; _ArrayDisplay($b, $i) ; Next ; =============================================================================================================================================== Func _HKCU_EnumVal($sKey, $iInstance) Local $asSplit = Split_sKey($sKey) Local $avProfile = GetProfile($asSplit[1], $asSplit[0]) Local $avArray[$avProfile[0][0] + 1][4], $iLoaded $avArray[0][0] = $avProfile[0][0] For $i = 1 To $avProfile[0][0] If $avProfile[$i][3] = 0 Then $iLoaded = _RegLoadHive($avProfile[$i][1] & "\NTUSER.DAT", $avProfile[$i][2]) EndIf $avArray[$i][0] = $avProfile[$i][0] $avArray[$i][1] = RegEnumVal($avProfile[$i][2] & "\" & $asSplit[2], $iInstance) $avArray[$i][2] = @error $avArray[$i][3] = @extended If $iLoaded Then _RegUnloadHive($avProfile[$i][2]) Next Return $avArray EndFunc ;==> _HKCU_EnumVal ; #FUNCTION# ==================================================================================================================================== ; Name...........: _HKCU_Import ; Description ...: Imports a previously exported reg file to the registry ; Syntax.........: _HKCU_Import($sReg [, $sName]) ; Parameters ....: $sReg - Path and filename of the file to be imported, file extension (.reg) ; $sName - User account name, defaults to all users ; Requirement(s).: Registry Console Tool ; Return values .: Returns an Array where: ; Column 0 - User account name ; Column 1 - Return value: ; 1 - Success ; 0 - Failure ; Column 2 - @error macro: ; 1 - Failure ; 0 - Success ; Author ........: engine ; Modified.......: ; Remarks .......: This function doesn't support remote computers ; Related .......: ; Link ..........; ; Examples ......; _HKCU_Import("ffdshow.reg") ; _HKCU_Import("ffdshow.reg", "Guest") ; =============================================================================================================================================== Func _HKCU_Import($sReg, $sName = "") Local $avProfile = GetProfile($sName) Local $avArray[$avProfile[0][0] + 1][3], $iLoaded, $avReg, $sReplace, $sTempReg, $iResult $avArray[0][0] = $avProfile[0][0] For $i = 1 To $avProfile[0][0] If $avProfile[$i][3] = 0 Then $iLoaded = _RegLoadHive($avProfile[$i][1] & "\NTUSER.DAT", $avProfile[$i][2]) EndIf _FileReadToArray($sReg, $avReg) $sReplace = StringReplace($avProfile[$i][2], "\\" & @ComputerName & "\", "") For $k = 1 To $avReg[0] $avReg[$k] = StringReplace($avReg[$k], "HKEY_CURRENT_USER", $sReplace) Next $sTempReg = _TempFile(@UserProfileDir, "~", ".reg") _FileWriteFromArray($sTempReg, $avReg, 1) $iResult = RunWait('reg import "' & $sTempReg & '"', "", @SW_HIDE) $avArray[$i][0] = $avProfile[$i][0] $avArray[$i][1] = 1 - $iResult - @error $avArray[$i][2] = @error FileDelete($sTempReg) If $iLoaded Then _RegUnloadHive($avProfile[$i][2]) Next Return $avArray EndFunc ;==> _HKCU_Import ; #FUNCTION# ==================================================================================================================================== ; Name...........: _HKCU_Read ; Description ...: Reads a value from the registry ; Syntax.........: _HKCU_Read($sKey, $sValue) ; Parameters ....: $sKey - see RegRead function for details (no 'HKCU' required) ; $sValue - see RegRead function for details ; Requirement(s).: ; Return values .: Returns an Array where: ; Column 0 - User account name ; Column 1 - RegRead function return value ; Column 2 - RegRead function @error macro ; Column 3 - RegRead function @extended macro ; Author ........: engine ; Modified.......: ; Remarks .......: It is possible to access remote registries by using $sKey in the form "\\\computername\keyname" ; It is possible to access a specific user account by using $sKey in the form "\\username\keyname" ; It is possible to access both a remote registry and a specific user account by using $sKey in the form ; "\\\computername\\username\keyname" ; Related .......: ; Link ..........; ; Examples ......; _HKCU_Read("Software\7-Zip", "Path") ; _HKCU_Read("\\\computername\Software\7-Zip", "Path") ; _HKCU_Read("\\username\Software\7-Zip", "Path") ; _HKCU_Read("\\\computername\\username\Software\7-Zip", "Path") ; =============================================================================================================================================== Func _HKCU_Read($sKey, $sValue) Local $asSplit = Split_sKey($sKey) Local $avProfile = GetProfile($asSplit[1], $asSplit[0]) Local $avArray[$avProfile[0][0] + 1][4], $iLoaded $avArray[0][0] = $avProfile[0][0] For $i = 1 To $avProfile[0][0] If $avProfile[$i][3] = 0 Then $iLoaded = _RegLoadHive($avProfile[$i][1] & "\NTUSER.DAT", $avProfile[$i][2]) EndIf $avArray[$i][0] = $avProfile[$i][0] $avArray[$i][1] = RegRead($avProfile[$i][2] & "\" & $asSplit[2], $sValue) $avArray[$i][2] = @error $avArray[$i][3] = @extended If $iLoaded Then _RegUnloadHive($avProfile[$i][2]) Next Return $avArray EndFunc ;==> _HKCU_Read ; #FUNCTION# ==================================================================================================================================== ; Name...........: _HKCU_Write ; Description ...: Creates a key or value in the registry ; Syntax.........: _HKCU_Write($sKey [, $sValue, $sType, $vData]) ; Parameters ....: $sKey - see RegWrite function for details (no 'HKCU' required) ; $sValue - [optional] see RegWrite function for details ; $sType - [optional] see RegWrite function for details ; $vData - [optional] see RegWrite function for details ; Requirement(s).: ; Return values .: Returns an array where: ; Column 0 - User account name ; Column 1 - RegWrite function return value ; Column 2 - RegWrite function @error macro ; Author ........: engine ; Modified.......: ; Remarks .......: It is possible to access remote registries by using $sKey in the form "\\\computername\keyname" ; It is possible to access a specific user account by using $sKey in the form "\\username\keyname" ; It is possible to access both a remote registry and a specific user account by using $sKey in the form ; "\\\computername\\username\keyname" ; Related .......: ; Link ..........; ; Examples ......; _HKCU_Write("Software\7-Zip", "Path", "REG_SZ", @ProgramFilesDir & "\7-Zip") ; _HKCU_Write("\\\computername\Software\7-Zip", "Path", "REG_SZ", @ProgramFilesDir & "\7-Zip") ; _HKCU_Write("\\username\Software\7-Zip", "Path", "REG_SZ", @ProgramFilesDir & "\7-Zip") ; _HKCU_Write("\\\computername\\username\Software\7-Zip", "Path", "REG_SZ", @ProgramFilesDir & "\7-Zip") ; =============================================================================================================================================== Func _HKCU_Write($sKey, $sValue = "", $sType = "REG_SZ", $vData = "") Local $asSplit = Split_sKey($sKey) Local $avProfile = GetProfile($asSplit[1], $asSplit[0]) Local $avArray[$avProfile[0][0] + 1][3], $iLoaded $avArray[0][0] = $avProfile[0][0] For $i = 1 To $avProfile[0][0] If $avProfile[$i][3] = 0 Then $iLoaded = _RegLoadHive($avProfile[$i][1] & "\NTUSER.DAT", $avProfile[$i][2]) EndIf $avArray[$i][0] = $avProfile[$i][0] $avArray[$i][1] = RegWrite($avProfile[$i][2] & "\" & $asSplit[2], $sValue, $sType, $vData) $avArray[$i][2] = @error If $iLoaded Then _RegUnloadHive($avProfile[$i][2]) Next Return $avArray EndFunc ;==> _HKCU_Write ; #INTERNAL_USE_ONLY#============================================================================================================================ ; Name...........: GetProfile ; Description ...: Determine each user's Profile folder, the user's SID and if the profile is loaded to the registry ; Syntax.........: GetProfile([$sAccount, $sComputer]) ; Parameters ....: $sAccount - User account name, defaults to all users ; $sComputer - Computer name, the local computer is default ; Requirement(s).: Service 'RemoteRegistry' running on the target computer ; When the target computer is the local computer, the 'RemoteRegistry' service isn't required ; Return values .: An array containing the path to each user's profile folder, the user's SID ; The array returned is two-dimensional and is made up as follows: ; $array[0][0] = Number of profiles ; $array[1][0] = 1st user name ; $array[1][1] = Path to 1st user profile ; $array[1][2] = 1st user registry hive ; $array[1][3] = 1 if 1st user profile is loaded to the registry, 0 if not ; $array[2][0] = 2nd user name ; $array[2][1] = Path to 2nd user profile ; $array[2][2] = 2nd user registry hive ; $array[2][3] = 1 if 2nd user profile is loaded to the registry, 0 if not ; ... ; $array[n][0] = nth user name ; $array[n][1] = Path to nth user profile ; $array[n][2] = nth user registry hive ; $array[n][3] = 1 if nth user profile is loaded to the registry, 0 if not ; Author ........: engine ; Modified.......: ; Remarks .......: For internal use only ; Related .......: ; Link ..........; ; Example .......; GetProfile("Default User") to get Default User's profile data on the local computer ; =============================================================================================================================================== Func GetProfile($sAccount = "", $sComputer = @ComputerName) Local $avArray[1][4], $sEnv Local Const $sProfileListKey = "\\" & $sComputer & "\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" Local Const $sRootKey = "\\" & $sComputer & "\HKEY_USERS\" Local Const $sDefaultUser = RegRead($sProfileListKey, "DefaultUserProfile") If @error Then $avArray[0][0] = 0 Return $avArray EndIf If $sAccount = "" Or $sAccount = $sDefaultUser Then Local $iInstance, $sSID While 1 $iInstance += 1 $sSID = RegEnumKey($sProfileListKey, $iInstance) If @error Then ExitLoop If StringLen($sSID) > 8 Then ProfileAdd($avArray, $sSID, $sProfileListKey, $sRootKey) WEnd Local $u = UBound($avArray), $iSum For $k = 1 To $u - 1 $iSum += $avArray[$k][3] Next ReDim $avArray[$u + 1][4] $avArray[$u][0] = $sDefaultUser $avArray[$u][1] = RegRead($sProfileListKey, "ProfilesDirectory") & "\" & $sDefaultUser If $iSum = 0 Then $avArray[$u][2] = "\\" & $sComputer & "\HKEY_CURRENT_USER" $avArray[$u][3] = 1 Else Local $sDSID, $avDU Do $sDSID = "S-1-5-21-" & Random(1E+8, 999999999, 1) & "-" & Random(1E+9, 9999999999, 1) & "-" & Random(1E+8, 999999999, 1) & "-" & Random(1E+3, 9999, 1) $avDU = _Security__LookupAccountSid($sDSID) Until $avDU = 0 $avArray[$u][2] = $sRootKey & $sDSID $avArray[$u][3] = 0 EndIf If $sAccount = $sDefaultUser Then Local $avNew[2][4] = [["", "", "", ""], [$avArray[$u][0], $avArray[$u][1], $avArray[$u][2], $avArray[$u][3]]] $avArray = $avNew EndIf Else Local $avSID = _Security__LookupAccountName($sAccount, $sComputer) ProfileAdd($avArray, $avSID[0], $sProfileListKey, $sRootKey) EndIf $avArray[0][0] = UBound($avArray) - 1 For $j = 1 To $avArray[0][0] $sEnv = StringRegExp($avArray[$j][1], "\x25\S{1,128}\x25", 1) If Not @error Then $avArray[$j][1] = StringReplace( $avArray[$j][1], $sEnv[0], EnvGet( StringReplace($sEnv[0], "%", "") ) ) Next Return $avArray EndFunc ;==> GetProfile ; #INTERNAL_USE_ONLY#============================================================================================================================ ; Name...........: ProfileAdd ; Description ...: Add profile data to an array that will be returned by GetProfile function ; Syntax.........: ProfileAdd($avArray, $sSID, $sProfileListKey, $sRootKey) ; Parameters ....: $avArray - Array ; $sSID - Account SID ; $sProfileListKey - Constant defined inside GetProfile function ; $sRootKey - Constant defined inside GetProfile function ; Requirement(s).: ; Return values .: ; Author ........: engine ; Modified.......: ; Remarks .......: For internal use only ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================================== Func ProfileAdd(ByRef $avArray, $sSID, Const $sProfileListKey, Const $sRootKey) Local $avUser = _Security__LookupAccountSid($sSID), $sPath, $i If Not @error And $avUser <> 0 Then If $avUser[2] = 1 Then $sPath = RegRead($sProfileListKey & "\" & $sSID, "ProfileImagePath") If Not @error Then $i = UBound($avArray) ReDim $avArray[$i + 1][4] $avArray[$i][0] = $avUser[0] $avArray[$i][1] = $sPath $avArray[$i][2] = $sRootKey & $sSID RegEnumKey($sRootKey & $sSID, 1) If @error Then $avArray[$i][3] = 0 Else $avArray[$i][3] = 1 EndIf EndIf EndIf EndIf EndFunc ;==> ProfileAdd ; #INTERNAL_USE_ONLY#============================================================================================================================ ; Name...........: Split_sKey ; Description ...: Splits $sKey between computername, username and keyname ; Syntax.........: Split_sKey($sKey) ; Parameters ....: $sKey - Reg function main key ; Requirement(s).: ; Return values .: ; Author ........: engine ; Modified.......: ; Remarks .......: For internal use only ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================================== Func Split_sKey($sKey) Local $asArray[3] If StringInStr($sKey, "\\\") = 1 Then Local $asComputer = StringRegExp($sKey, "\\\\\\[^\\]*\\", 1) If Not @error Then $asArray[0] = StringTrimRight( StringTrimLeft($asComputer[0], 3), 1 ) $sKey = StringReplace($sKey, $asComputer[0], "\", 1) If Not StringInStr($sKey, "\\") = 1 Then $sKey = StringTrimLeft($sKey, 1) EndIf EndIf If $asArray[0] = "" Then $asArray[0] = @ComputerName If StringInStr($sKey, "\\") = 1 And Not StringInStr($sKey, "\\\") = 1 Then Local $asUser = StringRegExp($sKey, "\\\\[^\\]*\\", 1) If Not @error Then $asArray[1] = StringTrimRight( StringTrimLeft($asUser[0], 2), 1 ) $sKey = StringReplace($sKey, $asUser[0], "", 1) EndIf EndIf If Not ( StringInStr($sKey, "\") = 1 Or StringInStr($sKey, "\", 0, -1) = StringLen($sKey) Or StringInStr($sKey, "\\") ) Then $asArray[2] = $sKey EndIf Return $asArray EndFunc ;==> Split_sKey Reg.au3 #include-once #include <SecurityConstants.au3> #include "Privilege.au3" ; #INDEX# ======================================================================================================================================= ; Title .........: Reg ; AutoIt Version : 3.2.10++ ; Language ......: English ; Description ...: Perform operations with registry files ; =============================================================================================================================================== ; #CURRENT# ===================================================================================================================================== ;_RegLoadHive ;_RegRestoreHive ;_RegSaveHive ;_RegUnloadHive ; =============================================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================================ ;RegCloseKey ;RegConnectRegistry ;RegCreateKeyEx ;RegOpenKeyEx ;Split_sRootKey ; =============================================================================================================================================== Global Const $KEY_READ = 0x20019 Global Const $KEY_WRITE = 0x20006 ; #FUNCTION# ==================================================================================================================================== ; Name...........: _RegLoadHive ; Description ...: Loads a file as a registry hive ; Syntax.........: _RegLoadHive($sFile, $sKey) ; Parameters ....: $sFile - Full path to the file to be loaded ; $sKey - Registry key to load the file to ; Must start with HKEY_LOCAL_MACHINE or HKEY_USERS ; Requirement(s).: None ; Return values .: Success - 1 ; Failure - 0 ; Sets @error ; Author ........: engine ; Modified.......: ; Remarks .......: It is possible to access remote registries by using $sRootKey in the form "\\computername\keyname" ; If a remote computer is specified than $sFile is relative to that computer ; You can only load registry hives to a subkey immediately below HKEY_LOCAL_MACHINE or HKEY_USERS ; Related .......: ; Link ..........; ; Examples ......; _RegLoadHive("C:\Documents and Settings\Guest\ntuser.dat", "HKU\TempHive") ; _RegLoadHive("C:\Documents and Settings\Guest\ntuser.dat", "HKLM\TempHive") ; _RegLoadHive("C:\Documents and Settings\Administrator\ntuser.dat", "\\computername\HKU\S-1-5-21-domain-500") ; _RegLoadHive("C:\Documents and Settings\Guest\ntuser.dat", "\\computername\HKEY_USERS\S-1-5-21-domain-501") ; =============================================================================================================================================== Func _RegLoadHive($sFile, $sKey) Local $avArray = Split_sRootKey($sKey) Local $hKey = RegConnectRegistry($avArray[0], $avArray[1]) Local $avCurr[2][2] = [[$SE_RESTORE_NAME, $SE_PRIVILEGE_ENABLED], [$SE_BACKUP_NAME, $SE_PRIVILEGE_ENABLED]] Local $avPrev = _SetPrivilege($avCurr) Local $avRLH = DllCall("Advapi32.dll", "long", "RegLoadKey", "hwnd", $hKey, "str", $avArray[2], "str", $sFile) _SetPrivilege($avPrev) RegCloseKey($hKey) Return SetError( $avRLH[0], 0, Number($avRLH[0] = 0) ) EndFunc ;==> _RegLoadHive ; #FUNCTION# ==================================================================================================================================== ; Name...........: _RegRestoreHive ; Description ...: Reads the registry information in a specified file and copies it over the specified key ; Syntax.........: _RegRestoreHive($sFile, $sKey) ; Parameters ....: $sFile - The name of the file with the registry information ; $sKey - Registry key ; Requirement(s).: None ; Return values .: Success - 1 ; Failure - 0 ; Sets @error ; Author ........: engine ; Modified.......: ; Remarks .......: It is possible to access remote registries by using $sKey in the form "\\computername\keyname" ; If a remote computer is specified than $sFile is relative to that computer ; Related .......: ; Link ..........; ; Example .......; _RegRestoreHive("HKCU.dat", "\\" & @ComputerName & "\HKCU") ; =============================================================================================================================================== Func _RegRestoreHive($sFile, $sKey) Local Const $REG_FORCE_RESTORE = 0x00000008 Local $avArray = Split_sRootKey($sKey) Local $hRoot = RegConnectRegistry($avArray[0], $avArray[1]) Local $hKey = RegCreateKeyEx( $hRoot, $avArray[2], BitOR($KEY_READ, $KEY_WRITE) ) RegCloseKey($hRoot) Local $avCurr[2][2] = [[$SE_RESTORE_NAME, $SE_PRIVILEGE_ENABLED], [$SE_BACKUP_NAME, $SE_PRIVILEGE_ENABLED]] Local $avPrev = _SetPrivilege($avCurr) Local $avRRK = DllCall("Advapi32.dll", "long", "RegRestoreKey", "hwnd", $hKey, "str", $sFile, "dword", $REG_FORCE_RESTORE) _SetPrivilege($avPrev) RegCloseKey($hKey) Return SetError( $avRRK[0], 0, Number($avRRK[0] = 0) ) EndFunc ;==> _RegRestoreHive ; #FUNCTION# ==================================================================================================================================== ; Name...........: _RegSaveHive ; Description ...: Saves the specified key and all of its subkeys and values to a new file, in the standard format ; Syntax.........: _RegSaveHive($sFile, $sKey) ; Parameters ....: $sFile - The name of the file in which the specified key and subkeys are to be saved ; $sKey - Registry key ; Requirement(s).: None ; Return values .: Success - 1 ; Failure - 0 ; Sets @error ; Author ........: engine ; Modified.......: ; Remarks .......: It is possible to access remote registries by using $sKey in the form "\\computername\keyname" ; Related .......: ; Link ..........; ; Example .......; _RegSaveHive("HKCU.dat", "\\" & @ComputerName & "\HKCU") ; =============================================================================================================================================== Func _RegSaveHive($sFile, $sKey) Local $avArray = Split_sRootKey($sKey) Local $hRoot = RegConnectRegistry($avArray[0], $avArray[1]) Local $hKey = RegOpenKeyEx($hRoot, $avArray[2], $KEY_READ) RegCloseKey($hRoot) Local $avCurr[2] = [$SE_BACKUP_NAME, $SE_PRIVILEGE_ENABLED] Local $avPrev = _SetPrivilege($avCurr) Local $avRSK = DllCall("Advapi32.dll", "long", "RegSaveKey", "hwnd", $hKey, "str", $sFile, "ptr", 0) _SetPrivilege($avPrev) RegCloseKey($hKey) Return SetError( $avRSK[0], 0, Number($avRSK[0] = 0) ) EndFunc ;==> _RegSaveHive ; #FUNCTION# ==================================================================================================================================== ; Name...........: _RegUnloadHive ; Description ...: Unloads a registry hive ; Syntax.........: _RegUnloadHive($sKey) ; Parameters ....: $sKey - Registry key to unload the hive from ; Requirement(s).: None ; Return values .: Success - 1 ; Failure - 0 ; Sets @error ; Author ........: engine ; Modified.......: ; Remarks .......: It is possible to access remote registries by using $sKey in the form "\\computername\keyname" ; Related .......: ; Link ..........; ; Examples ......; _RegUnloadHive("HKU\TempHive") ; _RegUnloadHive("HKLM\TempHive") ; _RegUnloadHive("\\computername\HKU\S-1-5-21-domain-500") ; _RegUnloadHive("\\computername\HKEY_USERS\S-1-5-21-domain-501") ; =============================================================================================================================================== Func _RegUnloadHive($sKey) Local $avArray = Split_sRootKey($sKey) Local $hKey = RegConnectRegistry($avArray[0], $avArray[1]) Local $avCurr[2][2] = [[$SE_RESTORE_NAME, $SE_PRIVILEGE_ENABLED], [$SE_BACKUP_NAME, $SE_PRIVILEGE_ENABLED]] Local $avPrev = _SetPrivilege($avCurr) Local $avRUH = DllCall("Advapi32.dll", "long", "RegUnLoadKey", "hwnd", $hKey, "str", $avArray[2]) _SetPrivilege($avPrev) RegCloseKey($hKey) Return SetError( $avRUH[0], 0, Number($avRUH[0] = 0) ) EndFunc ;==> _RegUnloadHive ; #INTERNAL_USE_ONLY#============================================================================================================================ ; Name...........: RegCloseKey ; Description ...: Closes a handle to the specified registry key ; Syntax.........: RegCloseKey($hKey) ; Parameters ....: $hKey - Registry key handle to close ; Requirement(s).: None ; Return values .: Success - 1 ; Failure - 0 ; Sets @error ; Author ........: engine ; Modified.......: ; Remarks .......: For internal use only ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================================== Func RegCloseKey($hKey) Local $avRCK = DllCall("Advapi32.dll", "long", "RegCloseKey", "hwnd", $hKey) Return SetError( $avRCK[0], 0, Number($avRCK[0] = 0) ) EndFunc ;==> RegCloseKey ; #INTERNAL_USE_ONLY#============================================================================================================================ ; Name...........: RegConnectRegistry ; Description ...: Establishes a connection to a predefined registry key on another computer ; Syntax.........: RegConnectRegistry($sComputer, $hKey) ; Parameters ....: $sComputer - Computer name in the form '\\computername' ; $hKey - Predefined registry key handle ; Requirement(s).: Service 'RemoteRegistry' running on the target computer ; When the target computer is the local computer, the 'RemoteRegistry' service isn't required ; Return values .: Success - Registry key handle ; Failure - 0 ; Sets @error ; Author ........: engine ; Modified.......: ; Remarks .......: For internal use only ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================================== Func RegConnectRegistry($sComputer, $hKey) Local $avRCR = DllCall( "Advapi32.dll", "long", "RegConnectRegistry", _ "str", $sComputer, _ "hwnd", $hKey, _ "hwnd*", 0 ) Return SetError($avRCR[0], 0, $avRCR[3]) EndFunc ;==> RegConnectRegistry ; #INTERNAL_USE_ONLY#============================================================================================================================ ; Name...........: RegCreateKeyEx ; Description ...: Creates the specified registry key ; Syntax.........: RegCreateKeyEx($kKey, $sSubKey, $iAccess) ; Parameters ....: $hKey - Predefined registry key handle ; $sSubKey - The name of the registry subkey to be created ; $iAccess - A mask that specifies the desired access rights to the key ; Requirement(s).: None ; Return values .: Success - Registry key handle ; Failure - 0 ; Sets @error ; Author ........: engine ; Modified.......: ; Remarks .......: For internal use only ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================================== Func RegCreateKeyEx($kKey, $sSubKey, $iAccess) Local Const $REG_OPTION_NON_VOLATILE = 0x00000000 Local $avRCKE = DllCall( "Advapi32.dll", "long", "RegCreateKeyEx", _ "hwnd", $kKey, _ "str", $sSubKey, _ "dword", 0, _ "ptr", 0, _ "dword", $REG_OPTION_NON_VOLATILE, _ "dword", $iAccess, _ "ptr", 0, _ "hwnd*", 0, _ "ptr", 0 ) Return SetError($avRCKE[0], 0, $avRCKE[8]) EndFunc ;==> RegCreateKeyEx ; #INTERNAL_USE_ONLY#============================================================================================================================ ; Name...........: RegOpenKeyEx ; Description ...: Opens the specified registry key ; Syntax.........: RegOpenKeyEx($hKey, $sSubKey, $iAccess) ; Parameters ....: $hKey - Predefined registry key handle ; $sSubKey - The name of the registry subkey to be opened ; $iAccess - A mask that specifies the desired access rights to the key ; Requirement(s).: None ; Return values .: Success - Registry key handle ; Failure - 0 ; Sets @error ; Author ........: engine ; Modified.......: ; Remarks .......: For internal use only ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================================== Func RegOpenKeyEx($hKey, $sSubKey, $iAccess) Local $avROKE = DllCall( "Advapi32.dll", "long", "RegOpenKeyEx", _ "hwnd", $hKey, _ "str", $sSubKey, _ "dword", 0, _ "dword", $iAccess, _ "hwnd*", 0 ) Return SetError($avROKE[0], 0, $avROKE[5]) EndFunc ;==> RegOpenKeyEx ; #INTERNAL_USE_ONLY#============================================================================================================================ ; Name...........: Split_sRootKey ; Description ...: Splits $sRootKey between computer name, predefined registry key handle and subkey ; Syntax.........: Split_sRootKey($sRootKey) ; Parameters ....: $sRootKey - Reg function main key ; Requirement(s).: None ; Return values .: Returns an array where: ; $array[0] = \\computername ; $array[1] = Predefined registry key handle ; $array[2] = Subkey ; Author ........: engine ; Modified.......: ; Remarks .......: For internal use only ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================================== Func Split_sRootKey($sRootKey) Local Const $HKEY_CLASSES_ROOT = 0x80000000 Local Const $HKEY_CURRENT_USER = 0x80000001 Local Const $HKEY_LOCAL_MACHINE = 0x80000002 Local Const $HKEY_USERS = 0x80000003 Local Const $HKEY_CURRENT_CONFIG = 0x80000005 Local $avHKEY[5][3] = [["HKCR", "HKEY_CLASSES_ROOT", $HKEY_CLASSES_ROOT], _ ["HKCU", "HKEY_CURRENT_USER", $HKEY_CURRENT_USER], _ ["HKLM", "HKEY_LOCAL_MACHINE", $HKEY_LOCAL_MACHINE], _ ["HKU", "HKEY_USERS", $HKEY_USERS], _ ["HKCC", "HKEY_CURRENT_CONFIG", $HKEY_CURRENT_CONFIG]] Local $avArray[3] If StringInStr($sRootKey, "\\") = 1 Then Local $asComputer = StringRegExp($sRootKey, "\\\\[^\\]*\\", 1) If Not @error Then $avArray[0] = StringTrimRight($asComputer[0], 1) $sRootKey = StringReplace($sRootKey, $asComputer[0], "", 1) EndIf EndIf If StringInStr($sRootKey, "\") = 1 Or StringInStr($sRootKey, "\", 0, -1) = StringLen($sRootKey) Or StringInStr($sRootKey, "\\") Then $avArray[0] = "" Return $avArray Else Local $asSplit = StringSplit($sRootKey, "\") For $i = 0 To UBound($avHKEY) - 1 If $asSplit[1] = $avHKEY[$i][0] Or $asSplit[1] = $avHKEY[$i][1] Then $avArray[1] = $avHKEY[$i][2] ExitLoop EndIf Next If $avArray[1] = "" Then $avArray[0] = "" Return $avArray EndIf For $i = 2 To $asSplit[0] - 1 $avArray[2] &= $asSplit[$i] & "\" Next If $asSplit[0] > 1 Then $avArray[2] &= $asSplit[ $asSplit[0] ] EndIf Return $avArray EndFunc ;==> Split_sRootKey Privilege.au3 #include-once #include <Constants.au3> #include <SecurityConstants.au3> ; #FUNCTION# ==================================================================================================================================== ; Name...........: _SetPrivilege ; Description ...: Enables or disables special privileges as required by some DllCalls ; Syntax.........: _SetPrivilege($avPrivilege) ; Parameters ....: $avPrivilege - An array of privileges and respective attributes ; $SE_PRIVILEGE_ENABLED - The function enables the privilege ; $SE_PRIVILEGE_REMOVED - The privilege is removed from the list of privileges in the token ; 0 - The function disables the privilege ; Requirement(s).: None ; Return values .: Success - An array of modified privileges and their respective previous attribute state ; Failure - An empty array ; Sets @error ; Author ........: engine ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================================== Func _SetPrivilege($avPrivilege) Local $iDim = UBound($avPrivilege, 0), $avPrevState[1][2] If Not ( $iDim <= 2 And UBound($avPrivilege, $iDim) = 2 ) Then Return SetError(1300, 0, $avPrevState) If $iDim = 1 Then Local $avTemp[1][2] $avTemp[0][0] = $avPrivilege[0] $avTemp[0][1] = $avPrivilege[1] $avPrivilege = $avTemp $avTemp = 0 EndIf Local $k, $tagTP = "dword", $iTokens = UBound($avPrivilege, 1) Do $k += 1 $tagTP &= ";dword;long;dword" Until $k = $iTokens Local $tCurrState, $tPrevState, $pPrevState, $tLUID, $hAdvapi32, $hKernel32, $ahGCP, $avOPT, $aiGLE $tCurrState = DLLStructCreate($tagTP) $tPrevState = DllStructCreate($tagTP) $pPrevState = DllStructGetPtr($tPrevState) $tLUID = DllStructCreate("dword;long") DLLStructSetData($tCurrState, 1, $iTokens) $hAdvapi32 = DllOpen("Advapi32.dll") For $i = 0 To $iTokens - 1 DllCall( $hAdvapi32, "int", "LookupPrivilegeValue", _ "str", "", _ "str", $avPrivilege[$i][0], _ "ptr", DllStructGetPtr($tLUID) ) DLLStructSetData( $tCurrState, 3 * $i + 2, DllStructGetData($tLUID, 1) ) DLLStructSetData( $tCurrState, 3 * $i + 3, DllStructGetData($tLUID, 2) ) DLLStructSetData( $tCurrState, 3 * $i + 4, $avPrivilege[$i][1] ) Next $hKernel32 = DllOpen("Kernel32.dll") $ahGCP = DllCall($hKernel32, "hwnd", "GetCurrentProcess") $avOPT = DllCall( $hAdvapi32, "int", "OpenProcessToken", _ "hwnd", $ahGCP[0], _ "dword", BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY), _ "hwnd*", 0 ) DllCall( $hAdvapi32, "int", "AdjustTokenPrivileges", _ "hwnd", $avOPT[3], _ "int", False, _ "ptr", DllStructGetPtr($tCurrState), _ "dword", DllStructGetSize($tCurrState), _ "ptr", $pPrevState, _ "dword*", 0 ) $aiGLE = DllCall($hKernel32, "dword", "GetLastError") DllCall($hKernel32, "int", "CloseHandle", "hwnd", $avOPT[3]) DllClose($hKernel32) Local $iCount = DllStructGetData($tPrevState, 1) If $iCount > 0 Then Local $pLUID, $avLPN, $tName, $avPrevState[$iCount][2] For $i = 0 To $iCount - 1 $pLUID = $pPrevState + 12 * $i + 4 $avLPN = DllCall( $hAdvapi32, "int", "LookupPrivilegeName", _ "str", "", _ "ptr", $pLUID, _ "ptr", 0, _ "dword*", 0 ) $tName = DllStructCreate("char[" & $avLPN[4] & "]") DllCall( $hAdvapi32, "int", "LookupPrivilegeName", _ "str", "", _ "ptr", $pLUID, _ "ptr", DllStructGetPtr($tName), _ "dword*", DllStructGetSize($tName) ) $avPrevState[$i][0] = DllStructGetData($tName, 1) $avPrevState[$i][1] = DllStructGetData($tPrevState, 3 * $i + 4) Next EndIf DllClose($hAdvapi32) Return SetError($aiGLE[0], 0, $avPrevState) EndFunc ;==> _SetPrivilege surreal.au3 #region consts Global Const $FO_MOVE = 0x0001 Global Const $FO_COPY = 0x0002 Global Const $FO_DELETE = 0x0003 Global Const $FO_RENAME = 0x0004 Global Const $FOF_MULTIDESTFILES = 0x0001 Global Const $FOF_CONFIRMMOUSE = 0x0002 Global Const $FOF_SILENT = 0x0004 Global Const $FOF_RENAMEONCOLLISION = 0x0008 Global Const $FOF_NOCONFIRMATION = 0x0010 Global Const $FOF_WANTMAPPINGHANDLE = 0x0020 Global Const $FOF_ALLOWUNDO = 0x0040 Global Const $FOF_FILESONLY = 0x0080 Global Const $FOF_SIMPLEPROGRESS = 0x0100 Global Const $FOF_NOCONFIRMMKDIR = 0x0200 Global Const $FOF_NOERRORUI = 0x0400 Global Const $FOF_NOCOPYSECURITYATTRIBS = 0x0800 Global Const $FOF_NORECURSION = 0x1000 Global Const $FOF_NO_CONNECTED_ELEMENTS = 0x2000 Global Const $FOF_WANTNUKEWARNING = 0x4000 Global Const $FOF_NORECURSEREPARSE = 0x8000 #endregion consts ;$result = _CopyWithProgress("\\folder\folder\folder\*.*","C:\folder") Func _CopyWithProgress($sFrom, $sTo) ; version 1 by SumTingWong on 5/26/2006 ; http://www.autoitscript.com/forum/index.php?showtopic=11888 ; updated by lod3n on 6/5/2007 Local $SHFILEOPSTRUCT Local $pFrom Local $pTo Local $aDllRet Local $nError = 0 Local $i $SHFILEOPSTRUCT = DllStructCreate("int;uint;ptr;ptr;uint;int;ptr;ptr") If @error Then Return "nostruct" ; hwnd DllStructSetData($SHFILEOPSTRUCT, 1, 0) ; wFunc DllStructSetData($SHFILEOPSTRUCT, 2, $FO_COPY) ; pFrom $pFrom = DllStructCreate("char[" & StringLen($sFrom)+2 & "]") ; pFrom will now be null-terminated at StringLen($sFrom)+1 DllStructSetData($pFrom, 1, $sFrom) For $i = 1 To StringLen($sFrom)+2 If DllStructGetData($pFrom, 1, $i) = 10 Then DllStructSetData($pFrom, 1, 0, $i) Next ; We need a second null at the end DllStructSetData($pFrom, 1, 0, StringLen($sFrom)+2) DllStructSetData($SHFILEOPSTRUCT, 3, DllStructGetPtr($pFrom)) ; pTo $pTo = DllStructCreate("char[" & StringLen($sTo)+2 & "]") ; pTo will now be null-terminated at StringLen($sTo)+1 DllStructSetData($pTo, 1, $sTo) ; We need a second null at the end DllStructSetData($pTo, 1, 0, StringLen($sTo)+2) DllStructSetData($SHFILEOPSTRUCT, 4, DllStructGetPtr($pTo)) ; fFlags DllStructSetData($SHFILEOPSTRUCT, 5, BitOR($FOF_NOCONFIRMMKDIR, _ $FOF_NOCONFIRMATION, _ $FOF_NOERRORUI)) ; fAnyOperationsAborted DllStructSetData($SHFILEOPSTRUCT, 6, 0) ; hNameMappings DllStructSetData($SHFILEOPSTRUCT, 7, 0) ; lpszProgressTitle DllStructSetData($SHFILEOPSTRUCT, 8, 0) $aDllRet = DllCall("shell32.dll", "int", "SHFileOperation", "ptr", DllStructGetPtr($SHFILEOPSTRUCT)) $retcode = $aDllRet[0] $pFrom = 0 $pTo = 0 $SHFILEOPSTRUCT = 0 If $retcode <> 0 Then ConsoleWrite(hex($retcode) & ": " & SHFileOperationErrDecode($retcode) & @crlf) SetError($nError) Return False EndIf Return True EndFunc func SHFileOperationErrDecode($errNum) Switch $errNum case 113 return "The source and destination files are the same file." case 114 return "Multiple file paths were specified in the source buffer, but only one destination file path." case 115 return "Rename operation was specified but the destination path is a different directory. Use the move operation instead." case 116 return "The source is a root directory, which cannot be moved or renamed." case 117 return "The operation was cancelled by the user, or silently cancelled if the appropriate flags were supplied to SHFileOperation." case 118 return "The destination is a subtree of the source." case 120 return "Security settings denied access to the source." case 121 return "The source or destination path exceeded or would exceed MAX_PATH." case 122 return "The operation involved multiple destination paths, which can fail in the case of a move operation." case 124 return "The path in the source or destination or both was invalid." case 125 return "The source and destination have the same parent folder." case 126 return "The destination path is an existing file." case 128 return "The destination path is an existing folder." case 129 return "The name of the file exceeds MAX_PATH." case 130 return "The destination is a read-only CD-ROM, possibly unformatted." case 131 return "The destination is a read-only DVD, possibly unformatted." case 132 return "The destination is a writable CD-ROM, possibly unformatted." case 133 return "The file involved in the operation is too large for the destination media or file system." case 134 return "The source is a read-only CD-ROM, possibly unformatted." case 135 return "The source is a read-only DVD, possibly unformatted." case 136 return "The source is a writable CD-ROM, possibly unformatted." case 183 return "MAX_PATH was exceeded during the operation." case 1026 return "An unknown error occurred. This is typically due to an invalid path in the source or destination. This error does not occur on Microsoft Windows Vista and later." case 65536 return "An unspecified error occurred on the destination." case 65652 return "Destination is a root directory and cannot be renamed." EndSwitch return "SHFileOperation returned errorcode " & hex($errNum) & ", which is not recognized" EndFunc thank you everyone for your help d@ve
-
thx kaotkbliss! martin, i have included the code, the only reason for the download as well is cause of the extra #includes. trying to have the gathered array information port into some kinda of popup that a user can select via checkbox what to or what not to install. the gathered information is from a remote system or local if you enter in the current computer name, the arrays gather the printers and mapped drives. thanks everyone! d@ve
-
any help would be great, is this maybe in the wrong part of the forum? d@ve
-
thanks to everyone that has looked over this so far. im still not able to get this to work. maybe GUICtrlCreateListView is not the correct format to accomplish what i need? d@ve
-
been trying a few things, im still not sure if this is not working cause of how im create the array. below is where i am so far, but not sure if i am even on the right track. thanks for the help. ;===Function For Mapped Drives===================================================================== Func Drives() If GUICtrlRead($cnTarget) = '' Then MsgBox(16, "", 'Target machine must be entered') Else SplashTextOn($sTitle, "Transfering Mapped Drives", 165, 40, -1, -1, 2, "", 9) Local $masset = GUICtrlRead($cnTarget) DirCreate("c:\Temp\Drives") Local $mapLocation = "c:\Temp\Drives\Drives.txt" Local $mapFile = FileOpen($mapLocation, 10) For $i = 1 To 25 $b = _HKCU_EnumKey("\\\" & $masset & "\Network", $i) $iProdm = 1 For $j = 1 To $b[0][0] $iProdm *= $b[$j][2] If $b[$j][2] = 0 Then $Path = _HKCU_Read("\\\" & $masset & "\\" & $b[$j][0] & "\Network\" & $b[$j][1], "RemotePath") FileWriteLine($mapFile, $b[$j][1] & "," & $Path[1][1]) EndIf Next If $iProdm <> 0 Then ExitLoop Next SplashOff() FileClose("c:\Temp\Drives\Drives.txt") EndIf GUICreate("Network Drives", 520, 125) $listview = GUICtrlCreateListView("", 10, 10, 495, 100) GUISetState() _GUICtrlListView_AddColumn($listview, "Drive Letter", 100) _GUICtrlListView_AddColumn($listview, "Mapped Path", 100) _GUICtrlListView_AddArray($listview, $Path) EndFunc ;==>Drives
-
I have gotten pretty far with this program but have once again hit a point that is beyond my coding knowledge and looking for some assistance. Here is the new code with all the needed files: Download When you test this script you will want to use the file – backup, option. That way it will place anything you select in a folder that you choose. This is best for testing. The mapped drives and printers part is what I’m having trouble with. I have the code working to create an array that will export the information to a text file (c:\temp). What I would like to do is have it to where it would pop up a listview with each device the array gathered. Within that listview have a checkbox so the the user can select what printers or mapped drives they want to install. to run the mapped drives or printers script it is located within the toolbar (programs) I did notice that maybe the problem with this is that the text file does not populate the array info tell you exit the program. #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 <Surreal.au3> #include <GuiStatusBar.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 Global $Lotus_Location Local $sTitle = 'eMigrate' Local $backup = "\Migrate_Backup\" Local $network = "c:\Temp\Migrate_Network\" Local $restore = "\Migrate_Restore\" Local $LogFile = "c:\Temp\LogFile.txt" Local $Separator = "------------------------------" Local $LogFileLocation = @ProgramFilesDir & "\" & $sTitle & "\eMigrate.txt" ;===GUI Start and File Menu======================================================================== $ParentWin = GUICreate("", 330, 185, -1, -1) $FileMenu = GUICtrlCreateMenu("&File") $BKItem = GUICtrlCreateMenuItem("Backup Only", $FileMenu) $RSItem = GUICtrlCreateMenuItem("Restore Only", $FileMenu) $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) $PRItem = GUICtrlCreateMenuItem("Migrate Printers", $ProMenu) $MDItem = GUICtrlCreateMenuItem("Migrate Mapped Drives", $ProMenu) $CPItem = GUICtrlCreateMenuItem("Command Prompt", $ProMenu) $HelpMenu = GUICtrlCreateMenu("&Help") $HelpItem = GUICtrlCreateMenuItem($sTitle & " Help", $HelpMenu) GUICtrlSetState($BKItem, $GUI_UNCHECKED) GUICtrlSetState($RSItem, $GUI_UNCHECKED) ;===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) $Box_Documents = GUICtrlCreateCheckbox("My Documents", 220, 25) $Box_IEFav = GUICtrlCreateCheckbox("IE Favorites", 220, 45) $Box_Notes = GUICtrlCreateCheckbox("Lotus Notes", 220, 65) GUICtrlSetState($Box_Documents, $GUI_CHECKED) GUICtrlSetState($Box_IEFav, $GUI_CHECKED) GUICtrlSetState($Box_Notes, $GUI_UNCHECKED) ;===GUI Start Function============================================================================= $StartButton = GUICtrlCreateButton("Start", 230, 100, 65, 30, $WS_GROUP) $StatusBar = _GUICtrlStatusBar_Create($ParentWin) _GUICtrlStatusBar_SetMinHeight($StatusBar, 5) 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) _GUICtrlStatusBar_SetText($StatusBar, "") Else GUICtrlSetState($BKItem, $GUI_CHECKED) Local $BKtarget = FileSelectFolder("Choose the location you want to back up to:" & @CRLF & "A backup folder (eMigrate) will be created", "", 1) _GUICtrlStatusBar_SetText($StatusBar, " Backup Mode Enabled") GUICtrlSetData($cnTarget, @ComputerName) GUICtrlSetState($RSItem, $GUI_UNCHECKED) Connect() EndIf If $BKtarget = '' Then GUICtrlSetState($BKItem, $GUI_UNCHECKED) _GUICtrlStatusBar_SetText($StatusBar, "") EndIf Case $msg = $RSItem If BitAND(GUICtrlRead($RSItem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($RSItem, $GUI_UNCHECKED) _GUICtrlStatusBar_SetText($StatusBar, "") Else GUICtrlSetState($RSItem, $GUI_CHECKED) Local $RStarget = FileSelectFolder("Choose the location you want to restore from:" & @CRLF & "Select the (eMigrate) folder you created", "") _GUICtrlStatusBar_SetText($StatusBar, " Restore Mode Enabled") GUICtrlSetData($cnTarget, @ComputerName) GUICtrlSetState($BKItem, $GUI_UNCHECKED) Connect() EndIf If $RStarget = '' Then GUICtrlSetState($RSItem, $GUI_UNCHECKED) _GUICtrlStatusBar_SetText($StatusBar, "") EndIf Case $msg = $HelpItem MsgBox(64, $sTitle, "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($LogFileLocation) Then ShellExecute($LogFileLocation, "") Else MsgBox(48, $sTitle, "A Log File has not been created yet.") EndIf Case $msg = $CPItem Run('cmd.exe', @SystemDir) ;===Case For Mapped Drives and Printers not working yet============================================ Case $msg = $MDItem If GUICtrlRead($cnTarget) = '' Then MsgBox(16, "", 'Target machine must be entered') Else Drives() MsgBox(64, $sTitle, "File has been created (c:\Temp\Drives)") EndIf Case $msg = $PRItem If GUICtrlRead($cnTarget) = '' Then MsgBox(16, "", 'Target machine must be entered') Else Printers() FileClose("c:\Temp\Printers\Printers.txt") MsgBox(64, $sTitle, "File has been created (c:\Temp\Printers)") EndIf ;===Case For Lotus Notes CheckBox================================================================== Case $msg = $Box_Notes If GUICtrlRead($cnTarget) = '' Or GUICtrlRead($prCombo) = '' Then MsgBox(16, "", 'Target machine and a profile must be entered') GUICtrlSetState($Box_Notes, $GUI_UNCHECKED) EndIf If BitAND(GUICtrlRead($Box_Notes), $GUI_UNCHECKED) = $GUI_UNCHECKED Then GUICtrlSetState($Box_Notes, $GUI_UNCHECKED) Else Lotus() GUICtrlSetState($Box_Notes, $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 Local $rmfavs = $Path & "\c$" & $DOC & GUICtrlRead($prCombo) & "\Favorites" Local $LotusProgram = @ProgramFilesDir & "\Lotus\Notes\Data" ;====================My Documents If GUICtrlRead($Box_Documents) = $GUI_CHECKED And BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then ;-----Backup _GUICtrlStatusBar_SetText($StatusBar, " Backing Up My Documents") DirCreate($BKtarget & $backup & $DF & "\" & GUICtrlRead($prCombo)) _CopyWithProgress($rmdocs & "\*.*", $BKtarget & $backup & $DF & "\" & GUICtrlRead($prCombo)) FileWriteLine($LogFile, "My Documents" & @TAB & "(Backup Successful)" & @CRLF) ElseIf GUICtrlRead($Box_Documents) = $GUI_CHECKED And BitAND(GUICtrlRead($RSItem), $GUI_CHECKED) = $GUI_CHECKED Then ;-----Restore _GUICtrlStatusBar_SetText($StatusBar, " Restoring My Documents") _CopyWithProgress($RStarget & $DF & "\" & GUICtrlRead($prCombo) & "\*.*", "c:" & $DOC & GUICtrlRead($prCombo) & "\" & $DF) FileWriteLine($LogFile, "My Documents" & @TAB & "(Restore Successful)" & @CRLF) ElseIf GUICtrlRead($Box_Documents) = $GUI_CHECKED Then ;-----Network _GUICtrlStatusBar_SetText($StatusBar, " Transferring My Documents") _CopyWithProgress($rmdocs & "\*.*", "c:" & $DOC & GUICtrlRead($prCombo) & "\" & $DF) FileWriteLine($LogFile, "My Documents" & @TAB & "(Network Successful)" & @CRLF) EndIf ;====================Favorites If GUICtrlRead($Box_IEFav) = $GUI_CHECKED And BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then ;-----Backup _GUICtrlStatusBar_SetText($StatusBar, " Backing Up Favorites") GUICtrlSetColor($cnMessage, 0x008000) DirCreate($BKtarget & $backup & "Favorites") _CopyWithProgress($rmfavs & "\*.*", $BKtarget & $backup & "Favorites") FileWriteLine($LogFile, "Favorites" & @TAB & "(Backup Successful)" & @CRLF) ElseIf GUICtrlRead($Box_IEFav) = $GUI_CHECKED And BitAND(GUICtrlRead($RSItem), $GUI_CHECKED) = $GUI_CHECKED Then ;-----Restore _GUICtrlStatusBar_SetText($StatusBar, " Restoring Favorites") _CopyWithProgress($RStarget & "Favorites" & "\*.*", "c:" & $DOC & GUICtrlRead($prCombo) & "\Favorites") FileWriteLine($LogFile, "Favorites" & @TAB & "(Restore Successful)" & @CRLF) ElseIf GUICtrlRead($Box_IEFav) = $GUI_CHECKED Then ;-----Network _GUICtrlStatusBar_SetText($StatusBar, " Transferring Favorites") _CopyWithProgress($rmfavs & "\*.*", "c:" & $DOC & GUICtrlRead($prCombo) & "\Favorites") FileWriteLine($LogFile, "Favorites" & @TAB & "(Network Successful)" & @CRLF) EndIf ;====================Lotus Notes If GUICtrlRead($Box_Notes) = $GUI_CHECKED And BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then ;-----Backup _GUICtrlStatusBar_SetText($StatusBar, " Backing Up Lotus Notes") DirCreate($BKtarget & $backup & "Notes") _CopyWithProgress($Lotus_Location & "\*.id", $BKtarget & $backup & "Notes") _CopyWithProgress($Lotus_Location & "\Desktop6.ndk", $BKtarget & $backup & "Notes") _CopyWithProgress($Lotus_Location & "\Names.nsf", $BKtarget & $backup & "Notes") _CopyWithProgress($Lotus_Location & "\User.dic", $BKtarget & $backup & "Notes") DirCreate($BKtarget & $backup & "Notes\Archive") _CopyWithProgress($Lotus_Location & "\Archive\*.*", $BKtarget & $backup & "Notes\Archive") FileWriteLine($LogFile, "Lotus Notes" & @TAB & "(Backup Successful)" & @CRLF) ElseIf GUICtrlRead($Box_Notes) = $GUI_CHECKED And BitAND(GUICtrlRead($RSItem), $GUI_CHECKED) = $GUI_CHECKED Then ;-----Restore _GUICtrlStatusBar_SetText($StatusBar, " Restoring Lotus Notes") _CopyWithProgress($RStarget & "Notes" & "\*.*", $LotusProgram) FileWriteLine($LogFile, "Lotus Notes" & @TAB & "(Restore Successful)" & @CRLF) ElseIf GUICtrlRead($Box_Notes) = $GUI_CHECKED Then ;-----Network _GUICtrlStatusBar_SetText($StatusBar, " Transferring Lotus Notes") _CopyWithProgress($Lotus_Location & "\*.id", $LotusProgram) _CopyWithProgress($Lotus_Location & "\Desktop6.ndk", $LotusProgram) _CopyWithProgress($Lotus_Location & "\Names.nsf", $LotusProgram) _CopyWithProgress($Lotus_Location & "\User.dic", $LotusProgram) DirCreate($LotusProgram & "\Archive") _CopyWithProgress($Lotus_Location & "\Archive\*.*", $LotusProgram & "\Archive") FileWriteLine($LogFile, "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() If GUICtrlRead($cnTarget) = '' Then MsgBox(16, "", 'Target machine must be entered') Else SplashTextOn($sTitle, "Transfering Printers", 165, 40, -1, -1, 2, "", 9) Local $passet = GUICtrlRead($cnTarget) DirCreate("c:\Temp\Printers") Local $pLocation = "c:\Temp\Printers\Printers.txt" Local $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 SplashOff() EndIf Return EndFunc ;==>Printers ;===Function For Mapped Drives===================================================================== Func Drives() If GUICtrlRead($cnTarget) = '' Then MsgBox(16, "", 'Target machine must be entered') Else SplashTextOn($sTitle, "Transfering Mapped Drives", 165, 40, -1, -1, 2, "", 9) Local $masset = GUICtrlRead($cnTarget) DirCreate("c:\Temp\Drives") Local $mapLocation = "c:\Temp\Drives\Drives.txt" Local $mapFile = FileOpen($mapLocation, 10) For $i = 1 To 25 $b = _HKCU_EnumKey("\\\" & $masset & "\Network", $i) $iProdm = 1 For $j = 1 To $b[0][0] $iProdm *= $b[$j][2] If $b[$j][2] = 0 Then $Path = _HKCU_Read("\\\" & $masset & "\\" & $b[$j][0] & "\Network\" & $b[$j][1], "RemotePath") FileWriteLine($mapFile, $b[$j][1] & "," & $Path[1][1]) EndIf Next If $iProdm <> 0 Then ExitLoop Next SplashOff() FileClose("c:\Temp\Drives\Drives.txt") EndIf Return EndFunc ;==>Drives ;===Function For Lotus Notes Child Window========================================================== Func Lotus() $ChildWin = GUICreate("", 135, 110, -1, -1, $WS_EX_TOPMOST) GUISetBkColor(0xFFFFFF) 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 $Lotus_Location = "\\" & GUICtrlRead($cnTarget) & "\c$\Program Files\Lotus\Notes\Data" Sleep(200) GUIDelete($ChildWin) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) Case $lnmsg = $Box_Multi And BitAND(GUICtrlRead($Box_Multi), $GUI_CHECKED) = $GUI_CHECKED $Lotus_Location = "\\" & GUICtrlRead($cnTarget) & "\c$" & $DOC & GUICtrlRead($prCombo) & "\Local Settings\Application Data\Lotus\Notes\Data" Sleep(200) GUIDelete($ChildWin) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) Case $lnmsg = $Box_System And BitAND(GUICtrlRead($Box_System), $GUI_CHECKED) = $GUI_CHECKED $Lotus_Location = "\\" & GUICtrlRead($cnTarget) & "\c$\Lotus\Notes\Data" Sleep(200) GUIDelete($ChildWin) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) EndSelect WEnd EndFunc ;==>Lotus Thanks everyone d@ve
-
alright, so i still cannot figure this out yet. but i do have a new idea. was wondering if the below would be possible? im thinking of having a separate click maybe in the toolbar. once clicked it will run the mapped drives function. but do the following: bring up a _GUICtrlListView of the remote users mapped drives. then have a checkbox that you can select what drive you want to map on the new system. a button that once clicked would map the drives from the gathered array that have been checked. im not sure if this is something possible, if so wow this would be great. any and all help would be so greatly appreciated, thank you so much. d@ve
-
If...ElseIf...Else...EndIf Help
surreal replied to surreal's topic in AutoIt General Help and Support
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 -
If...ElseIf...Else...EndIf Help
surreal replied to surreal's topic in AutoIt General Help and Support
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 -
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. #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
-
thx for the reply Authenticity. the issue is that the drive letter will be different per mapped drive per user. the drive letter is pulled and stored in the array. maybe this is a limitation of DriveMapAdd? d@ve
-
i myself use koda to start with, if you have installed SciTe you can launch it within autoit, tools, koda. hope this helps. d@ve
-
i have a working array that collects the current mapped drives on a remote system on the network. at this time i have the array exporting to a txt file: driveletter,servername\sharename driveletter,servername\sharename driveletter,servername\sharename i now need to install the gathered drives onto the system the script is ran from. DriveMapAdd ("driveletter:", "\\servername\sharename") i tried: $installdrive = $b[$j][1] $installpath = $path[1][1] DriveMapAdd($installdrive, $path) with no success can drivemapadd read the array or does it have to pull it from the txt file or an ini? if i need to create an ini instead of the txt file i can do that. if it can read from the array that would be even better. to be honest the most stable is what im hoping for. but beyond that on how to get this accomplished i have know clue and any help would be greatly appreciated. below is the code for the array. Func Mapped() Local $asset = GUICtrlRead($cnTarget) If BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then Local $mapLocation = $Target & $Temp & "Drives\Drives.txt" Else Local $mapLocation = $Temp2 & "Drives\Drives.txt" EndIf For $i = 1 To 25 $b = _HKCU_EnumKey("\\\" & $asset & "\Network", $i) $iProd = 1 For $j = 1 To $b[0][0] $iProd *= $b[$j][2] If $b[$j][2] = 0 Then $path = _HKCU_Read("\\\" & $asset & "\\" & $b[$j][0] & "\Network\" & $b[$j][1], "RemotePath") FileWriteLine($mapFile, $b[$j][1] & "," & $path[1][1]) EndIf Next If $iProd <> 0 Then ExitLoop Next EndFunc ;==> this is my full code if needed! #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> ;===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) GUICtrlSetState($BKItem, $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) $BoxMap = GUICtrlCreateCheckbox("Mapped Drives", 220, 25) $BoxPrinter = GUICtrlCreateCheckbox("Network Printers", 220, 45) $BoxLotus = GUICtrlCreateCheckbox("Lotus Notes", 220, 65) GUICtrlSetState($BoxMap, $GUI_CHECKED) GUICtrlSetState($BoxPrinter, $GUI_CHECKED) ;===GUI Start Function============================================================================= $StartButton = GUICtrlCreateButton("Start", 230, 100, 65, 30, $WS_GROUP) GUISetState(@SW_SHOW) $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) ;===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) EndIf $target = FileSelectFolder("Choose the location you want to back up to:", "") If $target = '' Then GUICtrlSetState($BKItem, $GUI_UNCHECKED) 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 ShellExecute($LogFile, "") 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 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() SplashTextOn("", "Working...", 165, 40, -1, -1, 2, "", 9) ;===Mapped Drives If GUICtrlRead($BoxMap) = $GUI_CHECKED Then GUICtrlSetData($cnMessage, 'Transferring: Mapped Drives') GUICtrlSetColor($cnMessage, 0x008000) If BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then DirCreate($Target & $Temp & "Drives") Mapped() Else DirCreate($Temp2 & "Drives") Mapped() DriveMapAdd ("X:", "\\wwcodcfileclst\Software") 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($Target & $Temp & "Printers") Printers() Else DirCreate($Temp2 & "Printers") Printers() 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($Target & $Temp & "Notes") FileCopy($Lotus_Location & "\*.id", $Target & $Temp & "Notes", 1) FileCopy($Lotus_Location & "\Desktop6.ndk", $Target & $Temp & "Notes", 1) FileCopy($Lotus_Location & "\Names.nsf", $Target & $Temp & "Notes", 1) FileCopy($Lotus_Location & "\User.dic", $Target & $Temp & "Notes", 1) DirCreate($Target & $Temp & "Notes\Archive") DirCopy($Lotus_Location & "\Archive", $Target & $Temp & "Notes\Archive", 1) FileWriteLine($LogFile, @CRLF & $Separator & "Lotus Notes:" & @TAB & "(Successful)" & @CRLF) Else DirCreate($Temp2 & "Notes") FileCopy($Lotus_Location & "\*.id", $Temp2 & "Notes", 1) FileCopy($Lotus_Location & "\Desktop6.ndk", $Temp2 & "Notes", 1) FileCopy($Lotus_Location & "\Names.nsf", $Temp2 & "Notes", 1) FileCopy($Lotus_Location & "\User.dic", $Temp2 & "Notes", 1) DirCreate($Temp2 & "Notes\Archive") DirCopy($Lotus_Location & "\Archive", $Temp2 & "Notes\Archive", 1) FileWriteLine($LogFile, @CRLF & $Separator & "Lotus Notes:" & @TAB & "(Network Successful)" & @CRLF) EndIf SplashOff() 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 = $Target & $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 Mapped Drives===================================================================== Func Mapped() Local $asset = GUICtrlRead($cnTarget) If BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then Local $mapLocation = $Target & $Temp & "Drives\Drives.txt" Else Local $mapLocation = $Temp2 & "Drives\Drives.txt" EndIf For $i = 1 To 25 $b = _HKCU_EnumKey("\\\" & $asset & "\Network", $i) $iProd = 1 For $j = 1 To $b[0][0] $iProd *= $b[$j][2] If $b[$j][2] = 0 Then $path = _HKCU_Read("\\\" & $asset & "\\" & $b[$j][0] & "\Network\" & $b[$j][1], "RemotePath") FileWriteLine($mapFile, $b[$j][1] & "," & $path[1][1]) EndIf Next If $iProd <> 0 Then ExitLoop Next EndFunc ;==>Mapped ;===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 update: i tried this also with no luck Func Mapped() Local $asset = GUICtrlRead($cnTarget) If BitAND(GUICtrlRead($BKItem), $GUI_CHECKED) = $GUI_CHECKED Then Local $mapLocation = $target & $Temp & "Drives\Drives.ini" Else Local $mapLocation = $Temp2 & "Drives\Drives.ini" EndIf $mapFile = FileOpen($mapLocation, 10) For $i = 1 To 25 $b = _HKCU_EnumKey("\\\" & $asset & "\Network", $i) $iProd = 1 For $j = 1 To $b[0][0] $iProd *= $b[$j][2] If $b[$j][2] = 0 Then $path = _HKCU_Read("\\\" & $asset & "\\" & $b[$j][0] & "\Network\" & $b[$j][1], "RemotePath") $inipath = $b[$j][1] & "=" & $path[1][1] IniWriteSection($mapLocation, "NetworkDrive", $inipath) EndIf Next If $iProd <> 0 Then ExitLoop Next $var = IniReadSection($mapLocation, "NetworkDrive") For $x = 1 To $var[0][0] DriveMapAdd($var[$x][0], $var[$x][1]) Next EndFunc
-
that did the trick, thank you, i will use tidy 4 now on, thanks again d@ve
-
im having a few issues with my gui that i cannot figure out. i have a splash during the ping process, incase it takes awhile the user does not think the program has hung, and keeps them from clicking connect twice. when i click on connect the splash will popup and display querying network if the correct name is entered and the ping is successful then the splash goes away and the txt will change and turn green. but: if you enter in a remote computer name that is incorrect and the ping is unsuccessful then the splash will not go away, but the txt does change. i think is has to do where i putting the code, not sure. thanks everyone for your help with this! d@ve #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> ;===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 GUICreate("", 330, 145, -1, -1) ;===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) $BoxMap = GUICtrlCreateCheckbox("Mapped Drives", 220, 25) $BoxPrinter = GUICtrlCreateCheckbox("Printers", 220, 45) $BoxWireless = GUICtrlCreateCheckbox("Wireless", 220, 65) ;===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 = $GUI_EVENT_CLOSE $Close = MsgBox(4, "", "Are you sure you want to exit?") If $Close = 6 Then GUIDelete() Exit EndIf ;===Case For Connect=============================================================================== Case $msg = $cnButton If GUICtrlRead($cnTarget) = '' Then GUICtrlSetData($cnMessage, 'Target machine must be entered') GUICtrlSetColor($cnMessage, 0xFF0000) ContinueLoop EndIf Connect() Case $msg = $StartButton StartButton() EndSelect WEnd ;===Function For Remote System InfoBox============================================================= Func Connect() Local $Separator = "------------------------------" 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 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() ;===Mapped Drives If GUICtrlRead($BoxMap) = $GUI_CHECKED Then DirCreate("c:\Temp\Migrate\Drives") Mapped() EndIf ;===Printers If GUICtrlRead($BoxPrinter) = $GUI_CHECKED Then DirCreate("c:\Temp\Migrate\Printers") Printers() EndIf ;===Wireless Settings If GUICtrlRead($BoxWireless) = $GUI_CHECKED Then DirCreate("c:\Temp\Migrate\Wireless") 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) Local $pLocation = 'c:\Temp\Migrate\Printers\Printers.txt' $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 ;==>SavePrinter ;===Function For Mapped Drives===================================================================== Func Mapped() Local $asset = GUICtrlRead($cnTarget) Local $mapLocation = 'c:\Temp\Migrate\Drives\Drives.txt' $mapFile = FileOpen($mapLocation, 10) For $i = 1 To 25 $b = _HKCU_EnumKey("\\\" & $asset & "\Network", $i) $iProd = 1 For $j = 1 To $b[0][0] $iProd *= $b[$j][2] If $b[$j][2] = 0 Then $path = _HKCU_Read("\\\" & $asset & "\\" & $b[$j][0] & "\Network\" & $b[$j][1], "RemotePath") FileWriteLine($mapFile, $b[$j][1] & "," & $path[1][1]) EndIf Next If $iProd <> 0 Then ExitLoop Next EndFunc
-
thank you so much Authenticity, thank you, thank you. that did the trick, im pretty new to arrays, learning as i go. not sure if i should start a new post but i now need to be able to use this array data from printers and mapped drivers to now install on the local machine. not sure if i need to create an ini or if i can use the array itself to do stuff like DriveMapAdd. any help in the right direction would be great. d@ve
-
Thanks for the reply Authenticity i added your change into the main code showen below but now the txt file is blank. if i remove the new code all printers are listed again. the reason i only want the network printers is once i grab this info i then want to add code to install them on the system that is running the script. thanks again for everyones help. #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> ;===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 GUICreate("", 330, 145, -1, -1) ;===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) $BoxMap = GUICtrlCreateCheckbox("Mapped Drives", 220, 25) $BoxPrinter = GUICtrlCreateCheckbox("Printers", 220, 45) $BoxWireless = GUICtrlCreateCheckbox("Wireless", 220, 65) ;===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 = $GUI_EVENT_CLOSE $Close = MsgBox(4, "", "Are you sure you want to exit?") If $Close = 6 Then GUIDelete() Exit EndIf ;===Case For Connect=============================================================================== Case $msg = $cnButton If GUICtrlRead($cnTarget) = '' Then GUICtrlSetData($cnMessage, 'Target machine must be entered') GUICtrlSetColor($cnMessage, 0xFF0000) ContinueLoop EndIf Connect() Case $msg = $StartButton StartButton() EndSelect WEnd ;===Function For Remote System InfoBox============================================================= Func Connect() Local $Separator = "------------------------------" 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 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() ;===Mapped Drives If GUICtrlRead($BoxMap) = $GUI_CHECKED Then DirCreate("c:\Temp\Migrate\Drives") Mapped() EndIf ;===Printers If GUICtrlRead($BoxPrinter) = $GUI_CHECKED Then DirCreate("c:\Temp\Migrate\Printers") Printers() EndIf ;===Wireless Settings If GUICtrlRead($BoxWireless) = $GUI_CHECKED Then DirCreate("c:\Temp\Migrate\Wireless") 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) Local $pLocation = 'c:\Temp\Migrate\Printers\Printers.txt' $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, "^\\\\(?!\\)") Then FileWriteLine($pFile, $p[$n][1] & "," & $ppath[1][1]) EndIf Next If $iProdp <> 0 Then ExitLoop Next EndFunc ;==>SavePrinter ;===Function For Mapped Drives===================================================================== Func Mapped() Local $asset = GUICtrlRead($cnTarget) Local $mapLocation = 'c:\Temp\Migrate\Drives\Drives.txt' $mapFile = FileOpen($mapLocation, 10) For $i = 1 To 25 $b = _HKCU_EnumKey("\\\" & $asset & "\Network", $i) $iProd = 1 For $j = 1 To $b[0][0] $iProd *= $b[$j][2] If $b[$j][2] = 0 Then $path = _HKCU_Read("\\\" & $asset & "\\" & $b[$j][0] & "\Network\" & $b[$j][1], "RemotePath") FileWriteLine($mapFile, $b[$j][1] & "," & $path[1][1]) EndIf Next If $iProd <> 0 Then ExitLoop Next EndFunc