07-24-2023, 04:28 AM
I want to make a bat file that prompt user with a default value. All`s fine, I found a CScript way.
But i have a problem with special characters like pharanteses..
bat file is
set "mysql_password="
title MyUniqueTitle
CScript //E:JScript //Nologo "%cscripts_path%\sendkeys.js" "MyUniqueTitle" "&GS)u**,o7,r"
set /p "mysql_password=> Enter new MySQL Password: "
and sendkeys.js
try
{
var WshShell = WScript.CreateObject('WScript.Shell');
var Title = WScript.Arguments.Item(0);
var Message = WScript.Arguments.Item(1);
WshShell.AppActivate(Title);
WshShell.SendKeys(Message)
WScript.Quit(0);
}
catch(e)
{
WScript.Echo(e);
WScript.Quit(1);
}
WScript.Quit(2);
Problem is with WshShell.SendKeys(Message) , here i should use an escape function that put bracets to special characters..
Does anyone know an way to escape Message code from SendKeys?
Thanks!
But i have a problem with special characters like pharanteses..
bat file is
set "mysql_password="
title MyUniqueTitle
CScript //E:JScript //Nologo "%cscripts_path%\sendkeys.js" "MyUniqueTitle" "&GS)u**,o7,r"
set /p "mysql_password=> Enter new MySQL Password: "
and sendkeys.js
try
{
var WshShell = WScript.CreateObject('WScript.Shell');
var Title = WScript.Arguments.Item(0);
var Message = WScript.Arguments.Item(1);
WshShell.AppActivate(Title);
WshShell.SendKeys(Message)
WScript.Quit(0);
}
catch(e)
{
WScript.Echo(e);
WScript.Quit(1);
}
WScript.Quit(2);
Problem is with WshShell.SendKeys(Message) , here i should use an escape function that put bracets to special characters..
Does anyone know an way to escape Message code from SendKeys?
Thanks!