Colls,我写了一个脚本应该:
将文件从C:\ PR \ DataFiles \ Input \ CL_CH5 \“+ k +”\ ext_028042012.dat复制到C:\ PR \ DataFiles \ Input \ ext_028042012.dat - 工作正常
< / LI>使用指定的命令行运行cmd.exe(p.3)
运行cmd.exe后,脚本应该转到c:disk,而不是将目录更改为c:/ pr,然后写入cmd行«process.bat c:\ pr \ text_028042012.dat auto»并按Enter键。
代码:
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!!!");
答案 0 :(得分:1)
您的command字符串,
"cmd /K cd c:\pr /K process.bat c:\ext_028042012.dat auto"
看起来很错误。我不相信你可以指定这样的几个/K
命令 - 因为/K
的含义是“执行命令并继续”永远不会结束第一个shell你发射。
你试过了吗?
"cmd /K cd c:\pr && process.bat c:\ext_028042012.dat auto"