Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
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 8:47

1 Answer 1

up vote 1 down vote accepted

Could your batch file use runas?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.