用VBS脚本写一个打开网络共享中心的脚本
时间: 2023-09-03 15:09:52 浏览: 47
可以使用以下VBS脚本来打开网络共享中心:
```
Set objShell = CreateObject("Shell.Application")
objShell.ControlPanelItem("Network and Sharing Center").Invoke
```
保存上述代码为一个以 `.vbs` 结尾的文件,双击运行即可打开网络共享中心。
相关问题
vbs脚本写一个打开网络共享中心
可以使用以下vbs脚本代码来打开网络共享中心:
```
Set objShell = CreateObject("Shell.Application")
objShell.ControlPanelItem("Network and Sharing Center").DoClick
```
保存上述代码为一个.vbs文件,然后双击该文件即可打开网络共享中心。
用vbs脚本写一个局域网扫描
我可以回答这个问题。您可以使用以下vbs脚本来扫描局域网:
```
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
strIP = IPConfig.IPAddress(i)
If InStr(strIP, ".") > Then
strPrefix = Left(strIP, InStrRev(strIP, "."))
For j=1 To 254
strTestIP = strPrefix & j
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("select * from Win32_PingStatus where address='" & strTestIP & "'")
For Each objStatus in objPing
If objStatus.StatusCode = Then
WScript.Echo "IP Address: " & strTestIP & " is online."
End If
Next
Next
End If
Next
End If
Next
```
这个脚本将扫描您的局域网,并显示在线的IP地址。请注意,您需要以管理员身份运行此脚本。