Trouble launching windows command
-
@damre22 said in Trouble launching windows command:
I also tried using the absolute path for uwfmgr: "C:/WINDOWS/System32/uwfmgr.exe"
Where is the code snipped for this try?
Don't know why you would need cmd.exe or simliar when you want to run an executable. -
I tried without the cmd but the result is the same:
QProcess process; process.setWorkingDirectory("C:\\Windows\\System32"); process.start("uwfmgr.exe", QStringList{ "volume", "protect", "C:" }); process.waitForFinished(10000);
process.errorString() contains: "Process failed to start: The system cannot find the file specified"
same as the other tries. I checked again the executable and is in: C:/Windows/System32/uwfmgr.exe -
Hi
I think its a rights issue.
if you look here
https://docs.microsoft.com/en-us/windows-hardware/customize/enterprise/uwfmgrexeit says it needs an administrator account to change anything.
so unless you app has the rights, already, i dont think its allowed.
-
Yes i'm using an administrator account and the application is launched with administrator privileges, all the tests above have been executed with this configuration
-
Yes it works with an administrator command prompt, exactly. I just edited the post because I found this
https://stackoverflow.com/questions/25457225/qprocess-always-returns-2-when-running-a-valid-command
My application is compiled with 32-bit QtFramework, could this be the issue? -
Yes it works with an administrator command prompt, exactly. I just edited the post because I found this
https://stackoverflow.com/questions/25457225/qprocess-always-returns-2-when-running-a-valid-command
My application is compiled with 32-bit QtFramework, could this be the issue?@damre22
Hi
Im not aware of any issues calling other .exe with QProcess and 32/64 issues.
Should not matter.
However, if the location does in fact differ between 32/64, then yes.
The 32 bit app simply dont see the .exe in that location.I would try test it
qDebug() << "file there" << QFile::exists(""C:/WINDOWS/System32/uwfmgr.exe"); -
QFile::exists(""C:/WINDOWS/System32/uwfmgr.exe") returns false. So I need to create a 64bit executable or find the real location of the 32bit one?
-
Found it! I read this article: https://www.samlogic.net/articles/sysnative-folder-64-bit-windows.htm
And just for summarizing it: I discovered that when you're running a 32bit application on a 64bit version of windows all the 64bit executables are accessible from %windir%/sysnative instead of %windir%/System32
Questionable design choice but everyone has their reason.
This is the snippet of the working code:QProcess process; //process.setWorkingDirectory("C:/Windows/Sysnative"); process.start("C:/Windows/Sysnative/uwfmgr.exe", QStringList{"volume", "protect", "C:"}); process.waitForFinished(10000); logInfo("std:"+process.readAllStandardOutput()); logInfo(QFile::exists(R"(C:\Windows\Sysnative\uwfmgr.exe)")?"uwfExists":"uwfNotExists");
Thank for the support and patience!