Reputation: 779
EDIT: Tried this:
C:\WINDOWS\system32>runas /user:gabs-pc\gabs-pc "J:\TI\...\Editor_PDF\editor_pdf.exe"
Got this error: "The system could not fin the specified file."
Pretty hard to expose my problem on the topic title...
Well... I have a .exe file that I want to run, this file is in a shared hard drive through a local network called J:\.
If I open my cmd prompt as a normal user in a given path and I try to execute the .exe file using, for example:
"J:\TI\Estágio\gabriel\Editor de PDF\Editor PDF\editor_pdf.exe" param1 param2 param3
It works fine. But when I try to run the exact same file, from the same computer opening the cmd prompt as an Administrator I get the following error:
'"J:\TI...\Editor PDF\editor_pdf.exe"' is not recognized as an internal or external command, an operable program or a batch file.
I would like to know how to execute that file as an administrator OR a single-line workaround to run that file as the current/normal user.
Comments.: If some of you are asking yourselves "why don't you just open cmd as a normal user?". I'm trying to call this program from another program which can only run cmd as an Administrator, that's why.
Upvotes: 0
Views: 261
Reputation: 711
You need to convert network drive path into its real UNC path first. As @RbMm says, network drive is a per-use configuration.
If you stick to cmd
, you may use wmic path win32_mappedlogicaldisk get DeviceID, ProviderName
to retrieve the real path of target.
You may also use Winapi WNetGetConnection
to retrieve the path of drive.
The process should NOT be done in Administrator context. If you cannot, you need to use CreateProcessAsUser
to retrieve information from another user's perspective.
Pseudo code:
char path[260] = {0};
WNetGetConncetion ("J:", path, 260);
WinExec ("\"" + path + "\\TI\\Estágio\\gabriel\\Editor de PDF\\Editor PDF\\editor_pdf.exe"
+ "\" " + param1 + " " + param2 + " " + param3, SW_HIDE);
Additional information:
Upvotes: 1