对于Wi-Fi配置更改密码 [英] Change the password for a Wi-Fi profile

查看:171
本文介绍了对于Wi-Fi配置更改密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在长期护理医院,在那里我的志愿,在每个月的第一天,密码为Guest Wi-Fi连接的变化。这会导致员工大量的工作,并为病人太多的无奈,许多人有非常有限的流动性。

(是的,真正的解决办法是让IT团队保持相同的密码,但是这不会发生)。

大部分患者通过Windows的笔记本电脑连接到外面的世界。我想创建一个批处理脚本,我们可以在他们的计算机上安装,它会自动检索下月密码,只要在需要使用它。

我可以在医院的内部网络,它只能由人谁目前拥有本月的密码来访问一个文件放在下个月的客户密码,我可以使用的bitsadmin 批处理脚本找回密码到本地文件中(见下文)。我可以设置每个病人的计算机上的任务只是在月底前运行此脚本。

我的问题是:当上个月的密码,在新月初出现故障,我该怎么更改密码从一个批处理脚本的网络连接。

我知道,我可以使用...

 的netsh wlan的节目配置文件名称=INSERT_SSID_HERE键=明确

...查找当前密码,但我怎么能设置呢?


编辑:我在Windows Vista中发现了 及以上,在Wi-Fi密码被保存在一个XML文件 C:\\ ProgramData \\微软\\ WLANSVC \\ Profiles文件\\接口[接口的Guid]的.xml 。它出现在格式为:

   - < sharedKey>
    <&关键字类型GT;&密语LT; /关键字类型>
    &所述经保护GT;真&下; /受保护的>
    < keyMaterial> ** 400 + hexit号**< / keyMaterial>
  < / sharedKey>

我猜测,更改密码,我需要使用适当的算法来加密新密码并更新此XML文件。有没有我可以用它来自动执行此命令?如果不是这样,我应该用什么样的加密算法?

一个简单的替代可能是删除加密:

 <受到保护的GT假LT; /保护>
    < keyMaterial> plainTextPassword< / keyMaterial>

然而,当我尝试重新启动重新启动计算机,使用已被修改这样一个XML文件后,Wi-Fi连接,连接失败。


不需要重新启动的解决方案是preferable。


批处理脚本,以获取密码:

 关闭@echo
SETLOCAL
设置文件=%〜dp0result.txt
的bitsadmin /复位
的bitsadmin /制作/下载作业
的bitsadmin / addfile工作http://example.com/password.html%文件%
的bitsadmin /恢复工作超时5的bitsadmin /工作有getstate |查找/ I转职&放大器;&安培;转到:完成
的bitsadmin /取消作业
退出/ B 1:完成
的bitsadmin /完整的工作
:: RESULTS.TXT现在拥有新密码
退出/ B 0


你有没有尝试删除并重新添加该配置文件,而不是仅仅改变了XML的内容,使用普通密码?

我在过去类似的情况,这是对我工作:

