Everyone knows the Run window that you can open with the shortcut Windows+R or directly in the Windows menu then Run.
I'm wondering how to open this Run window programmatically.
This window seems to be part of explorer.exe.
Does anyone have an idea on it ?
How to open the Run window programmatically
Asked Answered
Why would you want to open the Run window? Can't you execute the programs directly instead of going trough the run command? or am i missing something here? I did try to locate if it were in a separate .exe or something like that, but as you say it seems to be a part of explorer.exe. Have you considered using cmd.exe? –
Grieve
First of all, re-read the question; they never said anything about running anything, they simply asked about programmatically opening the Run dialog. Second, the Run dialog has options (check-boxes) to alter how the program/file is run that may not be easy, if at all possible to accomplish using whatever language they are using. –
Supernormal
You can use IShellDispatch::FileRun
to achieve this.
See Using the Windows RunFile dialog - The documented and undocumented way for details and sample code.
FYI, in Windows 10/11 (havn't checked 8.x) you can open the Run dialog easily by calling:
explorer shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}
E.g. in a batch script:
start explorer shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}
... and in pwsh
with quotes:
explorer "shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}"
This works if run from
cmd.exe
, but if I run from PowerShell, it opens Explorer with my 'Documents' folder focused. –
Blackfish @Blackfish You are right, that's really weird. But the following command also works in PowerShell - the quotes are crucial! explorer "shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}" –
Xerosis
If you mean that it could open say at 8:00 am, then you can use autohotkey and simply write
and then compile it as an .exe and put it as a cron jobSendInput {Raw}{Lwin}{R}
And what if the Win key combos are disabled? –
Supernormal
Not least of which, autohotkey introduces a whole slew of other issues, including security vulnerabilities –
Galvani
In PowerShell:
(New-Object -ComObject "Shell.Application").FileRun()
This does have the effect of flashing the PowerShell window for a moment, however
Or alternatively with
explorer "shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}"
Using Windows Command (cmd.exe
):
cmd /c 'explorer.exe Shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}'
© 2022 - 2024 — McMap. All rights reserved.