求开启本地连接共享到无线网络2的一个dos命令
这个是设置把本地连接共享的步骤:
1、以管理员身份运行命令提示符(用快捷键WIN+R调出运行然后输入CMD打开命令提示符的非是管理员权限),右击“命令提示符”,选择以 “管理员身份运行”。
2、在命令提示符下输入命令:netsh wlan set hostednetwork mode=allow
3、继续在命令提示符中输入:netsh wlan set hostednetwork ssid=您想要的无线网络的名称 key=您想要设置的密码(10位)
这一步是设置无线网络名称和密码,密码必须8位以上!
4、接下来打开网络共享中心--更改适配器设置,你会发现多了一个Microsoft Virtual wlan Miniport Adapter,对了,这个就是我们刚才 虚拟出来的无线网络适配器。
5、继续在命令提示符中输入:netsh wlan start hostednetwork
这一步是打开刚才虚拟的无线网络,这样你的无线终端就能发现你刚才虚拟的网络了。
6、打开网络共享中心发现你现在连接了两个网络了,一个是你的有线网络,另外一个就是虚拟网络
7、打开网络共享中心--更改适配器设置,右击你的宽带连接,也就是你连入网络的有线网卡,选择属性,点击共享,勾选“允许其他网络用 户通过此计算机的Internet连接还连接”选项,在下拉菜单中选择刚才建立的虚拟网络(无线连接2),确定。
现在求问的是第7步如何用DOS命令实现而不是去用鼠标点?
[解决办法]
想用vbs可以实现?
OPTION EXPLICIT
DIM ICSSC_DEFAULT, CONNECTION_PUBLIC, CONNECTION_PRIVATE, CONNECTION_ALL
DIM NetSharingManager
DIM PublicConnection, PrivateConnection
DIM EveryConnectionCollection
DIM objArgs
DIM priv_con, publ_con
dim switch
ICSSC_DEFAULT = 0
CONNECTION_PUBLIC = 0
CONNECTION_PRIVATE = 1
CONNECTION_ALL = 2
Main()
sub Main( )
Set objArgs = WScript.Arguments
if objArgs.Count = 3 then
priv_con = objArgs(0)
publ_con = objArgs(1)
switch = objArgs(2)
if Initialize() = TRUE then
GetConnectionObjects()
FirewallTestByName priv_con,publ_con
end if
else
DIM szMsg
if Initialize() = TRUE then
GetConnectionObjects()
FirewallTestByName "list","list"
end if
szMsg = "To share your internet connection, please provide the name of the private and public connections as the argument." & vbCRLF & vbCRLF & _
"Usage:" & vbCRLF & _
" " & WScript.scriptname & " " & chr(34) & "Private Connection Name" & chr(34) & " " & chr(34) & "Public Connection Name" & chr(34)
WScript.Echo( szMsg & vbCRLF & vbCRLF)
end if
end sub
sub FirewallTestByName(con1,con2)
on error resume next
DIM Item
DIM EveryConnection
DIM objNCProps
DIM szMsg
DIM bFound1,bFound2
WScript.echo(vbCRLF & vbCRLF)
bFound1 = false
bFound2 = false
for each Item in EveryConnectionCollection
set EveryConnection = NetSharingManager.INetSharingConfigurationForINetConnection(Item)
set objNCProps = NetSharingManager.NetConnectionProps(Item)
szMsg = "Name: " & objNCProps.Name & vbCRLF & _
"Guid: " & objNCProps.Guid & vbCRLF & _
"DeviceName: " & objNCProps.DeviceName & vbCRLF & _
"Status: " & objNCProps.Status & vbCRLF & _
"MediaType: " & objNCProps.MediaType
if EveryConnection.SharingEnabled then
szMsg = szMsg & vbCRLF & _
"SharingEnabled" & vbCRLF & _
"SharingType: " & ConvertConnectionTypeToString(EveryConnection.SharingConnectionType)
end if
if objNCProps.Name = con1 then
bFound1 = true
if EveryConnection.SharingEnabled = False and switch="on" then
szMsg = szMsg & vbCRLF & "Not Shared... Enabling private connection share..."
WScript.Echo(szMsg)
EveryConnection.EnableSharing CONNECTION_PRIVATE
szMsg = " Shared!"
elseif(switch = "off") then
szMsg = szMsg & vbCRLF & "Shared... DisEnabling private connection share..."
WScript.Echo(szMsg)
EveryConnection.EnableSharing CONNECTION_ALL
end if
end if
if objNCProps.Name = con2 then
bFound2 = true
if EveryConnection.SharingEnabled = False and switch="on" then
szMsg = szMsg & vbCRLF & "Not Shared... Enabling public connection share..."
WScript.Echo(szMsg)
EveryConnection.EnableSharing CONNECTION_PUBLIC
szMsg = " Shared!"
elseif(switch = "off") then
szMsg = szMsg & vbCRLF & "Shared... DisEnabling public connection share..."
WScript.Echo(szMsg)
EveryConnection.EnableSharing CONNECTION_ALL
end if
end if
WScript.Echo(szMsg & vbCRLF & vbCRLF)
next
if( con1 <> "list" ) then
if( bFound1 = false ) then
WScript.Echo( "Connection " & chr(34) & con1 & chr(34) & " was not found" )
end if
if( bFound2 = false ) then
WScript.Echo( "Connection " & chr(34) & con2 & chr(34) & " was not found" )
end if
end if
end sub
function Initialize()
DIM bReturn
bReturn = FALSE
set NetSharingManager = Wscript.CreateObject("HNetCfg.HNetShare.1")
if (IsObject(NetSharingManager)) = FALSE then
Wscript.Echo("Unable to get the HNetCfg.HnetShare.1 object")
else
if (IsNull(NetSharingManager.SharingInstalled) = TRUE) then
Wscript.Echo("Sharing isn't available on this platform.")
else
bReturn = TRUE
end if
end if
Initialize = bReturn
end function
function GetConnectionObjects()
DIM bReturn
DIM Item
bReturn = TRUE
if GetConnection(CONNECTION_PUBLIC) = FALSE then
bReturn = FALSE
end if
if GetConnection(CONNECTION_PRIVATE) = FALSE then
bReturn = FALSE
end if
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("No " + CStr(ConvertConnectionTypeToString(CONNECTION_TYPE)) + " connections 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("ERROR: There was more than one " + ConvertConnectionTypeToString(CONNECTION_TYPE) + " connection (" + CStr(Connection.Count) + ")")
bReturn = FALSE
end if
end if
Wscript.Echo(CStr(Connection.Count) + " objects for connection type " + ConvertConnectionTypeToString(CONNECTION_TYPE))
GetConnection = bReturn
end function
function ConvertConnectionTypeToString(ConnectionID)
DIM ConnectionString
if (ConnectionID = CONNECTION_PUBLIC) then
ConnectionString = "public"
elseif (ConnectionID = CONNECTION_PRIVATE) then
ConnectionString = "private"
elseif (ConnectionID = CONNECTION_ALL) then
ConnectionString = "all"
else
ConnectionString = "Unknown: " + CStr(ConnectionID)
end if
ConvertConnectionTypeToString = ConnectionString
end function