سؤال

I'm trying to run a program with another program. For this I use a class QProcess.

Program must be run with administrator privileges. To keep things simple step debugging and lead an example here, I started qt creator with privileges administator.

Now the fun part.

The following code runs the calculator.

QProcess * p = new QProcess();
p->start("C:\\Windows\\System32\\calc.exe");
p->waitForStarted();
delete p;

This code works. Now another example, which already runs the service window windows.

QProcess * p = new QProcess();
p->start("C:\\Windows\\System32\\services.msc");
p->waitForStarted();
delete p;

This code does not run the program services.msc. File exists and is run from the command line without any problems.

Why one works and the other not? How to fix?

Windows 7 x86.

هل كانت مفيدة؟

المحلول

Short answer: .msc is not an executable file type.

Long answer:

.msc is what's called a snap-in for the Microsoft Management Console.

From the command prompt or even from Start -> Run (win + R), running services.msc tells the operating system Hey, run this file with whatever program is associated with .msc files.

That program in particular is called mmc.exe, and even when run services.msc from the command prompt and look in the Task Manager, you'll see the window actually belongs to services.exe.

Try to start either mmc.exe services.msc or cmd.exe /C services.msc instead.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top