CodePudding user response:
As a service login this strategy is based on the security database, not to exist in the registries,Try this VBS
'SetLogonAsAServiceRight. VBS
'the Sample script to set the or grant Logon As A Service Right.
'the Author: http://www.morgantechspace.com/
'-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
Dim strUserName ConfigFileName, OrgStr RepStr, inputFile, strInputFile, outputFile, obj
StrUserName="work2008 \ DevUser"
Dim oShell
The Set oShell=CreateObject (" WScript. Shell ")
OShell. Run "secedit/export/CFG config. J inf", 0, true
OShell. Run "secedit/import/CFG config. J inf/db database. The SDB", 0, true
ConfigFileName="config. J inf"
OrgStr="SeServiceLogonRight="
RepStr="SeServiceLogonRight=" & amp; StrUserName & amp; ", "
The Set inputFile=CreateObject (" Scripting. FileSystemObject "). OpenTextFile (" config. J inf ", 1, 1, 1)
StrInputFile=inputFile. ReadAll
InputFile. Close
The Set of inputFile=Nothing
The Set outputFile=CreateObject (" Scripting. FileSystemObject "). OpenTextFile (" config. J inf ", 2, 1, 1)
OutputFile. Write (Replace (strInputFile OrgStr, RepStr))
OutputFile. Close
The Set outputFile=Nothing
OShell. Run "secedit/configure/db database. The SDB/CFG config. Inf", 0, true
The set oShell=Nothing
The Set obj=CreateObject (" Scripting. FileSystemObject ")
Obj. DeleteFile (" config. J inf ")
Obj. DeleteFile (" database. SDB ")
Msgbox "Logon As A Service Right granted to the user '" & amp; StrUserName & amp;" 'using Vbscript code"
CodePudding user response:
https://www.morgantechspace.com/2013/11/Set-or-Grant-Logon-As-A-Service-right-to-User.htmlThere are methods of c #