windowsseleniumregistrydosdoskey

How to add several values for a single key in Windows Registry


I'm trying to add an entry for AutoRun with value doskey selenium=java -jar C:\dev\selenium-server-standalone-2.45.0.jar to HKEY_CURRENT_USER\Software\Microsoft\Command Processor. However the AutoRun key has already a value (if %ANSICON_VER%==^%ANSICON_VER^% "C:\dev\ansi166\x64\ansicon" -p)

How can I solve this ?


Solution

  • The AutoRun value is the command line to run. You could simply append another command using the & operator. For example:

    (if %ANSICON_VER%==^%ANSICON_VER^% "C:\dev\ansi166\x64\ansicon" -p) & (doskey selenium=java -jar C:\dev\selenium-server-standalone-2.45.0.jar)
    

    Or replace the command with your own batch file, e.g. ("%LocalAppData%\autorun.cmd").

    Bear in mind that most system implementations (including Microsoft's) for some reason don't use the /D option to disable AutoRun commands; they just run a command using %ComSpec% /c. You can check/set a guard environment variable to avoid running doskey multiple times.