1

I have a program that will be ran as a windows service, so I have a batch script made that will run commands to install the .exe as a service. Since the custom actions can't run batch files I made a simple VBScript that I put in the 'Commit' folder of custom actions that will simply execute the batch file post-install. The problem is that it's not finding the batch file, however, I've tested it outside of the install process and it seems to find the file just fine so I'm unsure where the issue is.

Here is the batch file (InstallService.bat):

sc create "ServiceName" binPath="%~dp0pathToExE"
sc start ServiceName

VBScript:

Set Shell = CreateObject("Shell.Application")
Shell.ShellExecute "InstallService.bat", , , "runas", 0

Connor_H
  • 11
  • 1
  • 1
    Have you considered doing it all in VBS? Something like: https://github.com/LesFerch/SampleCode/blob/main/VBS-misc/ServiceStart.vbs – LesFerch Aug 16 '21 at 16:48
  • @LesFerch Is it possible to run the commands as administrator using .Run()? Unfortunately 'sc create' needs elevated privileges. – Connor_H Aug 16 '21 at 17:09
  • There's a lot of "it depends" to that question. What packager are you using? Is this to be run in a deployment infrastructure, such as MECM, or will it have to work offline with the user expected to get a UAC prompt? – LesFerch Aug 16 '21 at 18:00
  • Some of the code and info here might help: https://stackoverflow.com/questions/17466681/how-to-run-vbs-as-administrator-from-vbs – LesFerch Aug 16 '21 at 18:20

0 Answers0