Is Run command in Windows executable file?

339 Views Asked by At

Suddenly i got one thing in my mind that most of the win applications like windwos version(winver), calc and all are executable files which will be there in Windows or System32 folder.

Like that, Run Command which we are using Win+R shortcut are also executable file? is this available in anywhere in windows system folder as executable file ?

When i tried to click Open file location, it is opening Desktop. actually Where it is starting from when we click on shortcut ?

1

There are 1 best solutions below

0
On

No, it's not an exe, it's a shell dialog window that you find in the dynamic link library C:\Windows\System32\shell32.dll

You can call it from VBScript like this:

 dim objShell
 set objShell = CreateObject("shell.application")
 objShell.FileRun

From JScript like this:

var objShell = new ActiveXObject("shell.application");
objShell.FileRun();

From VB6 like this:

Private Sub fnShellFileRunVB()
    Dim objShell As Shell

    Set objShell = New Shell
    objShell.FileRun

    Set objShell = Nothing
End Sub

With modern VB.NET, this becomes:

Dim t2 As Type = Type.GetTypeFromProgID("Shell.Application")
Dim obj2 = Activator.CreateInstance(t2) ' dynamic 
obj2.FileRun()

If option strict is "ON", then the way to go is this:

Dim t As Type = Type.GetTypeFromProgID("Shell.Application")
Dim obj As Object = Activator.CreateInstance(t)
t.InvokeMember("FileRun", System.Reflection.BindingFlags.InvokeMethod, Nothing, obj, Nothing)

C# Variant:

Type t = Type.GetTypeFromProgID("Shell.Application");
object obj = Activator.CreateInstance(t);
t.InvokeMember("FileRun", System.Reflection.BindingFlags.InvokeMethod, null, obj, null);


//If the C # 4.0, the Dynamic Lookup presence of, it can be:
Type t2 = Type.GetTypeFromProgID("Shell.Application");
dynamic obj2 = Activator.CreateInstance(t2);
obj2.FileRun();

But you can also call it from a batch-file, if you want to:

C:\WINDOWS\system32\rundll32.exe shell32.dll,#61

or via the Explorer command-line:

explorer.exe Shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}