2011-12-12 87 views
0

我想写两个脚本,它们可以是vbs或ms-dos命令。脚本安全权限

首先是设置文件夹的用户权限(相当于:右键单击文件夹,属性,安全性,编辑,添加,NT AUTHORITY\NETWORK SERVICE)。

其次是设置permision作为服务运行,相当于单击点击是:Control Panel/Administrative Tools/Local Security Policy;左侧:Local Policies/User Rights Assignment;右侧:Log on as a service -> add Network Service作为拥有权限的用户。

会有人帮我做那个吗?

回答

1

MS-DOS命令:

文件夹权限:

CACLS path_of_folder /E /T /C /G "userName":F 

cacls command details

日志上作为服务权限:

ntrights -u "userName" +r SeServiceLogonRight 

ntrights command details

+0

我会推荐'icacls' over'cacls',因为它还能够处理继承和更改所有权。 –

0

这太令人沮丧了,我们没有Windows Server 2008及更高版本的ntrights工具。我已经提出了一个可行的vbscript。

Username = <domain\username> 
Dim oShell 
Set oShell = CreateObject ("WScript.Shell") 
oShell.Run "secedit /export /cfg config.inf", 0, true 
oShell.Run "secedit /import /cfg config.inf /db database.sdb", 0, true 

FileName = "config.inf" 
OrgStr = "SeServiceLogonRight =" 
RepStr = "SeServiceLogonRight = " & Username & "," 
Set inputFile = CreateObject("Scripting.FileSystemObject").OpenTextFile("config.inf", 1,1,-1) 
strInputFile = inputFile.ReadAll 
inputFile.Close 
Set inputFile = Nothing 

Set outputFile = CreateObject("Scripting.FileSystemObject").OpenTextFile("config.inf",2,1,-1) 
outputFile.Write (Replace(strInputFile,OrgStr,RepStr)) 
outputFile.Close 
Set outputFile = Nothing 

oShell.Run "secedit /configure /db database.sdb /cfg config.inf",0,true 
set oShell= Nothing 

Set obj = CreateObject("Scripting.FileSystemObject") 
obj.DeleteFile("config.inf") 
obj.DeleteFile("database.sdb")