mr-es335 Posted September 23 Share Posted September 23 (edited) Good day, I have managed - with great difficulty, in employing variables with Arrays. A couple of "things"... expandcollapse popup; ------------------------------------------------ #include <FileConstants.au3> ; ------------------------------------------------ Opt("MustDeclareVars", 1) ; ------------------------------------------------- _ExportRegKeys() ; ------------------------------------------------- Func _ExportRegKeys() ; Source data Local $_sRegKey[3] = [2] $_sRegKey[1] = "HKEY_CURRENT_USER\Software\Native Instruments" $_sRegKey[2] = "HKEY_LOCAL_MACHINE\Software\Native Instruments" ; ----------------- ; Destination data Local $_RegFile[3] = [2] $_RegFile[1] = "D:\Install\App_Config\Digital_Audio\2_GR5\Data\Reg_Keys\hkcu.reg" $_RegFile[2] = "D:\Install\App_Config\Digital_Audio\2_GR5\Data\Reg_Keys\hklm.reg" ; ------------------------------------------------- Local $sMessage = "Export Registry Keys data..." & @CRLF & @CRLF ; ------------------------------------------------- For $i = 1 To $_RegFile[0] Local $Result = ShellExecuteWait('REG', 'EXPORT " ' & $_sRegKey[$i] & '" ' & $_RegFile[$i] & '') Switch $Result Case 0 $Result = "The Registry Keys data...[" & $_RegFile[$i] & "]...was exported sucessfully!" Case 1 $Result = "The Registry Keys data...[" & $_RegFile[$i] & "]...was not exported sucessfully!" EndSwitch ; ----------------- $sMessage &= $Result & @CRLF Next ; ----------------------------------------------- $sMessage &= @CRLF & "Export Registry Keys completed..." & @CRLF ; ----------------------------------------------- SplashTextOn("NOTICE!!", $sMessage, 1050, 170, -1, -1, 4, "FuturaBQ-DemiBold", 14) Sleep(3000) SplashOff() EndFunc ;==>_ExportRegKeys ; ------------------------------------------------- Thing #1: How can the addition of "& '" /Y')" be employed in the above with the "ShellExecuteWrite" command? • I have attempted numerous insertion points with no success! Thing #2: Is the above script "sound"? Thank you for any assistance that one may provide. Edited September 23 by mr-es335 More claficiation required. mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
Marc Posted September 23 Share Posted September 23 Hi, mr-es335, to #1: I like to see the created command, so I extracted the parameters in a separate variable and wrote it to console. Makes it more visible to see what actually happens. Works quite fine this way. even with /y: Local $tmp = 'EXPORT "' & $_sRegKey[$i] & '" "' & $_RegFile[$i] & '" /Y' Local $Result = ShellExecuteWait('REG', $tmp) ConsoleWrite($tmp & @CRLF) to #2: Looks quite stable to me. best regards, Marc Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to comment Share on other sites More sharing options...
mr-es335 Posted September 23 Author Share Posted September 23 Marc, Thanks for the reply...appreciated...However the above example does not really help me at all. I simply want to changes this: ;reg export <keyname> <filename> [/y] ShellExecuteWait(REG, EXPORT "HKEY_CURRENT_USER\Software\Native Instruments" "E:\Desktop\Test\test.reg" /y) ...to this... Local $_Keyname = "HKEY_CURRENT_USER\Software\Native Instruments" Local $_DstFile = "E:\Desktop\Test\hkcu.reg" ;reg export <keyname> <filename> [/y] ShellExecuteWait(REG, EXPORT $_Keyname $_DstFile /y) mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
Solution Marc Posted September 23 Solution Share Posted September 23 (edited) If I'm not mistaken, that's just what the code does... If you replace the line Local $Result = ShellExecuteWait('REG', 'EXPORT " ' & $_sRegKey[$i] & '" ' & $_RegFile[$i] & '') with my code, you'll get: expandcollapse popup; ------------------------------------------------ #include <FileConstants.au3> ; ------------------------------------------------ Opt("MustDeclareVars", 1) ; ------------------------------------------------- _ExportRegKeys() ; ------------------------------------------------- Func _ExportRegKeys() ; Source data Local $_sRegKey[3] = [2] $_sRegKey[1] = "HKEY_CURRENT_USER\Software\Native Instruments" $_sRegKey[2] = "HKEY_LOCAL_MACHINE\Software\Native Instruments" ; ----------------- ; Destination data Local $_RegFile[3] = [2] $_RegFile[1] = "D:\Install\App_Config\Digital_Audio\2_GR5\Data\Reg_Keys\hkcu.reg" $_RegFile[2] = "D:\Install\App_Config\Digital_Audio\2_GR5\Data\Reg_Keys\hklm.reg" ; ------------------------------------------------- Local $sMessage = "Export Registry Keys data..." & @CRLF & @CRLF ; ------------------------------------------------- For $i = 1 To $_RegFile[0] Local $tmp = 'EXPORT "' & $_sRegKey[$i] & '" "' & $_RegFile[$i] & '" /Y' Local $Result = ShellExecuteWait('REG', $tmp) ConsoleWrite($tmp & @CRLF) Switch $Result Case 0 $Result = "The Registry Keys data...[" & $_RegFile[$i] & "]...was exported sucessfully!" Case 1 $Result = "The Registry Keys data...[" & $_RegFile[$i] & "]...was not exported sucessfully!" EndSwitch ; ----------------- $sMessage &= $Result & @CRLF Next ; ----------------------------------------------- $sMessage &= @CRLF & "Export Registry Keys completed..." & @CRLF ; ----------------------------------------------- SplashTextOn("NOTICE!!", $sMessage, 1050, 170, -1, -1, 4, "FuturaBQ-DemiBold", 14) Sleep(3000) SplashOff() EndFunc ;==>_ExportRegKeys ; ------------------------------------------------- and it seems to work fine. It displays the "successfully" message and two .reg files are created at the given location. And it uses the /y because it overwrites the files without asking if they are already there. ¯\_(ツ)_/¯ best regards, Marc Edited September 23 by Marc mr-es335 1 Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to comment Share on other sites More sharing options...
mr-es335 Posted September 23 Author Share Posted September 23 (edited) Marc, Okay! This is great! works as expected!! However, may I ask where you gleaned the information to know precisely how to format the syntax? ; Mine...works, but asks for confirmation to overwrite the exisiting data. ShellExecuteWait('REG', 'EXPORT " ' & $_sRegKey[$i] & '" ' & $_RegFile[$i] & '') ; Your...works, and does not asks for confirmation to overwrite the exisiting data. ShellExecuteWait('REG', 'EXPORT "' & $_sRegKey[$i] & '" "' & $_RegFile[$i] & '" /Y') Comparing the syntax I found with yours Edited September 23 by mr-es335 mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
Marc Posted September 23 Share Posted September 23 Well I just thought „how should the command look like if entered on the command line“ and came tobte conclusion of „out every Parameter in „“ and to be sure it is correct I added the consolewrite to see the result🙃 Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now