Search code examples
windowscmdregistry

Run on windows startup CMD with arguments


I need to run cmd with arguments on windows startup. Is it possible to this do via a registry key?

I am trying:

"parameter"="\"C:\\Windows\\System32\\cmd.exe\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\parameter]

But how can I add arguments to it, if that's possible?

I made this simple task C:\Windows\System32\cmd.exe /c notepad.exe but is doesn't work. What can be the reason?

Am I be missing something? I have made two records

HKLM / RUN/ "C:\Windows\System32\cmd.exe /c notepad.exe"
HKEY_CURRENT_USER/ RUN "C:\Windows\System32\cmd.exe /c notepad.exe"

`

The command doesn't start notepad.


Solution

  • Your example has the lines in the wrong order for a *.reg file. The following should work:

    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce]
    "Terminal"="C:\\Windows\\system32\\cmd.exe /c parameter1 parameter2 parameter3 ..."
    

    This will only run once on bootup. If you want to run every time you log in, then you need to change it to:

    Windows Registry Editor Version 5.00
    
    [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
    "Terminal"="C:\\Windows\\system32\\cmd.exe /c parameter1 parameter2 parameter3 ..."