Windows shell 创建用户,并将service启动用户设为该用户

简介: 最近改InstallAnyWhere脚本,其提供的action中可以调用系统的command或script,windows下就是CMD命令和BAT,有些实用命令记录一下。

最近改InstallAnyWhere脚本,其提供的action中可以调用系统的command或script,windows下就是CMD命令和BAT,有些实用命令记录一下。

 

创建用户test,密码为password:

net user test password /ADD

 

删除用户test:

net user test /delete

 

授权用户对某目录d:\Program Files\Applian的访问权限(full access):

cacls "d:\Program Files\Applian" /t /e /g test:f


windows command-line 命令授权账户的权限为Log On As A Service,
ntrights.exe +r SeServiceLogonRight -u domain\accountname

Granting SeServiceLogonRight to domain\accountname   ... successful

如果在CMD运行遇到以下错误,关闭wiNdows  UAC功能或让CMD运行在admin用户下(run as admin)
Granting SeServiceLogonRight to domain\accountname   OpenPolicy:

***Error*** OpenPolicy -1073741790

 

ntrights命令需要单独从微软网站下载,属于Resource Kit Tools包,主要功能就是给service授权,能授权的功能如下,该命令运行需要administrator权限:

 

 SeAssignPrimaryTokenPrivilege:  Replace a process level token

  SeAuditPrivilege:  Generate security audits

  SeBackupPrivilege:  Back up files and directories

  SeBatchLogonRight:  Log on as a batch job

  SeChangeNotifyPrivilege:  Bypass traverse checking

  SeCreatePagefilePrivilege:  Create a paging file

  SeCreatePermanentPrivilege:  Create permanent shared objects

  SeCreateTokenPrivilege:  Create a token object

  SeDebugPrivilege:  Debug programs

  SeIncreaseBasePriorityPrivilege:  Increase scheduling priority

  SeIncreaseQuotaPrivilege:  Increase quotas

  SeInteractiveLogonRight:  Log on locally

  SeLoadDriverPrivilege:  Load and unload device drivers

  SeLockMemoryPrivilege:  Lock pages in memory

  SeMachineAccountPrivilege:  Add workstations to domain

  SeNetworkLogonRight:  Access this computer from the network

  SeProfileSingleProcessPrivilege:  Profile single process

  SeRemoteShutdownPrivilege:  Force shutdown from a remote system

  SeRestorePrivilege:  Restore files and directories

  SeSecurityPrivilege:  Manage auditing and security log

  SeServiceLogonRight:  Log on as a service

  SeShutdownPrivilege:  Shut down the system

  SeSystemEnvironmentPrivilege:  Modify firmware environment values

  SeSystemProfilePrivilege:  Profile system performance

  SeSystemTimePrivilege:  Change the system time

  SeTakeOwnershipPrivilege:  Take ownership of files or other objects

  SeTcbPrivilege:  Act as part of the operating system

  SeUnsolicitedInputPrivilege:  Read unsolicited input from a terminal device

 

用管理员权限运行某些命令的方式为:

runas /user:administrator cmd.exe

相当于windows版的sudo,运行后需要手工输入管理员密码。

 

本文出自 “祝坤荣” 博客,请务必保留此出处

目录
相关文章
|
Linux C++ Windows
【Azure 应用服务】Azure App Service(Windows)环境中如何让.NET应用调用SAP NetWeaver RFC函数
【Azure 应用服务】Azure App Service(Windows)环境中如何让.NET应用调用SAP NetWeaver RFC函数
138 0
【Azure 应用服务】Azure App Service(Windows)环境中如何让.NET应用调用SAP NetWeaver RFC函数
|
10月前
|
安全 Windows
【Azure Cloud Service】在Windows系统中抓取网络包 ( 不需要另外安全抓包工具)
通常,在生产环境中,为了保证系统环境的安全和纯粹,是不建议安装其它软件或排查工具(如果可以安装,也是需要走审批流程)。 本文将介绍一种,不用安装Wireshark / tcpdump 等工具,使用Windows系统自带的 netsh trace 命令来获取网络包的步骤
205 32
|
10月前
|
C# Windows
【Azure App Service】在App Service for Windows上验证能占用的内存最大值
根据以上测验,当使用App Service内存没有达到预期的值,且应用异常日志出现OutOfMemory时,就需要检查Platform的设置是否位64bit。
160 11
|
11月前
|
Shell Linux Windows
Does windows have a shell layer?
Does windows have a shell layer?
|
Java 应用服务中间件 开发工具
[App Service for Windows]通过 KUDU 查看 Tomcat 配置信息
[App Service for Windows]通过 KUDU 查看 Tomcat 配置信息
133 2
|
Java 应用服务中间件 Windows
【App Service for Windows】为 App Service 配置自定义 Tomcat 环境
【App Service for Windows】为 App Service 配置自定义 Tomcat 环境
114 2
|
PHP Windows
【Azure App Service for Windows】 PHP应用出现500 : The page cannot be displayed because an internal server error has occurred. 错误
【Azure App Service for Windows】 PHP应用出现500 : The page cannot be displayed because an internal server error has occurred. 错误
209 1
|
PHP 开发工具 git
【Azure 应用服务】在 App Service for Windows 中自定义 PHP 版本的方法
【Azure 应用服务】在 App Service for Windows 中自定义 PHP 版本的方法
118 1
|
API C# Shell
WPF与Windows Shell完美融合:深入解析文件系统操作技巧——从基本文件管理到高级Shell功能调用,全面掌握WPF中的文件处理艺术
【8月更文挑战第31天】Windows Presentation Foundation (WPF) 是 .NET Framework 的关键组件,用于构建 Windows 桌面应用程序。WPF 提供了丰富的功能来创建美观且功能强大的用户界面。本文通过问题解答的形式,探讨了如何在 WPF 应用中集成 Windows Shell 功能,并通过具体示例代码展示了文件系统的操作方法,包括列出目录下的所有文件、创建和删除文件、移动和复制文件以及打开文件夹或文件等。
293 0
|
网络安全 API 数据安全/隐私保护
【Azure App Service】.NET代码实验App Service应用中获取TLS/SSL 证书 (App Service Windows)
【Azure App Service】.NET代码实验App Service应用中获取TLS/SSL 证书 (App Service Windows)
114 0