cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
MarcB
Level II

Using RunProgram to start cmd.exe and execute commands

I want to use RunProgram to run an executable like notepad.exe through cmd.exe.

The below will return the correct directory but when I add another command to the options list "notepad.exe" I get an error that the system cannot find the path specified.

cmd1 = "/k cd /d " || "C:\Windows\System32";
RP = RunProgram(
	Executable( "CMD.EXE"),
	Options( {cmd1} ),	
	ReadFunction("text")
);

I have also seen this error a few times and don't fully understand what it is saying. How can this be remedied?

The external program was producing output when the RunProgram object was destroyed.
Use a JSL variable to hold the RunProgram object.
Optionally, send messages to the variable to manage the object's lifetime.
1 ACCEPTED SOLUTION

Accepted Solutions
gzmorgan0
Super User (Alumni)

Re: Using RunProgram to start cmd.exe and execute commands

You should look at example 3 in the Help > Scripting Index > Functions>Run Program.

Attached is a script written for chapter 9 of JSL Companion, Applications of the JMP Scripting Languge, Second Edition.  It includes multiple methods for reading multiple commands; multple commands to one program, or multiple DOS commands.  See example #5 in this script for multiple dos commands (cd, dir, etc.) The discussion notes start on line 199 and the JSL is on line  253 to 287. 

 

If you are just wanting to take notes, during your session, here is a simple script that does not require Run Program.

Names Default to Here(1);

noteslst ={};
InsertInto(noteslst, char(AsDate(Today()))|| " Notes");
InsertInto(noteslst, "Hello, World!");
InsertInto(noteslst,"It's hot here, 99 degrees");
InsertInto(noteslst,"Time to cool off");
InsertInto(noteslst,"Good Bye");

xtxt = Concat Items(noteslst,"\!N");
Save Text File( "c:\temp\July23Notes.txt" , xtxt);

View solution in original post

2 REPLIES 2
gzmorgan0
Super User (Alumni)

Re: Using RunProgram to start cmd.exe and execute commands

You should look at example 3 in the Help > Scripting Index > Functions>Run Program.

Attached is a script written for chapter 9 of JSL Companion, Applications of the JMP Scripting Languge, Second Edition.  It includes multiple methods for reading multiple commands; multple commands to one program, or multiple DOS commands.  See example #5 in this script for multiple dos commands (cd, dir, etc.) The discussion notes start on line 199 and the JSL is on line  253 to 287. 

 

If you are just wanting to take notes, during your session, here is a simple script that does not require Run Program.

Names Default to Here(1);

noteslst ={};
InsertInto(noteslst, char(AsDate(Today()))|| " Notes");
InsertInto(noteslst, "Hello, World!");
InsertInto(noteslst,"It's hot here, 99 degrees");
InsertInto(noteslst,"Time to cool off");
InsertInto(noteslst,"Good Bye");

xtxt = Concat Items(noteslst,"\!N");
Save Text File( "c:\temp\July23Notes.txt" , xtxt);
MarcB
Level II

Re: Using RunProgram to start cmd.exe and execute commands

perfect, thanks.  I can't believe i've never noticed the multiple example drop down list.