PDA

View Full Version : Help with Registry.SetValue and Session Variables


WarrenW
03-23-2005, 04:10 PM
Hello,

I am trying to use the %AppPath% value in the registry because I want to add my program to the registry startup for Windows. I contacted support and they gave me the following result but the value for %AppPath% was not there.

The following lines was placed in the On Post Install because I assume the session var would be set already:


AppPath = SessionVar.Expand("%AppPath%");
Registry.SetValue(HKEY_LOCAL_MACHINE, "software\\microsoft\\Windows\\CurrentVersion\\Run", "MyProgram", AppPath.."\\services.exe", REG_SZ);


When I run the install and look in the registry, the value for this is:

%AppPath%\services.exe

The %AppPath% variable was never filled in.

Can anyone help? I would GREATLY appreciate it!

Thanks

Jason Pate
03-23-2005, 04:56 PM
Codes looks right, is this on the POST Install event?

csd214
03-23-2005, 11:15 PM
i) Correct syntax (as far as I can see)
ii) The code is in the right place (after the install procedure)

So far, so good, but your resulting registry entry is %AppPath%\services.exe. That means there is no value assigned to %AppPath%. In a case like this, I would have used the debug function.

AppPath = SessionVar.Expand("%AppPath%");
Debug.ShowWindow(true);
Debug.Print("The registry valus is: "..AppPath.."\\services.exe".."\r\n");
-- Registry.SetValue(HKEY_LOCAL_MACHINE, "software\\microsoft\\Windows\\CurrentVersion\\Run", "MyProgram", AppPath.."\\services.exe", REG_SZ);

(Or 2) use a dialog message or 3) write to the setup log).

Check the variable list (Ctrl-B). I don't think you have %AppPath%. The default variable is %AppFolder%. Change the variable name and you will have success.

WarrenW
03-24-2005, 06:03 AM
I just looked and your right - it is AppFolder. This has been driving me crazy for over a day!

Thanks alot everyone!

Warren