coolguy123
coolguy123

Reputation: 97

Create Service/Task with an MSI

I want to package programs into an MSI and create Scheduled Tasks (i.e. run on Boot/Startup).

I'm trying solutions available on the market such as Advanced Installer and EMCO MSI Packager, but I get the same error in both:

Verify that you have sufficient privileges to start system services

This means my account does not have the "Login as a service" privilege. However, looking up solutions, you'll find that Advanced Installer offers little help.

Basically, they suggest either (1) hardcoding user credentials, which is obviously unviable or (2) creating a new user with the required privileges, also unviable.

I've created tasks before in plain C++ and it was very easy, a simple

system("schtasks [args]")

Was enough to create tasks, and as long as the program was running after a UAC prompt was accepted, the tasks were successfully created.

So what exactly is the aforementioned error, and how can I fix it, preferably with a solution from the market (it is cleaner than having to manually make a setup.exe, ask for privileges, manually make tasks).

Edit: Any answers that provide some clarity on creating Scheduled Tasks that automatically run elevated (i.e. have access to Program Files, etc) are greatly appreciated.

Edit 2: Setting user to LocalService did not work.

enter image description here

Upvotes: 1

Views: 627

Answers (1)

Christopher Painter
Christopher Painter

Reputation: 55601

Verify that you have sufficient privileges to start system services is a red herring. It's a generic error message from MSI saying it couldn't start the service. There's a bakers dozen reasons (that I've answered on here: Error 1920 service failed to start. Verify that you have sufficient privileges to start system services )

Here's a couple tips:

  1. DLLs going to Win SXS and GAC don't happen until after StartServices because of a design limitation in MSI. Try installing but not starting the service. Then after it's installed try to start it. If it works, it could be that.

  2. You could be missing files. You can try to run the exe from a command prompt while it's hung and see if it says anything is missing.

  3. The application could be crashing on startup.

I offer free 1 hour consulting sessions. If you can share the files with me I could look at it with you. Look me up if you are interested.

Upvotes: 0

Related Questions