2

I need to restart an application using a service running on the SYSTEM account. The problem is that the application is then also started under the SYSTEM account. For various reasons beyond my control the restart system is a bit complicated but as a result of its complicatedness(c) I'm sure there must be at least one stage where its possible to specify the account that the app is eventually run on.

The service calls bounce.bat which contains the following:

@echo off
cscript "C:\Program Files\myApp\bounce.vbs"

The relevant section of bounce.vbs is:

Set oProcess = oWMIService.Get("Win32_Process")
Set oProgram = oProcess.Methods_("Create").InParameters.SpawnInstance_
oProgram.CommandLine = sPath & sExe   
Set sShell = oWMIService.ExecMethod("Win32_Process", "Create", oProgram)

If there are no clever suggestions I'll try this approach, but I'm sure there must be a cleaner way.

Note: Cross-posted from SO as the original was getting no action.

Skrealin
  • 123
  • 1
  • 3
  • I gave up waiting and used runas with the password piped in from a text file, as described in the link above. This brought up another issue, where the app was starting under the correct user but on the wrong session / desktop. I gave up on runas and got my batch file to trigger a scheduled task which then runs the vbscript. Ugly as hell but it works. – Skrealin Apr 14 '11 at 08:47

1 Answers1

1

Could your batch file use runas?

crb
  • 7,998
  • 1
  • 38
  • 53