I'm trying to programmatically start explorer.exe but I'm not having any luck.
This is my code:
cout << pName << "died, lets restart it." << endl;
STARTUPINFO startupInfo = {0};
startupInfo.cb = sizeof(startupInfo);
PROCESS_INFORMATION processInformation;
if(CreateProcess(pName, NULL, NULL, NULL, false, NORMAL_PRIORITY_CLASS, NULL, NULL, &startupInfo, &processInformation) == 0){
cout << "Error starting " << pName << ": " << GetLastError() << endl;
}
and pName is explorer.exe
Can someone tell me what I'm doing wrong? I get the error code '2' which is ERROR_FILE_NOT_FOUND
You can also open File Explorer from CMD, just as you can also open Windows Explorer from CMD. If you like working with Windows Terminal, Command Prompt, or PowerShell, type the command explorer in any of them and press Enter.
Explorer.exe is an executable in the Windows operating systems that is located at C:\Windows\explorer.exe. When Windows starts and a user logs in, the operating system will launch the Explorer.exe process, which displays the Windows user environment such as the desktop, taskbar, and Start Menu.
To launch File Explorer this way, press Ctrl+Shift+Esc to open Task Manager. Then, click “File” and select “Run New Task.” The “Create New Task” window will appear. Type “Explorer” in the “Open:” text box, click “OK,” and File Explorer will open.
Broadly the same as previous versions of Windows, click on file explorer, click on This PC, you'll find the C drive there. Was this reply helpful? Hi XYZ, If you click start, and type “this pc” and open it up, you should see your C drive right there.
The first parameter is the application name; the second is the command line. Try specifying "explorer.exe" as the second parameter.
See this MSDN article:
lpApplicationName [in, optional]
The name of the module to be executed. This module can be a Windows-based application. It can be some other type of module (for example, MS-DOS or OS/2) if the appropriate subsystem is available on the local computer.
The string can specify the full path and file name of the module to execute or it can specify a partial name. In the case of a partial name, the function uses the current drive and current directory to complete the specification. The function will not use the search path. This parameter must include the file name extension; no default extension is assumed.
You probably should give "ShellExecuteEx" a try. This function lets you specify a file or folder and a verb that describes what to do with it. If you use "explore
" as the verb, it will open Windows Explorer with the given folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With