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,运行后需要手工输入管理员密码。

 

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

目录
相关文章
|
20天前
|
Linux C++ Windows
【Azure 应用服务】Azure App Service(Windows)环境中如何让.NET应用调用SAP NetWeaver RFC函数
【Azure 应用服务】Azure App Service(Windows)环境中如何让.NET应用调用SAP NetWeaver RFC函数
【Azure 应用服务】Azure App Service(Windows)环境中如何让.NET应用调用SAP NetWeaver RFC函数
|
20天前
|
Java 应用服务中间件 开发工具
[App Service for Windows]通过 KUDU 查看 Tomcat 配置信息
[App Service for Windows]通过 KUDU 查看 Tomcat 配置信息
|
20天前
|
Java 应用服务中间件 Windows
【App Service for Windows】为 App Service 配置自定义 Tomcat 环境
【App Service for Windows】为 App Service 配置自定义 Tomcat 环境
|
20天前
|
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. 错误
|
20天前
|
PHP 开发工具 git
【Azure 应用服务】在 App Service for Windows 中自定义 PHP 版本的方法
【Azure 应用服务】在 App Service for Windows 中自定义 PHP 版本的方法
|
14天前
|
API C# Shell
WPF与Windows Shell完美融合:深入解析文件系统操作技巧——从基本文件管理到高级Shell功能调用,全面掌握WPF中的文件处理艺术
【8月更文挑战第31天】Windows Presentation Foundation (WPF) 是 .NET Framework 的关键组件,用于构建 Windows 桌面应用程序。WPF 提供了丰富的功能来创建美观且功能强大的用户界面。本文通过问题解答的形式,探讨了如何在 WPF 应用中集成 Windows Shell 功能,并通过具体示例代码展示了文件系统的操作方法,包括列出目录下的所有文件、创建和删除文件、移动和复制文件以及打开文件夹或文件等。
30 0
|
20天前
|
网络安全 API 数据安全/隐私保护
【Azure App Service】.NET代码实验App Service应用中获取TLS/SSL 证书 (App Service Windows)
【Azure App Service】.NET代码实验App Service应用中获取TLS/SSL 证书 (App Service Windows)
|
20天前
|
Shell PHP Windows
【Azure App Service】Web Job 报错 UNC paths are not supported. Defaulting to Windows directory.
【Azure App Service】Web Job 报错 UNC paths are not supported. Defaulting to Windows directory.
|
20天前
|
存储 Linux Windows
【应用服务 App Service】App Service For Windows 如何挂载Storage Account File Share 示例
【应用服务 App Service】App Service For Windows 如何挂载Storage Account File Share 示例
|
20天前
|
应用服务中间件 nginx Windows
【Azure 应用服务】在App Service for Windows中实现反向代理
【Azure 应用服务】在App Service for Windows中实现反向代理