Home > OS >  How to use the instruction to modify Windows system strategy, make a user login can be used as a ser
How to use the instruction to modify Windows system strategy, make a user login can be used as a ser

Time:11-29

Recently released the aspnetcore, want to use the HTTPS, but found that you must specify a line can be used as a service users only, can pass instruction to create a new user, can also be set for the administrator privileges for him, but was not able to login as a service, could you tell me how to in the code or the DOS command this layer to solve this problem?

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.html
There are methods of c #
  • Related