Jump to content

Recommended Posts

Posted

if RegRead("HKEY_LOCAL_MACHINE\xxxxx\xxxxxx", "") Then

ProcessWaitClose("1111.exe")

$PID = Run("1111.exe")

ProcessWaitClose($PID)

exit

else

ProcessWaitClose("2222.exe")

$PID = Run("2222.exe")

ProcessWaitClose($PID)

exit

EndIf

not 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.


Posted

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!

Posted

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.

Posted (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 by Rico.JohnnY
Posted

thx Rico.JohnnY, but not work

If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Lavasoft", "") <> "" Then

$PID = Run( @ScriptDir & '\spybot.exe' )

ProcessWaitClose($PID)

Else

$PID = Run( @ScriptDir & '\ad-aware.exe' )

ProcessWaitClose($PID)

EndIf

tested and not work.

it always executes spybot.exe exists or not that entrance of registry

solution?

thx!!!!!!!

Posted (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 key

From AutoIt help file it says "" looks at Default

RegRead("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 by smashly
Posted

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

Posted (edited)

@Alagor

Post 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 by smashly

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...