cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
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.