返回列表 发帖

[系统相关] 使用netsh命令获取连接wifi的密码时,出现问题

是命令行中执行
netsh wlan show profiles name="HYS" key=clearCOPY
时,能正常返回wifi密码,
但是用批处理时,就出现问题,如下
for /f "delims=" %xx in ('netsh wlan show profiles name="HYS" key=clear') do echo %xxCOPY
该命令的一个或多个参数错误或缺少。
用法: show profiles [[name=]<string>] [interface=<string>] [key=<string>]
参数:
    标记            值
    name          - 所要显示配置文件的名称。
    interface     - 已配置此配置文件的接口的名称。
    key           - 以纯文件显示密钥,设置密钥=clear。
注释:
    显示配置文件数据或列出系统上的配置文件。
    参数 name 和 interface 都是可选的。
    如果已给定配置文件名称,则将会显示配置文件的内容。否则,将仅列出配置文件
    名称和描述。
    如果已给定接口名称,则将仅列出给定接口上的指定配置文件。否则,将列出
    系统中给定名称的所有配置文件。
    如果将密钥设置为 "clear",且呼叫方为本地管理员,
    则该密钥将以纯文本显示。
    组策略配置文件为只读,而用户配置文件是
    可读写的,而且,首选顺序也可以更改。
示例:
    show profiles name="profile 1" interface="Wireless Network Connection"
    show profiles name="profile 2"
    show profiles name="profile 3" key=clear
    show profiles

求助大神帮忙分析看看是啥原因

%xx改为%%x

TOP

回复 1# shootman2

改用以下代码应该可以了...
for /f "delims=" %%x in (' "netsh wlan show profiles name=HYS key=clear" ') do echo,%%xCOPY

TOP

回复 3# aloha20200628


    好了,太牛了

    这是啥原理呢?大神

TOP



如图,只有被双引号包裹的delims= 中的等号还是等号,其它包括 逗号、分号、制表符,全变成空格了
bat小白,请多指教!谢谢!

TOP

返回列表