无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站广告联系 微信:wuyouceo QQ:184822951
查看: 2392|回复: 13

[求助] 请求汉化wifi获取VBS代码

[复制链接]
发表于 2019-1-17 08:38:47 | 显示全部楼层 |阅读模式
最近在一个博客上看到一个获取当前电脑上WIFI密码的VBS,但因为可能作者的操作系统是英文,在中文系统上无法正常运行,希望高手能汉化一下,感谢

网址在这里:https://github.com/0v3rl0w/e013
发表于 2019-1-17 09:43:56 | 显示全部楼层
好的,我知道了啊~~
回复

使用道具 举报

发表于 2019-1-17 10:18:47 | 显示全部楼层
改两个数字就应该可以运行了
If i > 8 And i < Ubound(strText)-1 Then 改为
If i > 9 And i < Ubound(strText)-1 Then

str=Split(GetOutput("netsh wlan show profile """ & Name & """ key=clear"), "\n")(32) 改为
str=Split(GetOutput("netsh wlan show profile """ & Name & """ key=clear"), "\n")(29)
回复

使用道具 举报

发表于 2019-1-17 10:20:24 | 显示全部楼层
完整代码
Function GetOutput(command)
  Set Shell = Wscript.CreateObject("WScript.Shell")
  Set cmd = Shell.Exec("cmd /c  " & command)
  strOut = ""

  Do While Not cmd.StdOut.AtEndOfStream
    strOut = strOut & cmd.StdOut.ReadLine() & "\n"
  Loop
  GetOutput=strOut
End Function

Function saveIt(wifi, passwd)
  wifi = Replace(Replace(wifi, ">", "-"), "<", "-")
  Set objFSO=CreateObject("Scripting.FileSystemObject")
  Set objFile=objFSO.CreateTextFile(wifi & ".txt")
  objFile.Write(passwd)
  objFile.Close
End Function

strText=Split(GetOutput("netsh wlan show profile"), "\n")

i = 0

For Each x in strText
        If i > 9 And i < Ubound(strText)-1 Then
                Name = Split(x, ": ")(1)
                str=Split(GetOutput("netsh wlan show profile """ & Name & """ key=clear"), "\n")(29)
                passwd = Split(str, ": ")
                If Ubound(passwd) Then
                        saveIt Name, passwd(1)
                End If
        End If
        i = i + 1
Next

点评

我直接这样添加的,但是没有效果 Function GetOutput(command) Set Shell = Wscript.CreateObject("WScript.Shell") Set cmd = Shell.Exec("cmd /c " & command) strOut = "" Do While Not cmd.St  详情 回复 发表于 2019-1-17 17:50
大侠您好,能帮稍改一下代码吗? 上面的代码,会创建一个记事本文件,我不想创建文件,我只想让代码运行完后,显示一下网络和密码,像下面这样,能实现吗?感谢!! Wscript.Echo 网络 Wscript.Echo 密码  详情 回复 发表于 2019-1-17 17:46
感谢大侠,刚才试了一下,真的可以运行了  详情 回复 发表于 2019-1-17 17:39
[attachimg]385962[/attachimg] 出来这个提示是什么情况?  详情 回复 发表于 2019-1-17 12:19
回复

使用道具 举报

发表于 2019-1-17 10:23:05 | 显示全部楼层
这个写法不好,如果netsh输出位置变了结果就不对了
回复

使用道具 举报

发表于 2019-1-17 11:44:26 | 显示全部楼层
汉不汉化一个意思,命令行都是英文的,主要看你使用netsh wlan show profile命令后,从第一个冒号开始第几行开始出现SSID,,,修改一下i的值就可以跑起来了。
回复

使用道具 举报

发表于 2019-1-17 12:19:36 | 显示全部楼层
abxy 发表于 2019-1-17 10:20
完整代码
Function GetOutput(command)
  Set Shell = Wscript.CreateObject("WScript.Shell")

2019-1-17 12-18-49.png

出来这个提示是什么情况?

点评

保存为ansi编码  详情 回复 发表于 2019-1-17 17:19
回复

使用道具 举报

发表于 2019-1-17 17:19:30 | 显示全部楼层
zijian2008 发表于 2019-1-17 12:19
出来这个提示是什么情况?

保存为ansi编码

点评

好的,可以运行了,但是只显示“WPA2 - 个人”,不显示wifi名称和wifi密码,这是咋回事儿?  详情 回复 发表于 2019-1-19 09:58
回复

使用道具 举报

 楼主| 发表于 2019-1-17 17:36:35 | 显示全部楼层
各位大侠好,我的表达有误,我其实,是想让代码运行起来,取得和英文系统下代码运行一样的效果
回复

使用道具 举报

 楼主| 发表于 2019-1-17 17:39:36 | 显示全部楼层
abxy 发表于 2019-1-17 10:20
完整代码
Function GetOutput(command)
  Set Shell = Wscript.CreateObject("WScript.Shell")

感谢大侠,刚才试了一下,真的可以运行了
回复

使用道具 举报

 楼主| 发表于 2019-1-17 17:46:45 | 显示全部楼层
abxy 发表于 2019-1-17 10:20
完整代码
Function GetOutput(command)
  Set Shell = Wscript.CreateObject("WScript.Shell")

大侠您好,能帮稍改一下代码吗?

上面的代码,会创建一个记事本文件,我不想创建文件,我只想让代码运行完后,显示一下网络和密码,像下面这样,能实现吗?感谢!!

Wscript.Echo 网络
Wscript.Echo 密码
回复

使用道具 举报

 楼主| 发表于 2019-1-17 17:50:09 | 显示全部楼层
abxy 发表于 2019-1-17 10:20
完整代码
Function GetOutput(command)
  Set Shell = Wscript.CreateObject("WScript.Shell")

我直接这样添加的,但是没有效果

Function GetOutput(command)
  Set Shell = Wscript.CreateObject("WScript.Shell")
  Set cmd = Shell.Exec("cmd /c  " & command)
  strOut = ""

  Do While Not cmd.StdOut.AtEndOfStream
    strOut = strOut & cmd.StdOut.ReadLine() & "\n"
  Loop
  GetOutput=strOut
End Function

Function saveIt(wifi, passwd)
  wifi = Replace(Replace(wifi, ">", "-"), "<", "-")
  Set objFSO=CreateObject("Scripting.FileSystemObject")
  Set objFile=objFSO.CreateTextFile(wifi & ".txt")
  objFile.Write(passwd)
  objFile.Close
End Function

strText=Split(GetOutput("netsh wlan show profile"), "\n")

i = 0

For Each x in strText
        If i > 9 And i < Ubound(strText)-1 Then
                Name = Split(x, ": ")(1)
                str=Split(GetOutput("netsh wlan show profile """ & Name & """ key=clear"), "\n")(29)
                passwd = Split(str, ": ")
                If Ubound(passwd) Then
                        saveIt Name, passwd(1)
                End If
        End If
        i = i + 1
Next

Wscript.Echo passwd
Wscript.Echo wifi
回复

使用道具 举报

发表于 2019-1-17 19:47:08 | 显示全部楼层
本帖最后由 610644034 于 2019-1-17 19:48 编辑

感谢分享精神!我Win8.1 跑起来了, 技术关键在:cmd 命令用:

netsh wlan show profile “WIFI名” key=clear

这个命令可以在cmd 显示连接过的WIFI密码!

而取密码只是从cmd里面取哪一行的哪一位置的字符串是WIFI密码而已!
回复

使用道具 举报

发表于 2019-1-19 09:58:09 | 显示全部楼层

好的,可以运行了,但是只显示“WPA2 - 个人”,不显示wifi名称和wifi密码,这是咋回事儿?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2024-3-28 17:59

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表