本文最后更新于 2018年12月24日 17:59 可能会因为没有更新而失效。如已失效或需要修正,请留言
netsh、net为DOS下的命令,相关的netsh、net可用/?查询
例如:
netsh /? Netsh ras /? net /?
该命令可做的事情很多,比如设置IP地址、设置VPN账号的访问权限等等。
举例:
设置53AT用户允许使用远程访问权限
netsh ras set user 53AT permit
设置特定的网卡中的IP地址、掩码
netsh interface ip add address "以太网 2" 107.163.242.2 255.255.255.0
批量命令:
for /l %i in (2,1,254) do
批量增加IP地址:
for /l %i in (2,1,254) do netsh interface ip add address "以太网 2" 107.163.242.%i 255.255.255.0
批量删除IP地址:
for /l %i in (2,1,254) do netsh interface ip del address "以太网 2" 107.163.242.%i 255.255.255.0
批量设置用户
for /l %i in (2,1,3) do net user 53AT%i 312 /add
1、批量设置用户、密码、全名、描述
命令说明:设置user-1到user-6这6个用户,密码为password,用户永不失效,全名为user-1到user-6,描述为user-1到user-6,/y 确认
for /l %i in (1,1,6) do net user user-%i password /add /expires:never /fullname:"user-%i" /comment:"user-%i" /y
2、批量设置用户组
命令说明:添加user-1到user-6这6个用户到远程桌面用户组
for /l %i in (1,1,6) do net localgroup "Remote Desktop Users" user-%i /add /y
3、批量设置用户密码永不过期
命令说明:设置user-1到user-6这6个用户的密码永不过期
for /l %i in (1,1,6) do wmic UserAccount where "Name='user-%i'" set PasswordExpires=False
批量设置拨入权限(允许访问网络权限)
for /l %i in (2,1,254) do netsh ras set user 53AT%i permit for /l %i in (2,1,254) do netsh ras set user 207AT%i permit for /l %i in (2,1,254) do netsh ras set user 222AT%i permit for /l %i in (2,1,254) do netsh ras set user 242AT%i permit
批量设置用户密码永不过期
for /l %i in (2,1,254) do WMIC USERACCOUNT WHERE "Name='53AT%i'" SET PasswordExpires=FALSE for /l %i in (2,1,254) do WMIC USERACCOUNT WHERE "Name='207AT%i'" SET PasswordExpires=FALSE for /l %i in (2,1,254) do WMIC USERACCOUNT WHERE "Name='222AT%i'" SET PasswordExpires=FALSE for /l %i in (2,1,254) do WMIC USERACCOUNT WHERE "Name='242AT%i'" SET PasswordExpires=FALSE