Search code examples
windowscommand-promptspecial-folders

Execute Windows run dialog command in command prompt


In the Windows Run dialog, I can use the command shell:startup to open the user's startup folder.

In hope to be able to use the command in the Windows command line, I tried typing shell in the command prompt, but returned with the error message

'shell' is not recognized as an internal or external command,
operable program or batch file.

How can I execute such run line commands in the command prompt?


Solution

  • The run dialog accepts not only a command but also a URL/URI or any real paths, as you can see from its description:

    Run dialog

    That's why when you open shell:startup which is a special path (specified in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\FolderDescriptions) it works normally

    However in Windows cmd or PowerShell the command must be an executable file, a script file or any other files with a registered type. It won't accept a folder. To work around that use either of the following

    start shell:startup
    explorer shell:startup
    

    If the path contains spaces then in cmd you must add another empty parameter due to the legacy issues in cmd.exe

    start "" "shell:common startup"
    

    If you use PowerShell then start "shell:common startup" will work normally because start is an alias to Start-Process in PowerShell. If you run explorer then you don't need that empty string either