Pringlis Posted August 16, 2004 Posted August 16, 2004 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
mazin Posted August 16, 2004 Posted August 16, 2004 It should run properly. Just post your strings, there might be mistakes.
Pringlis Posted August 16, 2004 Author Posted August 16, 2004 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
jrzycrim Posted August 16, 2004 Posted August 16, 2004 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\RunOnceREG ADD %KEY% /V SetupEnv /D "\"%AUTOTESTDIR%\WindowsInstallerFiles\RunWindowsInstallEnv.bat\"" /fREG ADD %KEY% /V RunSanityTest /D "\"%AUTOTESTDIR%\RunWindowsSanityTest.bat\"" /fThe 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.
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