Forum Discussion
computer
6 years agoNew Contributor
I am using Javascript. here is example code snippet,
var url = "10.10.199.22";
var username = "WIN7-Test01\admin";
var password = "password";
Sys.OleObject("WScript.Shell").Run("cmdkey /add:" + url + " /User:" + username + " /pass:" + password );
WIN7-Test01\admin becomes WIN7-Test01admin
WIN7-Test01\\admin becomes WIN7-Test01\\admin
WIN7-Test01\\\admin becomes WIN7-Test01\\admin
Thanks.
tristaanogre
6 years agoEsteemed Contributor
Because it's JavaScript, you need to make sure that the \ is "escaped" properly. The proper way to process this is as so:
var url = "10.10.199.22";
var username = "WIN7-Test01\\admin";
var password = "password";
Sys.OleObject("WScript.Shell").Run("cmdkey /add:" + url + " /User:" + username + " /pass:" + password );
This will work. While you are correct, the string reflects the \\, when it's actually interpreted into the Run command, it will have the proper number of characters.