Reputation: 2520
Colls, I wrote a script which should:
copy a file from C:\PR\DataFiles\Input\CL_CH5\"+k+"\ext_028042012.dat to C:\PR\DataFiles\Input\ext_028042012.dat - works fine
run cmd.exe with specified command line (p.3)
after runing cmd.exe, script should go to c: disk, than change directory to c:/pr, then write in cmd line «process.bat c:\pr ext_028042012.dat auto» and press Enter.
Code is:
var fso = new ActiveXObject("Scripting.FileSystemObject");
for (var k = -2; k <= 0; k++)
{
var out_dir = "C:\\PROBE\\DataFiles\\Input\\CL_CH5";
// now i am copying a ext_028042012 to destination folder
fso.CopyFile("C:\\PR\\DataFiles\\Input\\CL_CH5\\"+k+"\\ext_028042012.dat",
"C:\\PR\\DataFiles\\Input\\ext_028042012.dat", 1);
WScript.Echo(k+"file copied.");
/*Block which run cmd window*/
//The following code should open a command window, changes to the path to C:\ , and executes the DIR command.
var oShell = WScript.CreateObject ("WScript.Shell");
**oShell.run ("cmd /K cd c:\pr /K process.bat c:\ext_028042012.dat auto");**
WScript.Echo(k+ "file proceed!!!");
Upvotes: 0
Views: 2211
Reputation: 42870
Your command string,
"cmd /K cd c:\pr /K process.bat c:\ext_028042012.dat auto"
looks erroneous. I don't believe you can specify several /K
commands like that - and since the meaning of /K
is "Carry out the command and continue" never ending the first shell you launch.
Have you tried:
"cmd /K cd c:\pr && process.bat c:\ext_028042012.dat auto"
Upvotes: 1