Run process (net.exe or sc.exe) with Administrator

2019-05-30 16:52发布

问题:

In the [Run] section of my script I want to run the net.exe with the parameter start MyService. The Flags are:

  • waituntilterminated
  • runhidden
  • postinstall

If the setup is run explicitly as administrator with the "Run as administrator" option, the service gets started after the user hits "Finish".

If the setup is just double clicked (PrivilegesRequired is set to admin) the service doesn't get started.

This also happens with the sc.exe

What do I have to do, so that the service gets started at the end, no matter what the user did to run the setup?

回答1:

Use the runascurrentuser flag:

If this flag is specified, the spawned process will inherit Setup/Uninstall's user credentials (typically, full administrative privileges).

This is the default behavior when the postinstall flag is not used.



标签: inno-setup