简体   繁体   English

通过命令行在管理员组中创建用户,但不依赖操作系统语言

[英]Create user in admin group via command line, but not O.S Language dependency

i need create user in admin group via command line, but not OS Language dependency:我需要通过命令行在管理员组中创建用户,而不是操作系统语言依赖项:

the problem is that some machine have spanish lengueage other english....问题是某些机器有西班牙语 lengueage 其他英语....

and group must be called Administradores or Administrators并且组必须称为AdministradoresAdministrators

net user prueba2 123456 /add
net localgroup Administradores prueba2 /add

pause

How can I make this batch script work on any OS如何使此批处理脚本在任何操作系统上工作

Here's a batch file example which runs your two commands, retrieving the required LocalGroup name using :这是一个批处理文件示例,它运行您的两个命令,使用检索所需的LocalGroup名称:

@%__AppDir__%net.exe User prueba2 123456 /Add
@For /F Tokens^=6Delims^=^" %%G In ('%__AppDir__%wbem\WMIC.exe Group Where SID^="S-1-5-32-544" Get Name /Format:MOF 2^>NUL')Do @%__AppDir__%net.exe LocalGroup %%G prueba2 /Add

If one or more of your systems are Windows 7, there's a potential issue with the example above, (the required xsl file isn't, by default, located in the correct directory) .如果您的一个或多个系统是 Windows 7,则上述示例可能存在问题(默认情况下,所需的xsl文件不在正确的目录中) The following modification should hopefully take care of that issue, and should still work as intended on the other WMIC supported Operating Systems :以下修改有望解决该问题,并且仍应在其他 WMIC 支持的操作系统上按预期工作

@%__AppDir__%net.exe User prueba2 123456 /Add
@For /F Delims^= %%G In ('%__AppDir__%where.exe /R %__AppDir__% mof.xsl 2^>NUL')Do @For /F Tokens^=6Delims^=^" %%H In ('%__AppDir__%wbem\WMIC.exe Group Where SID^="S-1-5-32-544" Get Name /Format:"%%G" 2^>NUL')Do @%__AppDir__%net.exe LocalGroup %%H prueba2 /Add

Please remember to change the two instances of your user name and your password as needed.请记住根据需要更改用户名和密码的两个实例。 It is likely that this script needs to run by an account with sufficient permissions to create users.此脚本可能需要由具有足够权限的帐户运行才能创建用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM