0

Colls, I wrote a script which should:

  1. copy a file from C:\PR\DataFiles\Input\CL_CH5\"+k+"\ext_028042012.dat to C:\PR\DataFiles\Input\ext_028042012.dat - works fine

  2. run cmd.exe with specified command line (p.3)

  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!!!"); 
  1. Unfortunatly, it doesn't work. Script doesn't put command line from p.3 to opened cmd.exe window. Please, tell me where is my mistake. Thank you a lot.
1
  • What error you get? And how you run it? Commented Apr 30, 2012 at 5:18

1 Answer 1

1

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" 
Sign up to request clarification or add additional context in comments.

3 Comments

result: 'The system cannot find the path specified. C:\PR\DataFiles\Input>' - nothing changes =(
Is that error from the fso.CopyFile line, or is something within process.bat? Does the folder exist?
exactly!!! there was problem with in incorrect path. also i should use double slash instead "\". Do you want to let cmd.exe know wait for pressing enter after "c:\pr && process.bat c:\ext_028042012.dat auto"? i try to use \k and \c, but have no effect.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.