1

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

coolguy123
  • 67
  • 6
  • You don't have to use an actual user account: you can use `LocalService` or `NetworkService` (and I think there are other related accounts) that don't need credentials, but of course need elevated permissions while installing. If you have elevated your installer, this should work. Ref: https://stackoverflow.com/questions/510170/the-difference-between-the-local-system-account-and-the-network-service-acco – Steve Friedl Dec 28 '22 at 22:08
  • When I open a the prompt displaying the list of users on my machine I find neither LocalService nor NetworkService. I've tried setting the service to run as LocalService but it didn't work either, as per EDIT2 to my question. – coolguy123 Dec 28 '22 at 23:06
  • If you check the link in my comment, you'll find that `NT Authority\LocalService` is the proper name - this maps to a built-in user, and I doubt it will show in any drop-down. – Steve Friedl Dec 28 '22 at 23:14
  • Yes, that didn't work with Advanced Packager either. I'm trying with EMCO MSI Packager to see if it makes a diference. – coolguy123 Dec 28 '22 at 23:21
  • I don't know what "didn't work" means, but this appears to be supported by Advanced Installer, at least for English versions. Ref: https://www.advancedinstaller.com/forums/viewtopic.php?t=50245 – Steve Friedl Dec 28 '22 at 23:32
  • Sorry for the lack of specificity. I inserted NT Authority\ followed LocalService, LocalSystem and NetworkService, as well as selected the package to "Run as Administrator". However, the same error remained. I've followed the instructions in the link and again failed, I must be doing something wrong as it's clear by the link it works. – coolguy123 Dec 28 '22 at 23:40
  • @SteveFriedl I've managed to achieve a successful result using PowerShell and the "NT AUTHORITY\SYSTEM" account, but when I try LocalService or above, I get an "Acess Denied" result from the task. – coolguy123 Dec 29 '22 at 01:15
  • What does C or C++ have to do with an installer? Are you installing the source code? Are you writing an installer in C or C++? Most installers install executables *that can be generated from any compliable language*. – Thomas Matthews Dec 29 '22 at 04:48
  • @ThomasMatthews the question is about scheduling tasks with an explorer vs. doing it in plain C/C++ (considering practicality, time efficiency, etc). However, I can delete the tags if you think they are unwarranted. – coolguy123 Dec 29 '22 at 13:15
  • On Windows, EXEs can implement the SCM API to be a service. The main thing I rememeber seeing once that was unique to C/C++ was a situation where the EXE cared what service name it was given. The correct service name would work. A different service name it wouldn't work. I've never seen this with .NET services. – Christopher Painter Jan 03 '23 at 04:10

1 Answers1

0

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.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100