Tinywoods Posted March 4, 2006 Share Posted March 4, 2006 (edited) Hello I made a script that export a part of registry and replace a phrase with another phrase. However, I really do NOT want to see any window during a script runs. I really want to do it in silent. The reg file is about 135KB. Is there any better way to do that? I don't use an English OS, so some of widows' name maybe wrong in the below my script. (I might mistake when I translate it to post the forum.) :"> expandcollapse popup#include <Process.au3> ; Export a part of Reg $rc = _RunDos("REG EXPORT HKEY_CLASSES_ROOT\Installer\Products C:\WPI\NEROREG.reg") $handle = "C:\WPI\NEROREG.reg" $rename = "C:\WPI\NEROREG.txt" $old = "Nero 7 Demo" $new = "Nero 7.0.5.4 Premium Edition (demo)" ; Make a copied txt file of the reg file If FileExists($handle) Then FileCopy($handle, $rename, 1) EndIf Sleep(2000) ; Replace a phrase in the txt If FileExists($rename) Then Run("notepad.exe C:\WPI\NEROREG.txt") WinWait("NEROREG.txt - Notepad") Sleep(5000) Send("!e") Sleep(2000) Send("{R}") Sleep(5000) ControlSend("Replace", "", "Edit1", $old) Sleep(2000) ControlSend("Replace", "", "Edit2", $new) Sleep(2000) ControlClick("Replace", "", "Button5") Sleep(2000) ControlClick("Replace", "", "Button6") Sleep(2000) Send("^s") EndIf Sleep(2000) WinClose("NEROREG.txt - Notepad") Sleep(2000) ; Make a copied reg file of the txt file FileCopy($rename, $handle, 1) Sleep(2000) ; Import the modified new Reg _RunDos("Regedit /s C:\WPI\NEROREG.reg") Edited March 4, 2006 by Tinywoods Link to comment Share on other sites More sharing options...
BigDod Posted March 4, 2006 Share Posted March 4, 2006 Why not just use RegRead to check what is in the key and RegWrite to change it if it is not what you want. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Tinywoods Posted March 4, 2006 Author Share Posted March 4, 2006 (edited) Hi BigDod,Thank you for your response. Yes, I agree with you to use Regread. I did not mention that the script will be used in WPI (Windows XP Post Install Wizard). In registry, HKEY_CLASSES_ROOT\Installer\Products\XXXXXXXXX."\XXXXXXXXX" is not fixed data and it is always changing installation by installation. Therefore, it was difficult for me to use Regread or RegEnumKey. In this case, I want to change below part.Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Installer\Products\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX] "ProductName"="Nero 7 Demo"I'd like to have the below Reg.[HKEY_CLASSES_ROOT\Installer\Products\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX] "ProductName"=" Nero 7.0.5.4 Premium Edition (demo)" Edited March 4, 2006 by Tinywoods Link to comment Share on other sites More sharing options...
MHz Posted March 4, 2006 Share Posted March 4, 2006 (edited) Hey Tinywoods, This should do it for you $key = 'HKCR\Installer\Products' $valuename = 'ProductName' For $i = 1 To 1000 $subkey = RegEnumKey($key, $i) If @error Then ExitLoop $data = RegRead($key & '\' & $subkey, $valuename) If Not @error Then If $data = 'Nero 7 Demo' Then $data = 'Nero 7.0.5.4 Premium Edition (demo)' RegWrite($key & '\' & $subkey, 'Reg_sz', $data) ExitLoop EndIf EndIf Next Edited March 4, 2006 by MHz Link to comment Share on other sites More sharing options...
Tinywoods Posted March 4, 2006 Author Share Posted March 4, 2006 (edited) Hello MHz, Thank you agin and again. Nice ! it works !! I just needed to add $valuename in a line of RegWrite. Then, it became perfect. Your WPI.au3 (To find out the correct WPI.hta from CD-Drives) that you provided me still works fine, too. I'm NOT still good at "LOOP" commands, sorry. Edited March 4, 2006 by Tinywoods 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