Jump to content

Recommended Posts

Posted

Hey folks,

I'm trying to run a .bat file from the RunOnce key in the registry but it never seems to execute. Quite simply, nothing happens! In contrast, a .exe will open fine. Is it the case that .bat files cannot be run from the registry or is something more sinister wrong? I did once have the suspicion that it was to do with my path being slightly broken (some program went mad and added itself many times pushing out other items) but I am not sure.

I'm on Windows XP Pro.

Cheers for any help,

Neil


Posted

OK, cheers. The keys are added by executing a .reg file which adds them. I've verified that they're added, but no restart, nowt happens. ;)

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce]
"SetupEnv"="%AUTOTESTDIR%\\WindowsInstallerFiles\\RunWindowsInstallEnv.bat"
"RunSanityTest"="%AUTOTESTDIR%\\RunWindowsSanityTest.bat"

AutoTestDir is a System Environment variable pointing to the path of the .bat file.

I had also tried getting cmd.exe to execute the commands but no luck there either.

"SetupEnv"="\"%WinDir%\\system32\\cmd.exe\" /c \"%AUTOTESTDIR%\\WindowsInstallerFiles\\RunWindowsInstallEnv.bat\""
"RunSanityTest"="\"%WinDir%\\system32\\cmd.exe\" /c \"%AUTOTESTDIR%\\RunWindowsSanityTest.bat\""

Thanks!

Neil

Posted

It's the variables that are causing the problem. You can't use them in RunOnce unless you use an expandable String Value. Another option would be to add those entries from a batch file:

SET KEY=HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce

REG ADD %KEY% /V SetupEnv /D "\"%AUTOTESTDIR%\WindowsInstallerFiles\RunWindowsInstallEnv.bat\"" /f
REG ADD %KEY% /V RunSanityTest /D "\"%AUTOTESTDIR%\RunWindowsSanityTest.bat\"" /f

The variables will be resolved when the batch executes and will not end up in the RunOnce Values.

The extra quotes (\") are only necessary if the path\filename in the value contains spaces. In this case, that would depend on whether %AUTOTESTDIR% contains spaces when resolved.

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