这个答案假定您希望在网络,而不是一个完整的XML和无线网络的SSID上只保留了WiFi密码是我的网络


  1. 从网络断开连接:的netsh wlan的断开

  2. 导出我的网络配置文件到别的地方,例如 C:\\ Netsh的WLAN导出配置文件文件夹=C:\\NAME =我的网络键=清除 - >这应该创建 C:\\ Wi-Fi的我Network.xml 。由此产生的 XML 文件应该是类似于您在中看到的C:\\ ProgramData \\微软\\ WLANSVC \\ Profiles文件\\接口,但与< sharedKey> 部分未受保护的(这让我们只能做一个替换的下一步)。很明显,你也可以通过复制 WLANSVC 的个人资料目录中的文件,但这样做这样做,所以需要对界面的GUID的知识。导出很容易,你只需要知道你的SSID。

  3. 在复制的配置文件,确保保护,并填写 keyMaterial 通过明文口令(简单的文本替换,应该很容易用VB或C#做的,但如果你需要做纯粹它批处理脚本,请参阅Changing使用Windows批处理文件)在XML文件中的标记数据

  4. 删除当前存储的配置文件:的netsh wlan的删除配置文件名称=我的网络

  5. 添加回配置文件:的netsh wlan的添加会员名=C:\\ Wi-Fi的我Network.xml。结果
    (这将重新创建相应的文件:C:\\ ProgramData \\微软\\ WLANSVC \\ Profiles文件\\接口,使用加密密码)

  6. 连接到网络:的netsh WLAN连接的名称=我的网络

如果你是好与存储完整的XML,也可以导出配置文件加密(步骤2),并将其存储在您的网络驱动器,那么你只需要执行步骤1,4,5和6。

我希望这有助于。

In the long-term care hospital where I volunteer, on the first day of every month, the password for the Guest Wi-Fi connection changes. This causes a lot of work for the staff and a lot of frustration for the patients, many of whom have very limited mobility.

(Yes, the real solution is to get the IT team to keep the same password, but that's not going to happen).

Most of the patients connect to the outside world through Windows laptops. I'd like to create a batch script that we can install on their computers that will automatically retrieve the password for the coming month and apply it as soon as it is needed.

I can put next month's Guest password in a file on the hospital's internal network, where it can only be accessed by someone who currently has this month's password, and I can use bitsadmin inside a batch script to retrieve the password to a local file (see below). I can set up a task on each patient's computer to run this script just before the end of the month.

My question is: when last month's password fails at the beginning of the new month, how can I change the password for that network connection from a batch script?

I know that I can use...

netsh wlan show profile name="INSERT_SSID_HERE" key=clear

... to find the current password, but how can I set it?


EDIT: I have found that in Windows Vista and up, the Wi-Fi passphrase is stored in an XML file at C:\ProgramData\Microsoft\Wlansvc\Profiles\Interfaces[Interface Guid].xml. It appears in the format:

- <sharedKey>
    <keyType>passPhrase</keyType>
    <protected>true</protected>
    <keyMaterial> ** 400+ hexit number ** </keyMaterial>
  </sharedKey>

I am guessing that to change the password, I need to encrypt the new password using the appropriate algorithm and update this XML file. Is there a command that I can use to do this automatically? If not, what encryption algorithm should I use?

A simpler alternative might be to remove the encryption:

    <protected>false</protected>
    <keyMaterial>plainTextPassword</keyMaterial>

However, when I try to relaunch the Wi-Fi connection after rebooting the computer, using an XML file that has been modified this way, the connection fails.


A solution which does not require a reboot is preferable.


Batch script to retrieve password:

@echo off
setlocal
set file=%~dp0result.txt
bitsadmin /reset
bitsadmin /create /download job
bitsadmin /addfile job http://example.com/password.html %file%
bitsadmin /resume job

timeout 5

bitsadmin /getstate job | find /i "TRANSFERRED" && goto :done
bitsadmin /cancel job
exit /b 1

:done
bitsadmin /complete job
:: results.txt now holds the new password
exit /b 0

解决方案

Did you try removing and re-adding the profile instead of just changing the content of the XML to use plain password?

I had a similar situation in the past and this is what worked for me:

This answer assumes that you want to keep only the WiFi password on the network instead of a full XML and the SSID of the WiFi is "My Network".

  1. Disconnect from the network: netsh wlan disconnect
  2. Export the "My Network" profile to somewhere else, e.g. C:\: netsh wlan export profile folder="C:\" name="My Network" key=clear --> this should create C:\Wi-Fi-My Network.xml. The resulting xml file should be similar to the one you see in C:\ProgramData\Microsoft\Wlansvc\Profiles\Interfaces, but with the <sharedKey> part unprotected (this allows us to only do one replacement on the next step). Obviously, you can also do this by copying the file from the Wlansvc's profile directory, but doing so requires the knowledge of the interface's GUID. Exporting is easier as you only need to know your SSID.
  3. In the copied profile, make sure that protected is false, and fill the keyMaterial with the plain password (simple text replacement, should be easy to do with VB or C#, but if you need to do it purely in batch script, see Changing tag data in an XML file using windows batch file)
  4. Remove the currently stored profile: netsh wlan delete profile name="My Network"
  5. Add back the profile: netsh wlan add profile filename="C:\Wi-Fi-My Network.xml".
    (This will recreate the appropriate file in C:\ProgramData\Microsoft\Wlansvc\Profiles\Interfaces, with encrypted password.)
  6. Connect to the network: netsh wlan connect name="My Network"

If you are okay with storing the full XML, you can also export the profile unencrypted (step 2) and store it in your network drive, then you simply need to do step 1, 4, 5 and 6.

I hope this helps.

这篇关于对于Wi-Fi配置更改密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