# Code to change wifi password

**URL:** <https://forum.genieacs.com/t/code-to-change-wifi-password/2603>\
**Category:** Uncategorized\
**Created:** [April 30, 2022, 12:24am UTC](https://forum.genieacs.com/t/code-to-change-wifi-password/2603 "2022-04-30T00:24:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![wisar](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@wisar](https://forum.genieacs.com/u/wisar)\
**Post date:** [April 30, 2022, 12:24am UTC](https://forum.genieacs.com/t/code-to-change-wifi-password/2603/1 "2022-04-30T00:24:34Z")

</div>

Good evening,

I have a query, it is possible to make a configuration so that with the same line of command you can change the password of the Wi-Fi network of different onts, since depending on the brand, the route to change the password varies.

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [April 30, 2022, 12:43am UTC](https://forum.genieacs.com/t/code-to-change-wifi-password/2603/2 "2022-04-30T00:43:18Z")

</div>

Yes, its called a [virtual parameter](https://docs.genieacs.com/en/latest/virtual-parameters.html). Third example is for wifi passphrase.

---

<div class="post-metadata">

**Author:** ![wisar](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@wisar](https://forum.genieacs.com/u/wisar)\
**Post date:** [April 30, 2022, 5:44pm UTC](https://forum.genieacs.com/t/code-to-change-wifi-password/2603/3 "2022-04-30T17:44:28Z")

</div>

Good afternoon,  
Thank you very much for the information, I added the virtual parameter according to the page and also added it in the List of provisions “declare(“VirtualParameters.wifipassword”, {value: Date.now()});”, but nevertheless in an ont tp-link it continues to come out with the same route, am I doing something wrong?

 ![Captura1](https://canada1.discourse-cdn.com/flex035/uploads/genieacs/original/1X/a8a81ceb5adc4e0ee1e71e2a5900820128527ec6.png)  
 ![Captura2](https://canada1.discourse-cdn.com/flex035/uploads/genieacs/original/1X/66a6e116c09e20b639289b5c11a6f61fd4107015.png)  
 ![Captura3](https://canada1.discourse-cdn.com/flex035/uploads/genieacs/original/1X/82532671f2e3f92e610f894a08c84d0e9bc881f1.png)

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [April 30, 2022, 6:09pm UTC](https://forum.genieacs.com/t/code-to-change-wifi-password/2603/4 "2022-04-30T18:09:04Z")

</div>

You used the vparam verbatim. You need to adapt it to your equipment. If you need paid, professional help to do that, you should email [sales@genieacs.com](mailto:sales@genieacs.com) and engage them with a support contract.

---

<div class="post-metadata">

**Author:** ![smartolt](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/smartolt/32/1502_2.png) [@smartolt](https://forum.genieacs.com/u/smartolt)\
**Post date:** [April 6, 2023, 3:51pm UTC](https://forum.genieacs.com/t/code-to-change-wifi-password/2603/5 "2023-04-06T15:51:18Z")

</div>

sir i cant get return back responce from sales team.

---

<div class="post-metadata">

**Author:** ![Victor](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/victor/32/1313_2.png) [@Victor](https://forum.genieacs.com/u/Victor)\
**Post date:** [May 24, 2023, 5:08pm UTC](https://forum.genieacs.com/t/code-to-change-wifi-password/2603/7 "2023-05-24T17:08:20Z")

</div>

How do I do it for some routers

```auto
let password = "";

const is_tplink = declare("DeviceID.Manufacturer", {value: Date.now()}).value[0] === "TP-Link" ? true : false;
const is_dlink = declare("DeviceID.Manufacturer", {value: Date.now()}).value[0] === "D-LINK" ? true : false;
const is_nokia = declare("DeviceID.Manufacturer", {value: Date.now()}).value[0] === "ALCL" ? true : false;
const is_zte = declare("DeviceID.Manufacturer", {value: Date.now()}).value[0] === "ZTE" ? true : false;

if (args[1].value) {
  password = args[1].value[0];
  
  if(is_tplink) { 
  	  declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.X_TP_PreSharedKey", null, {value: password})
  }
  if (is_dlink) {
      declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.KeyPassphrase", null, {value: password});
  }
  if (is_nokia) {
      declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.KeyPassphrase", null, {value: password});
  }
  if (is_zte) {
      declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.KeyPassphrase", null, {value: password});
  }
}
else {
  if(is_tplink) {
      password = declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.X_TP_PreSharedKey", {value: Date.now()}).value[0];
  }
  if (is_dlink) {
      password = declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.KeyPassphrase", {value: Date.now()}).value[0];
  }
  if (is_nokia) {
      password = declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.KeyPassphrase", {value: Date.now()}).value[0];
  }
  if (is_zte) {
      password = declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.KeyPassphrase", {value: Date.now()}).value[0];
  }
}

return {writable: true, value: [password, "xsd:string"]};

```

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [May 24, 2023, 7:43pm UTC](https://forum.genieacs.com/t/code-to-change-wifi-password/2603/8 "2023-05-24T19:43:49Z")

</div>

Your ternary can be simplified to this:

```auto
const model = declare("DeviceID.Manufacturer", {value: Date.now()}).value[0];
const is_tplink = model === "TP-Link";
const is_dlink = model === "D-LINK";
const is_nokia = model === "ALCL";
const is_zte = model === "ZTE";

```

The result of a `===` is always a boolean, there is no need to use a ternary operator.

---

<div class="post-metadata">

**Author:** ![galeober](https://avatars.discourse-cdn.com/v4/letter/g/f04885/32.png) [@galeober](https://forum.genieacs.com/u/galeober)\
**Post date:** [March 19, 2024, 6:35pm UTC](https://forum.genieacs.com/t/code-to-change-wifi-password/2603/10 "2024-03-19T18:35:03Z")

</div>

Very Interest!  
Thanks!
