WSH problem
har fundet følgende på nettet og det virker okay.// Create the WSHExt object to extend the WSH
// with the WSHShell method.
var Wsh = WScript.CreateObject("WSHExtend.WinExt");
// launch Windows calculator
var ProcID_Calc = Wsh.WSHShell ("Calc.exe",1);
// launch Windows editor
var ProcID_NotePad = Wsh.WSHShell ("Notepad.exe",1);
// set focus to the calculator window and check
// whether the activation is succesful
var status = Wsh.WSHAppActivate (ProcID_Calc);
// just calculate something
Wsh.WSHSendKeys ("10", true);
Wsh.WSHSendKeys ("{+}", true);
Wsh.WSHSendKeys ("2", true);
Wsh.WSHSendKeys ("=", true);
// result into clipboard
Wsh.WSHSendKeys ("^{c}", true);
WScript.Echo ("Close calculator, write text into editor window.");
// set focus to the editor window and check
// whether the activation is succesful
var status = Wsh.WSHAppActivate (ProcID_NotePad);
// write text into the editor window
// first insert result from the clipboard
Wsh.WSHSendKeys ("Calculation Result: ", true);
Wsh.WSHSendKeys ("^{v}", true);
Wsh.WSHSendKeys ("\n\n", true);
// Now write the text 30 times
for (var i = 1; i <=30; i++)
{
Wsh.WSHSendKeys (i + " Hello, World\n", true);
}
// set focus to calc and check
// whether the activation is succesful
var status = Wsh.WSHAppActivate (ProcID_Calc);
// close calc with Alt+F4
Wsh.WSHSendKeys ("%{F4}", true);
// End
Men hvordan får jeg ændre var
ProcID_NotePad = Wsh.WSHShell ("Notepad.exe",1);
til
ProcID_NotePad = Wsh.WSHShell ("c:\windows\system32\notepad.exe",1);
altså hvordan angiver man programmets placering, frem for bare navnet.