『楼 主』:
[求助]1.环境变量 2.自动修改IP地址
使用 LLM 解释/回答一下
起因: 前些天一单位几十台机器,因工作需要,装了一个sslvpn的软件,装完后它会自动添加一个虚拟网卡,构建虚拟VPN专网,并通过SSL协议安全访问某站点.
故障现象: 装完后所有机器都无法运行 ping, regedit等命令,说这些不是外部或内部命令,也不是批处理.
我的分析: 显然, 系统的环境变量被破坏了. 我查看了系统环境变量,为: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem.发现没有什么问题,而且 ping, regedit等命令在上述路径中. 当我把%SystemRoot%\System32\Wbem改成%SystemRoot%\system32\wbem(有二个字母小写了)或任意二个路径交换顺序后故障现象消失,我赶紧查看未装此软件的新机器,发现其环境变量也是%SystemRoot%\System32\Wbem,照这么说,这个路径应该是没错了.再抽查了几台故障机器,有的是Wbem,有的又是WBEM,真是TMD百思不得其解.在故障机器上打开CMD窗口,运行 path命令,发现问题了,窗口中显示的是PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem,而正常的机器中显示的则是PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem,但在故障机CMD窗口中显示SystemRoot=C:\WINDOWS,表明SystemRoot环境变量被正确识别了呀,为什么在path路径中又不能被正确替换呢?我这几天真是相当的郁闷,请达人出手相救.
另外,请教自动修改IP地址.目的: 虚拟网卡添加后默认是没有IP地址的, 现要求根据实网卡的IP来修改虚网卡的IP地址,方法是虚网卡IP地址的前二位固定为11.123,后二位取实网卡IP的后二位,如:某机器的实网卡为192.168.9.7,则虚网卡的IP为11.123.9.7,掩码为255.255.0.0
关于这方面的帖子我搜了也看了一些, 大部分都是用netsh来修改IP,但这些机器上的网络连接名很多都不相同,比如,有的机器上实连接叫"本地连接 3",虚的反而叫"本地连接";有的机器装有二块网卡,一块设有IP,一块又没设.而且,我看到有的帖子里说用netsh命令,必须要开启remote registry服务,但我的机器上早就禁用此服务了,用netsh却照样可以改IP地址,不知哪位高人知其缘由.
我想了想,可以实现,没写出来,用了自己常用的strrpc文本替换工具,因我对for命令实在是没时间研究了,想看看其他高手是怎么写的,还请赐教
Cause: A few days ago, several dozen machines in a unit installed an sslvpn software due to work needs. After installation, it automatically adds a virtual network card, constructs a virtual VPN private network, and accesses a certain site securely through the SSL protocol.
Symptoms: After installation, all machines cannot run commands like ping, regedit, etc. It says these are not external or internal commands, nor batch files.
My analysis: Obviously, the system's environment variables were damaged. I checked the system environment variables and they were: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem. There seemed to be no problem, and the ping, regedit, etc., commands were in the above paths. When I changed %SystemRoot%\System32\Wbem to %SystemRoot%\system32\wbem (with two letters in lowercase) or swapped the order of any two paths, the symptom disappeared. I quickly checked a new machine that hadn't installed this software and found its environment variables were also %SystemRoot%\System32\Wbem. According to this, this path should be correct. Then I randomly checked several faulty machines. Some had Wbem, and some had WBEM. It was really frustrating and I couldn't figure it out. When I opened the CMD window on the faulty machine and ran the path command, I found the problem. The window showed PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem, while the normal machine showed PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem. But in the CMD window of the faulty machine, SystemRoot=C:\WINDOWS was displayed, indicating that the SystemRoot environment variable was correctly recognized. Why couldn't it be correctly replaced in the path? I've been really depressed these days. I hope an expert can come to the rescue.
In addition, I would like to ask about automatically modifying the IP address. Purpose: The virtual network card has no IP address by default after being added. Now, it is required to modify the IP address of the virtual network card according to the IP of the real network card. The method is that the first two digits of the IP address of the virtual network card are fixed as 11.123, and the last two digits take the last two digits of the IP of the real network card. For example, if the real network card of a certain machine is 192.168.9.7, then the IP of the virtual network card is 11.123.9.7, and the mask is 255.255.0.0.
I have searched and read some posts about this. Most of them use netsh to modify the IP, but the network connection names on these machines are many and different. For example, on some machines, the real connection is called "Local Area Connection 3", and the virtual one is called "Local Area Connection" instead; some machines have two network cards, one with an IP set and the other without. Moreover, I saw in some posts that the netsh command must enable the remote registry service, but I have already disabled this service on my machine, but netsh can still change the IP address. I don't know why.
I thought it could be implemented, but I didn't write it out. I used my commonly used strrpc text replacement tool. Since I really don't have time to study the for command, I want to see how other experts write it. I still ask for your advice.
|