Jump to content

changing login user for service doesnt work


Recommended Posts

Hallo forum,

I have build a little installer for a bunch of programs. One of the programs is installing a service which I would like to run with a specific user.

Func _prog()
   FileChangeDir ( @ScriptDir )
   $CMD = @ScriptDir&"\programuser.vbs "&$pguser[1]&" "&$pgpw[1]  ;the pguser and pgpw are set in a main program
   $Error_user = RunWait(@ComSpec & " /c " & $CMD, @Scriptdir)
   $CMD = "call "&@ScriptDir&"\"&$Inst_program&" --mode unattended" ;$Inst_program is also set in the main program

   $Error_install = RunWait(@ComSpec & " /c " & $CMD, @Scriptdir)
   $CMD = 'ntrights +r SeServiceLogonRight -u '&$pguser[1]
   $Error_service = RunWait(@ComSpec & " /c " & $CMD, @ScriptDir)
   $CMD = @ScriptDir&"\programservicechange.vbs "&$pguser[1]&" "&$pgpw[1]
   $Error_service = RunWait(@ComSpec & " /c " & $CMD, @Scriptdir)
EndFunc

programuser.vbs creates a new windows user and sets a password for it that doesn't expire

'ntrights +r SeServiceLogonRight -u '&$pguser[1]   sets Logon as service Rights for that created user

programservicechange.vbs (modifies the service to start with the user and starts the service)

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServices = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_Service WHERE Name = 'service'")

For Each objService In colServices

    errServiceChange = objService.Change _
        ( , , , , , , "program" , "password")  
Next

as far as I can check it it works fine (the user is created, the right password is set and the service is also set with that user)

still my problem is:

when I let the installer only run the install program and create a new user and after that change the service manually it works fine

but when I let the installer do everything (install program, create user and mod service) the service isn't started when I go to Management>Serivces

and if I start the service manually I get a message that it was paused and that it is normal for some services to be paused after start if they are not used by a program or service

the computer is member of a domain and the user with which I run the installer is local Admin

I tried many things now and i am a little frustrated. Hope you can help my

 

Edited by powerbot
Link to comment
Share on other sites

Hallo powerbot,

willkommen beim englischen AutoIt Forum!
Um möglichst viele Antworten auf Dein Probem zu bekommen solltest Du entweder Deine Frage auf englisch stellen oder im deutschen Forum posten.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...