记录、分享
一直在路上

windows下netsh的使用及批量命令

netsh为DOS下的命令

 

相关的netsh可用/?查询

 

例如:

netsh /?

Netsh ras /?

 

该命令可做的事情很多,比如设置IP地址、设置VPN账号的访问权限等等。

举例:

netsh ras set user 53AT permit

设置53AT用户允许使用远程访问权限

 

netsh interface ip add address “以太网 2” 107.163.242.2 255.255.255.0

设置特定的网卡中的IP地址、掩码

 

批量命令:

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

 

批量设置拨入权限(允许访问网络权限)

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

打赏
欢迎转载,请注明出处:轻时代 » windows下netsh的使用及批量命令

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址