[英]Run cmd.exe with specified parametrs from Javascript
Colls, I wrote a script which should: Colls,我编写了一个脚本,该脚本应:
copy a file from C:\\PR\\DataFiles\\Input\\CL_CH5\\"+k+"\\ext_028042012.dat to C:\\PR\\DataFiles\\Input\\ext_028042012.dat - works fine 将文件从C:\\ PR \\ DataFiles \\ Input \\ CL_CH5 \\“ + k +” \\ ext_028042012.dat复制到C:\\ PR \\ DataFiles \\ Input \\ ext_028042012.dat-正常
run cmd.exe with specified command line (p.3) 使用指定的命令行运行cmd.exe(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. 运行cmd.exe后,脚本应转到c:磁盘,然后将目录更改为c:/ pr,然后在cmd行“ process.bat c:\\ pr ext_028042012.dat auto»中写入并按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!!!");
"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. 我不相信您可以指定几个
/K
命令-而且/K
的含义是“执行命令并继续”,所以永远不会结束您启动的第一个Shell。
Have you tried: 你有没有尝试过:
"cmd /K cd c:\pr && process.bat c:\ext_028042012.dat auto"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.