脚本获取子网掩码和网关
Often times network admins need to run domain logon scripts for seperate subnets, but also for a seperate set of computers within that subnet. In this circumstance, configuring Active Directory Sites and Services then linking a GPO to site/subnet might not be an option.
网络管理员通常需要为单独的子网运行域登录脚本,但也需要为该子网内的另一组计算机运行域登录脚本。 在这种情况下,可能无法选择配置Active Directory站点和服务,然后将GPO链接到站点/子网。
So now what ?
那么现在怎么办 ?
This is a real world example of this situation and my accepted solution: http://www.experts-exchang
这是这种情况和我接受的解决方案的真实示例: http://www.experts-exchang e.com/OS/M icrosoft_O perating_S 系统/服务 ver / Q_2274 6765.html? sfQueryTer mInfo = 1 + lo 猫+登录+ 脚本+ vb
This is the solution you can employ so that your logon scripts can identify the subnet a computer exists on...in order to decide whether to run or terminate. Currently the script is only designed for class C network identification.
这是您可以采用的解决方案,以便您的登录脚本可以标识计算机所在的子网...以便决定运行还是终止。 当前,该脚本仅设计用于C类网络标识。
You need two things to make this work...
您需要两件事来使这项工作...
1) The attached vbscript (paste into notepad and save as *.vbs)
1)附加的vbscript(粘贴到记事本中并另存为* .vbs)
2) A program called setx.exe (Found in the MS Resource kit - http://www.microsoft.com/d
2)名为setx.exe的程序(位于MS Resource Kit中-http: //www.microsoft.com/d 自载/天 etails.asp x?FamilyID = DC2D3339- 8F36-4FBA- A406-2A2A2 AD7208C&di splaylang = zh )
Once you have successfully employed this method....you can use the conditional code in your logon scripts using the subnet as a system variable.
成功使用此方法后,您可以使用子网作为系统变量在登录脚本中使用条件代码。
Example: The subnet is 192.168.6, which was set as a variable %IPNETID%, and I want a script to only run if that is the subnet the machine is presently on...
示例:子网是192.168.6,它已设置为变量%IPNETID%,并且我希望脚本仅在该计算机当前位于的子网中才能运行...
Therefore the first line on the logon batch script would be the following....
因此,登录批处理脚本的第一行将是以下内容。
IF NOT %IPNETID% == 192.168.6 EXIT
如果不是%IPNETID%== 192.168.6退出
or you could use this...
或者你可以使用这个...
IF %IPNETID% == 192.168.6 net use m: "\\server\share"
如果%IPNETID%== 192.168.6净使用m:“ \\服务器\共享”
This is my original solution which was published on Microsoft Script Center repository - Technet (http://www.microsoft.com/t
这是我的原始解决方案,已发布在Microsoft脚本中心存储库-Technet( http://www.microsoft.com/t echnet / scr iptcenter / csc /脚本 s /桌面/ 设置/ c scds060.ms px )
Now when you move machines between subnets, the proper logon scripts will run automatically after the first reboot.
现在,当您在子网之间移动计算机时,正确的登录脚本将在第一次重新引导后自动运行。
NOTE: One caveat i've found, is that this script when used as a startup script will sometimes set the system variable only after the second reboot/logon, on a newly domain-joined machine. I believe this is because of machine authentication reasons... not sure though. Make sure the setx file is accessible to all machines, and that this script is set to run prior to other scripts running because the variable needs to be set prior to being used as a condition in your other logon scripts.
注意:我发现的一个警告是,此脚本用作启动脚本时,有时仅会在新加入域的计算机上第二次重新启动/登录后才设置系统变量。 我相信这是由于机器身份验证的原因...虽然不确定。 确保setx文件可被所有计算机访问,并且此脚本被设置为在其他脚本运行之前运行,因为在将其用作其他登录脚本中的条件之前,需要先设置变量。
脚本获取子网掩码和网关