Copy link to clipboard
Copied
system('start /min reg add "HKEY_CURRENT_USER\\Software\\abcdefg" /f')
When this code runs, the window flashes
 
var ret = run_cmd('reg add "HKEY_CURRENT_USER\\Software\\abcdefg" /f', false, false);
alert(ret);
/////////////////////////////////////////////////
function run_cmd(cmd, visible, wait)
{
try {
var tmp_name = "tmp.js";
var file = new File(Folder.temp.fsName + "\\" + tmp_name);
file.open("w");
file.encoding = "UNICODE-1-1-UTF-8";
if (file.error) throw(file.error);
file.writeln("WScript.CreateObject(\"WScript.Shell\").Run(" + cmd.toSourc
...
Copy link to clipboard
Copied
what exactly are your trying to do?
Copy link to clipboard
Copied
I want to write to the registry and use this line of code to write to the registry when there is an error in the script
system('start /min reg add "HKEY_CURRENT_USER\\Software\\abcdefg" /f')
Copy link to clipboard
Copied
what are you trying to write something to the registry?
why are you trying to write something to the registry?
Copy link to clipboard
Copied
The line of code I sent can be written to the registry, but a flashing console window appears, and I want to be able to hide this window from running
Copy link to clipboard
Copied
var ret = run_cmd('reg add "HKEY_CURRENT_USER\\Software\\abcdefg" /f', false, false);
alert(ret);
/////////////////////////////////////////////////
function run_cmd(cmd, visible, wait)
{
try {
var tmp_name = "tmp.js";
var file = new File(Folder.temp.fsName + "\\" + tmp_name);
file.open("w");
file.encoding = "UNICODE-1-1-UTF-8";
if (file.error) throw(file.error);
file.writeln("WScript.CreateObject(\"WScript.Shell\").Run(" + cmd.toSource() + "," + (visible?"1":"0") + "," + (wait?"true":"false") + ");");
file.writeln("with(new ActiveXObject(\"Scripting.FileSystemObject\")) GetFile(GetSpecialFolder(2).Path+\"\\\\\"+\"" + tmp_name + "\").Delete();");
if (file.error) throw(file.error);
file.close();
file.execute();
var ok = false;
try {
while (1)
{
if (!file.exists) { ok = true; break; }
set_performance("stepByStep");
}
}
catch(e) { }
set_performance("accelerated");
return ok;
}
catch(e) { alert(e); }
}
/////////////////////////////////////////////////
function set_performance(mode)
{
try {
var d = new ActionDescriptor();
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("playbackOptions"));
r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
d.putReference(stringIDToTypeID("null"), r);
var d1 = new ActionDescriptor();
d1.putEnumerated(stringIDToTypeID("performance"), stringIDToTypeID("performance"), stringIDToTypeID(mode));
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("playbackOptions"), d1);
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
}
catch (e) { throw(e); }
}