Alagor Posted October 22, 2006 Share Posted October 22, 2006 if RegRead("HKEY_LOCAL_MACHINE\xxxxx\xxxxxx", "") ThenProcessWaitClose("1111.exe")$PID = Run("1111.exe")ProcessWaitClose($PID)exitelseProcessWaitClose("2222.exe")$PID = Run("2222.exe")ProcessWaitClose($PID)exitEndIfnot work As I verify if a key in the registry exists? because desire to do scrip that it verifies if an entrance in the registry exists and if it exists executes an application and if it does not exist it executes another one.pardon by my ingles, but I do not speak ingles. Link to comment Share on other sites More sharing options...
Rico.JohnnY Posted October 22, 2006 Share Posted October 22, 2006 if RegRead("HKEY_LOCAL_MACHINE\xxxxx\xxxxxx", "") <> "" Thentry this.. Link to comment Share on other sites More sharing options...
Alagor Posted October 22, 2006 Author Share Posted October 22, 2006 thanks to answer, but do not work my scrip fails in which always "11111.exe" executes the application, exists or not entered it the registry. it never executes "2222.exe" I want that it verifies if an entrance in the registry exists, and if it exists it executes an application and if it does not exist it executes another one.thank you very much! Link to comment Share on other sites More sharing options...
Rico.JohnnY Posted October 22, 2006 Share Posted October 22, 2006 The format for the script seems ok... so the problem may be caused by the registry itself...If you want 2222.exe to be executed, make sure that the default value for "HKEY_LOCAL_MACHINE\xxxxx\xxxxxx" is empty..or you can try to delete the value and try again..BTW, you'd better remove the two lines of "exit", it's redundant. Link to comment Share on other sites More sharing options...
Alagor Posted October 22, 2006 Author Share Posted October 22, 2006 thanks but with scrip that has put do not execute anything Link to comment Share on other sites More sharing options...
Rico.JohnnY Posted October 22, 2006 Share Posted October 22, 2006 (edited) I am 100% sure that your error was caused by the RegRead("HKEY_LOCAL_MACHINE\xxxxx\xxxxxx", "")Maybe you mixed up the "key name" and the "value name", export the value from the registry and paste it on the post, let me see if you made a mistake...Just curious, why did you add a line of "ProcessWaitClose("xxxx.exe")" before each run ? They were already running where you ran the script?Maybe the following code was better. If RegRead('HKEY_LOCAL_MACHINE\xxxxx\xxxxxx', '') <> '' Then $PID = Run( @ScriptDir & '\1111.exe' ) ProcessWaitClose($PID)Else $PID = Run( @ScriptDir & '\2222.exe' ) ProcessWaitClose($PID)EndIf Edited October 22, 2006 by Rico.JohnnY Link to comment Share on other sites More sharing options...
Alagor Posted October 23, 2006 Author Share Posted October 23, 2006 thx Rico.JohnnY, but not workIf RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Lavasoft", "") <> "" Then$PID = Run( @ScriptDir & '\spybot.exe' )ProcessWaitClose($PID)Else$PID = Run( @ScriptDir & '\ad-aware.exe' )ProcessWaitClose($PID)EndIftested and not work.it always executes spybot.exe exists or not that entrance of registrysolution?thx!!!!!!! Link to comment Share on other sites More sharing options...
smashly Posted October 23, 2006 Share Posted October 23, 2006 (edited) RegRead("HKEY_LOCAL_MACHINE\xxxxx\xxxxxx", "") When you look in the registry you see:Default REG_SZ (Value Not Set) <--- This is looking at Default value under the xxxxxx keyFrom AutoIt help file it says "" looks at DefaultRegRead("HKEY_LOCAL_MACHINE\xxxxx\xxxxxx", "222") .When you look in the registry you see:Default REG_SZ (Value Not Set)222 REG_SZ C:\Whateverpath\222.exe <--- This is looking at the value of 222 under the key. Edited October 23, 2006 by smashly Link to comment Share on other sites More sharing options...
Alagor Posted October 23, 2006 Author Share Posted October 23, 2006 it pardons smashly, but I do not understand it, to put scrip of example? thank you very much Link to comment Share on other sites More sharing options...
MHz Posted October 23, 2006 Share Posted October 23, 2006 Check the @error macro. If it errors then it does not exist or it is unable to read.RegRead("HKLM\SOFTWARE\Lavasoft", "")If Not @error Then RunWait('"' & @ScriptDir & '\spybot.exe" /verysilent')Else RunWait('"' & @ScriptDir & '\ad-aware.exe" /s')EndIf Link to comment Share on other sites More sharing options...
smashly Posted October 23, 2006 Share Posted October 23, 2006 (edited) @AlagorPost the registry entries for the 2 programs you want to use in the script.Not XXXX ... The full path/filename of the 2 exe in the Registry.RegRead("HKEY_LOCAL_MACHINE\xxxxx\xxxxxx", "") <--- This does not point at your either of the exe you want to launch. This points at the value Default = (value not set)When your script runs and reads the registry it will return and empty string! in other words 0.Even if there are other values under the key. It will return an empty sting! in other words 0.Even If you have other values in the key it will return and Empty String ! in other words 0.(I'm assuming your using AutoIT , since it's the same post in the AutoIt forum) Edited October 23, 2006 by smashly 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