![](/img/trans.png)
[英]Run hide cmd.exe from website (using javascript or VBScript)
[英]Run cmd.exe with specified parametrs from Javascript
Colls,我編寫了一個腳本,該腳本應:
將文件從C:\\ PR \\ DataFiles \\ Input \\ CL_CH5 \\“ + k +” \\ ext_028042012.dat復制到C:\\ PR \\ DataFiles \\ Input \\ ext_028042012.dat-正常
使用指定的命令行運行cmd.exe(p.3)
運行cmd.exe后,腳本應轉到c:磁盤,然后將目錄更改為c:/ pr,然后在cmd行“ process.bat c:\\ pr ext_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!!!");
您的命令字符串,
"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"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.