Jump to content

RunOnceEX With System Variables


MtK

Recommended Posts

Hi,

I'm using RunOnceEx to install my apps, & i'm using it with self-created variables (done with SetEnv & tested to work)

I have a batch file that looks something like this:

SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx

REG ADD %KEY% /V TITLE /D "Installing Applications" /f

REG ADD %KEY%\000 /VE /D "Testing" /f
REG ADD %KEY%\001 /V 1 /D "%%Install%%\app.exe" /f

The "%%" will make it look like "%" in the REGISTRY, so it executes:

%Install%\App.exe

during login the RunOnceEx starts normally but I recieve an error saying the application cannot be found...

as said before %Install% is set, & points correctly to the needed folder...

what could it be?

Link to comment
Share on other sites


i always thought system variables are expanded in the registry but...

The "%%" will make it look like "%"

... i'll suppose your registry entry looks like "%Install%\App.exe", the variable %install% it's defined during the runonceex importing process, but what about after reboot?

i think i'm not explaining too well, after the reboot, when runonce process it's started, it finds a "%install%" entry but it isn't defined bcuz after the reboot, you haven't stablish it :unsure:

Link to comment
Share on other sites

That's quite strange. I'm creating a brand new preload right now and haven't tested it yet, but made it with variables in regfiles.

When I import the reg file as seen below here it works fine, although not in the preinstallation, but just on a already installed windows system. Shouldn't make a difference though.

@ECHO OFF

SET SLEUTEL=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx
SET SCRIPT=%systemdrive%\source\script
SET PROGS=%systemdrive%\source\progs

REG ADD %SLEUTEL% /V TITLE /D "Hello" /f

REG ADD %SLEUTEL%\001 /VE /D "Bezig met voorbereiden..." /f
REG ADD %SLEUTEL%\001 /V 1 /D "%SCRIPT%\start.cmd" /f

REG ADD %SLEUTEL%\010 /VE /D "Adobe Reader 6.0.1" /f
REG ADD %SLEUTEL%\010 /V 1 /D "%PROGS%\AdobeReader\AR601NL.msi /QB" /f

Works for me.

Greetz

Link to comment
Share on other sites

as said before %Install% is set, & points correctly to the needed folder...

Like SiMoNsAyS says (heh), the set= is gone when you reboot. If you don't re-set it then it will not fine the %Install% for sure. If you missed this thing you can make a .cmd at first RunOnceEx stage, although you can not point this to %Install%\re-set.cmd for example.

Thats all what I can think about of at the moment. Good luck with finding a solution :)

Link to comment
Share on other sites

In most registry keys, to get this to work you would make it a REG_EXPAND_SZ, but runonceex does not support the REG_EXPAND_SZ type variables. So they will get skipped if it sees the %INSTALL% variable.

Unfortunately this is no way around this. You could always try adding cmd /c infront of every entry so that it re-routes through cmd thus giving you the variable. Not to sure how that would reacte though, so its YMMV.

Link to comment
Share on other sites

Hi,

if it was not understood, i'm talking about the first boot the machine does (RunOnceEx)

the variables are set at first commands:

REG ADD %KEY%\000 /V 1 /D "SetEnv /u Install C:\Install" /f

but the command that comes after that (during the same first-boot):

REG ADD %KEY%\000 /V 2 /D "%%Install%%\app.exe" /f

does not run, because it can't find %Install%\app.exe (which exists)

(I checked after boot is done & the varable is still set OK...)

Link to comment
Share on other sites

Hi,

if it was not understood, i'm talking about the first boot the machine does (RunOnceEx)

the variables are set at first commands:

REG ADD %KEY%\000 /V 1 /D "SetEnv /u Install C:\Install" /f

but the command that comes after that (during the same first-boot):

REG ADD %KEY%\000 /V 2 /D "%%Install%%\app.exe" /f

does not run, because it can't find %Install%\app.exe (which exists)

(I checked after boot is done & the varable is still set OK...)

If you read my post again, then you can not use %INSTALL% in RunOnceEx.

I'll re-explain here. The customary way to get system variables to work in the registry is by making them REG_EXPAND_SZ. So when it sees your variable %INSTALL%, it understands it is C:\install. THAT IS THE ONLY WAY. However, RunOnceEx does not support REG_EXPAND_SZ keys with variables in them. This is why this isn't working.

The only way to get it to work is by routing it through cmd, by either using cmd /c, or a batch file. What you want to do does not exist.

If my explaination is to much for you, tell me what you don't understand.

Link to comment
Share on other sites

The way you make the variable looks fine. I don't use setenv, but I'm sure you have the syntax correct. Your problem is how you use it later, after setting it. Windows won't recognize it. It has to be done like everyone else does it, before you put it in the registry.

Link to comment
Share on other sites

The variables exist as soon as you log in.

The following should work

REG ADD %KEY%\000 /V 2 /D "cmd.exe /c %%Install%%\app.exe" /f

This wouldn't however

REG ADD %KEY%\000 /V 2 /D "%%Install%%\app.exe" /f

This is because cmd.exe will interpret the variable, while runonceex won't.

Note: I didn't test the cmd.exe way, but it should work in theory.

Link to comment
Share on other sites

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