Board logo

标题: [系统相关] 批处理实现创建或关闭无线网络/wifi热点共享 [打印本页]

作者: gcb384076498    时间: 2015-9-2 21:48     标题: 批处理实现创建或关闭无线网络/wifi热点共享

本帖最后由 pcl_test 于 2016-11-9 16:21 编辑

这是我自己做的承载网络的相关设置
  1. @shift
  2. @echo off
  3. title 承载网络设置
  4. Echo -------------------------------------------------------------------------------
  5. Echo 欢迎使用本程序
  6. Echo -------------------------------------------------------------------------------
  7. :1
  8. Echo -------------------------------------------------------------------------------
  9. Echo a:指定允许还是禁止托管网络。
  10. Echo b:托管网络的 SSID。
  11. Echo c:托管网络使用的用户安全密钥及指定用户密钥密钥是永久性的还是临时的。
  12. Echo d:启动承载网络
  13. Echo e:停止承载网络
  14. Echo f:显示驱动信息
  15. Echo g:查看是否被蹭网
  16. Echo h:打开控制面板-网络连接
  17. Echo i:退出
  18. Echo j:清空屏幕
  19. Echo k:查看ssid和key
  20. Echo l:关闭计算机
  21. Echo m:添加\删除右键菜单的虚拟WIFI的状态
  22. Echo (空格/其他):退出
  23. Echo -------------------------------------------------------------------------------
  24. set m== ""
  25. set /p m= 请输入您的选择并回车:
  26. if /I "%m%"=="a" goto 2
  27. if /I "%m%"=="b" goto 3
  28. if /I "%m%"=="c" goto 4
  29. if /I "%m%"=="d" goto 5
  30. if /I "%m%"=="e" goto 6
  31. if /I "%m%"=="f" goto 7
  32. if /I "%m%"=="g" goto 8
  33. if /I "%m%"=="h" ncpa.cpl
  34. if /I "%m%"=="i" exit
  35. if /I "%m%"=="k" goto 9
  36. if /I "%m%"=="l" goto 10
  37. if /I "%m%"=="m" goto 11
  38. if /I "%m%"==" " exit
  39. if not exit
  40. Echo -------------------------------------------------------------------------------
  41. if /I "%m%"=="j" cls
  42. pause
  43. :2
  44. Echo -------------------------------------------------------------------------------
  45. Echo 允许还是禁止托管网络?
  46. Echo a:允许
  47. Echo b:拒绝
  48. Echo -------------------------------------------------------------------------------
  49. set n==""
  50. set /p n= 请输入您的选择并回车:
  51. Echo -------------------------------------------------------------------------------
  52. if /I "%n%"=="a" netsh wlan set hostednetwork mode=allow
  53. if /I "%n%"=="b" netsh wlan set hostednetwork mode=disallow
  54. pause
  55. goto 1
  56. :3
  57. Echo -------------------------------------------------------------------------------
  58. set s==""
  59. set /p o= 请输入您要设置的WiFi名称并回车:
  60. netsh wlan set hostednetwork ssid="%o%"
  61. Echo -------------------------------------------------------------------------------
  62. pause
  63. Echo -------------------------------------------------------------------------------
  64. goto 1
  65. :4
  66. Echo -------------------------------------------------------------------------------
  67. set p==""
  68. set /p p= 请输入您要设置的密码并回车:
  69. Echo -------------------------------------------------------------------------------
  70. Echo 密码性质
  71. Echo a:永久性密码
  72. Echo b:临时性密码
  73. Echo -------------------------------------------------------------------------------
  74. set q==""
  75. set /p q= 请输入您的选择并回车:
  76. if /I "%q%"=="a" netsh wlan set hostednetwork key="%p%" keyUsage=persistent
  77. if /I "%q%"=="b" netsh wlan set hostednetwork key="%p%" keyUsage=temporary
  78. Echo -------------------------------------------------------------------------------
  79. pause
  80. Echo -------------------------------------------------------------------------------
  81. goto 1
  82. :5
  83. Echo -------------------------------------------------------------------------------
  84. netsh wlan start hostednetwork
  85. Echo -------------------------------------------------------------------------------
  86. pause
  87. Echo -------------------------------------------------------------------------------
  88. goto 1
  89. :6
  90. Echo -------------------------------------------------------------------------------
  91. netsh wlan stop hostednetwork
  92. Echo -------------------------------------------------------------------------------
  93. pause
  94. Echo -------------------------------------------------------------------------------
  95. goto 1
  96. :7
  97. Echo -------------------------------------------------------------------------------
  98. netsh wlan show drivers
  99. Echo -------------------------------------------------------------------------------
  100. pause
  101. Echo -------------------------------------------------------------------------------
  102. goto 1
  103. :8
  104. Echo -------------------------------------------------------------------------------
  105. netsh wlan show hostednetwork
  106. pause
  107. goto 1
  108. :9
  109. Echo -------------------------------------------------------------------------------
  110. netsh wlan show hostednetwork setting=security>>ssid.txt
  111. setlocal enabledelayedexpansion
  112. for /f "delims=" %%a in (ssid.txt) do (
  113. set /a m+=1
  114. if !m!==6 set a=%%a
  115. )
  116. netsh wlan show hostednetwork>>key.txt
  117. setlocal enabledelayedexpansion
  118. for /f "delims=" %%b in (key.txt) do (
  119. set /a n+=1
  120. if !n!==4 set b=%%b
  121. )
  122. Echo -------------------------------------------------------------------------------
  123. Echo %b%
  124. Echo %a%
  125. Echo -------------------------------------------------------------------------------
  126. Echo off
  127. del ssid.txt
  128. del key.txt
  129. pause
  130. goto 1
  131. :10
  132. shutdown /s
  133. :11
  134. Echo -------------------------------------------------------------------------------
  135. reg query hkcr\DesktopBackground\Shell\VirWifi >nul 2>nul && goto DelVirtualWifi || goto CreateVirtualWifi
  136. Echo -------------------------------------------------------------------------------
  137. :CreateVirtualWifi
  138. reg add hkcr\DesktopBackground\Shell\VirWifi /ve /t reg_sz /d "开启虚拟WIFI" /f >nul 2>nul
  139. reg add hkcr\DesktopBackground\Shell\VirWifi\command /ve /t reg_sz /d "cmd /c reg query hkcr\DesktopBackground\Shell\VirWifi /ve | find """关闭虚拟WIFI""" >nul 2>nul && (netsh wlan stop hostednetwork >nul 2>nul & reg add hkcr\DesktopBackground\Shell\VirWifi /ve /t reg_sz /d """开启虚拟WIFI""" /f >nul 2>nul) || (netsh wlan start hostednetwork >nul 2>nul & reg add hkcr\DesktopBackground\Shell\VirWifi /ve /t reg_sz /d """关闭虚拟WIFI""" /f >nul 2>nul)" /f >nul 2>nul
  140. schtasks /create /ru system /tn RestVirWIFI /sc onstart /tr "cmd /c reg add hkcr\DesktopBackground\Shell\VirWifi /ve /t reg_sz /d """开启虚拟WIFI""" /f >nul 2>nul" /f >nul 2>nul
  141. echo 已将开关虚拟WIFI添加到桌面右击菜单中.
  142. echo 添加计划任务,系统每次开机都重新初始化虚拟WIFI的显示状态。
  143. Echo -------------------------------------------------------------------------------
  144. pause >nul
  145. goto 1
  146. :DelVirtualWifi
  147. echo 确定真的要删除虚拟WIFI?按任意键继续删除,放弃请直接关闭窗口。
  148. pause >nul
  149. reg delete hkcr\DesktopBackground\Shell\VirWifi /f >nul 2>nul
  150. schtasks /delete /tn RestVirWIFI /f >nul 2>nul
  151. echo 删除成功,按任意键退出。
  152. pause >nul
  153. goto 1
复制代码

作者: 路过    时间: 2015-9-3 21:03

头衔低是硬伤啊
作者: erjnasrtnws    时间: 2016-1-7 08:10

横强大的   谢谢你的分享!!!




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2