if GetConnection(CONNECTION_ALL) = FALSE then bReturn = FALSE end if
GetConnectionObjects = bReturn
end function
function GetConnection(CONNECTION_TYPE) DIM bReturn DIM Connection DIM Item
bReturn = TRUE
if (CONNECTION_PUBLIC = CONNECTION_TYPE) then set Connection =
NetSharingManager.EnumPublicConnections(ICSSC_DEFAULT)
if (Connection.Count > 0) and (Connection.Count < 2) then for each Item in Connection set PublicConnection =
NetSharingManager.INetSharingConfigurationForINetConnection(Item) next else
bReturn = FALSE end if
elseif (CONNECTION_PRIVATE = CONNECTION_TYPE) then set Connection =
NetSharingManager.EnumPrivateConnections(ICSSC_DEFAULT)
if (Connection.Count > 0) and (Connection.Count < 2) then for each Item in Connection set PrivateConnection =
NetSharingManager.INetSharingConfigurationForINetConnection(Item) next else
bReturn = FALSE end if
elseif (CONNECTION_ALL = CONNECTION_TYPE) then
set Connection = NetSharingManager.EnumEveryConnection if (Connection.Count > 0) then
set EveryConnectionCollection = Connection else
bReturn = FALSE end if
else
bReturn = FALSE end if
if (TRUE = bReturn) then
if (Connection.Count = 0) then Wscript.Echo(\
CStr(ConvertConnectionTypeToString(CONNECTION_TYPE)) + \exist (Connection.Count gave us 0)\ bReturn = FALSE
'valid to have more than 1 connection returned from EnumEveryConnection
elseif (Connection.Count > 1) and (CONNECTION_ALL <> CONNECTION_TYPE) then
Wscript.Echo(\
ConvertConnectionTypeToString(CONNECTION_TYPE) + \CStr(Connection.Count) + \ bReturn = FALSE end if end if
Wscript.Echo(CStr(Connection.Count) + \objects for connection type \
GetConnection = bReturn end function
function ConvertConnectionTypeToString(ConnectionID) DIM ConnectionString
if (ConnectionID = CONNECTION_PUBLIC) then ConnectionString = \
elseif (ConnectionID = CONNECTION_PRIVATE) then ConnectionString = \
elseif (ConnectionID = CONNECTION_ALL) then ConnectionString = \ else
ConnectionString = \ end if
ConvertConnectionTypeToString = ConnectionString end function
5、用下面的代码建立批处理文件wifi.bat
rem 1、禁用网络连接共享(有线网卡)
cscript /nologo ics.vbs \无线网络连接 2\本地连接\
rem 2、禁用网卡(无线网卡)
netsh interface set interface name=\无线网络连接\
rem 3、启用网卡(无线网卡)
netsh interface set interface name=\无线网络连接\
rem 4、设置wifi热点并使其可用(无线网卡) netsh wlan set hostednetwork mode=allow
rem 5、启动wifi热点(无线网卡) netsh wlan start hostednetwork
rem 6、启用网络连接共享(有线网卡)
cscript /nologo ics.vbs \无线网络连接 2\本地连接\
注意:
rem 4、设置wifi热点(无线网卡)
netsh wlan set hostednetwork mode=allow
此处这么用是因为上面已经在1里面执行过
netsh wlan set hostednetwork mode=allow ssid=wifi key=1234567890 系统会记住你设置的,重启也不会丢失。
最开始我用网上的方法设置了虚拟wifi,但重启系统或待机激活后出现不能连接,后来通过多次测试,得出了上面上网设置1-6条,这个顺序很重要,切记!
6、把wifi.bat 和ics.vbs放在同一目录下
运行wifi.bat等待批处理执行完毕,你的手机或其他电脑就可以连接wifi上网了。
重启电脑或待机激活电脑后只要再次运行wifi.bat就可以了,希望大家玩的愉快!