cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
%3CLINGO-SUB%20id%3D%22lingo-sub-63700%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E4%BD%BF%E7%94%A8RunProgram%E5%95%9F%E5%8B%95cmd.exe%E4%B8%A6%E5%9F%B7%E8%A1%8C%E5%91%BD%E4%BB%A4%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-63700%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%88%91%E6%83%B3%E4%BD%BF%E7%94%A8%20RunProgram%20%E9%80%9A%E9%81%8E%20cmd.exe%20%E9%81%8B%E8%A1%8C%E5%83%8F%20notepad.exe%20%E9%80%99%E6%A8%A3%E7%9A%84%E5%8F%AF%E5%9F%B7%E8%A1%8C%E6%96%87%E4%BB%B6%E3%80%82%3C%2FP%3E%3CP%3E%E4%B8%8B%E9%9D%A2%E7%9A%84%E5%91%BD%E4%BB%A4%E5%B0%87%E8%BF%94%E5%9B%9E%E6%AD%A3%E7%A2%BA%E7%9A%84%E7%9B%AE%E9%8C%84%EF%BC%8C%E4%BD%86%E6%98%AF%E7%95%B6%E6%88%91%E5%B0%87%E5%8F%A6%E4%B8%80%E5%80%8B%E5%91%BD%E4%BB%A4%E6%B7%BB%E5%8A%A0%E5%88%B0%E9%81%B8%E9%A0%85%E5%88%97%E8%A1%A8%E2%80%9Cnotepad.exe%E2%80%9D%E6%99%82%EF%BC%8C%E5%87%BA%E7%8F%BE%E7%B3%BB%E7%B5%B1%E6%89%BE%E4%B8%8D%E5%88%B0%E6%8C%87%E5%AE%9A%E8%B7%AF%E5%BE%91%E7%9A%84%E9%8C%AF%E8%AA%A4%E3%80%82%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Ecmd1%20%3D%20%22%2Fk%20cd%20%2Fd%20%22%20%7C%7C%20%22C%3A%5CWindows%5CSystem32%22%3B%0ARP%20%3D%20RunProgram(%0A%20Executable(%20%22CMD.EXE%22)%2C%0A%20Options(%20%7Bcmd1%7D%20)%2C%20%0A%20ReadFunction(%22text%22)%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%E6%88%91%E4%B9%9F%E5%A4%9A%E6%AC%A1%E7%9C%8B%E5%88%B0%E9%80%99%E5%80%8B%E9%8C%AF%E8%AA%A4%EF%BC%8C%E4%BD%86%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%90%86%E8%A7%A3%E5%AE%83%E5%9C%A8%E8%AA%AA%E4%BB%80%E9%BA%BC%E3%80%82%20%E5%A6%82%E4%BD%95%E8%A3%9C%E6%95%91%EF%BC%9F%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EThe%20external%20program%20was%20producing%20output%20when%20the%20RunProgram%20object%20was%20destroyed.%0AUse%20a%20JSL%20variable%20to%20hold%20the%20RunProgram%20object.%0AOptionally%2C%20send%20messages%20to%20the%20variable%20to%20manage%20the%20object's%20lifetime.%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-63777%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E4%BD%BF%E7%94%A8%20RunProgram%20%E5%95%9F%E5%8B%95%20cmd.exe%20%E4%B8%A6%E5%9F%B7%E8%A1%8C%E5%91%BD%E4%BB%A4%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-63777%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E5%BE%88%E5%A5%BD%EF%BC%8C%E8%AC%9D%E8%AC%9D%E3%80%82%E6%88%91%E4%B8%8D%E6%95%A2%E7%9B%B8%E4%BF%A1%E6%88%91%E5%BE%9E%E4%BE%86%E6%B2%92%E6%9C%89%E8%A8%BB%E6%84%8F%E5%88%B0%E5%A4%9A%E5%80%8B%E7%A4%BA%E4%BE%8B%E4%B8%8B%E6%8B%89%E5%88%97%E8%A1%A8%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-63720%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E4%BD%BF%E7%94%A8%20RunProgram%20%E5%95%9F%E5%8B%95%20cmd.exe%20%E4%B8%A6%E5%9F%B7%E8%A1%8C%E5%91%BD%E4%BB%A4%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-63720%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%82%A8%E6%87%89%E8%A9%B2%E6%9F%A5%E7%9C%8B%E2%80%9C%E5%B9%AB%E5%8A%A9%E2%80%9D%26gt%3B%E2%80%9C%E8%85%B3%E6%9C%AC%E7%B4%A2%E5%BC%95%E2%80%9D%26gt%3B%E2%80%9C%E5%87%BD%E6%95%B8%E2%80%9D%26gt%3B%E2%80%9C%E9%81%8B%E8%A1%8C%E7%A8%8B%E5%BA%8F%E2%80%9D%E4%B8%AD%E7%9A%84%E7%A4%BA%E4%BE%8B%203%E3%80%82%3C%2FP%3E%3CP%3E%E9%99%84%E4%BB%B6%E6%98%AF%E7%82%BA%E7%AC%AC9%E7%AB%A0%E7%B7%A8%E5%AF%AB%E7%9A%84%E8%85%B3%E6%9C%AC%3CSTRONG%3EJSL%20Companion%EF%BC%8CJMP%20%E8%85%B3%E6%9C%AC%E8%AA%9E%E8%A8%80%E7%9A%84%E6%87%89%E7%94%A8%E7%A8%8B%E5%BA%8F%EF%BC%8C%E7%AC%AC%E4%BA%8C%E7%89%88%3C%2FSTRONG%3E%E3%80%82%E5%8C%85%E5%90%AB%E5%A4%9A%E7%A8%AE%E8%AE%80%E5%8F%96%E5%A4%9A%E6%A2%9D%E5%91%BD%E4%BB%A4%E7%9A%84%E6%96%B9%E6%B3%95%EF%BC%9B%E4%B8%80%E5%80%8B%E7%A8%8B%E5%BA%8F%E7%9A%84%E5%A4%9A%E5%80%8B%E5%91%BD%E4%BB%A4%EF%BC%8C%E6%88%96%E5%A4%9A%E5%80%8B%20DOS%20%E5%91%BD%E4%BB%A4%E3%80%82%E8%AB%8B%E5%8F%83%E9%96%B1%E6%AD%A4%E8%85%B3%E6%9C%AC%E4%B8%AD%E7%9A%84%E7%A4%BA%E4%BE%8B%20%235%20%E4%BA%86%E8%A7%A3%E5%A4%9A%E5%80%8B%20dos%20%E5%91%BD%E4%BB%A4%EF%BC%88cd%E3%80%81dir%20%E7%AD%89%EF%BC%89%E3%80%82%E8%A8%8E%E8%AB%96%E8%A8%BB%E9%87%8B%E5%BE%9E%E7%AC%AC%20199%20%E8%A1%8C%E9%96%8B%E5%A7%8B%EF%BC%8CJSL%20%E4%BD%8D%E6%96%BC%E7%AC%AC%20253%20%E8%87%B3%20287%20%E8%A1%8C%E3%80%82%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%E5%A6%82%E6%9E%9C%E6%82%A8%E5%8F%AA%E6%83%B3%E5%9C%A8%E6%9C%83%E8%A9%B1%E6%9C%9F%E9%96%93%E5%81%9A%E7%AD%86%E8%A8%98%EF%BC%8C%E9%80%99%E8%A3%A1%E6%9C%89%E4%B8%80%E5%80%8B%E4%B8%8D%E9%9C%80%E8%A6%81%E9%81%8B%E8%A1%8C%E7%A8%8B%E5%BA%8F%E7%9A%84%E7%B0%A1%E5%96%AE%E8%85%B3%E6%9C%AC%E3%80%82%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20to%20Here(1)%3B%0A%0Anoteslst%20%3D%7B%7D%3B%0AInsertInto(noteslst%2C%20char(AsDate(Today()))%7C%7C%20%22%20Notes%22)%3B%0AInsertInto(noteslst%2C%20%22Hello%2C%20World!%22)%3B%0AInsertInto(noteslst%2C%22It's%20hot%20here%2C%2099%20degrees%22)%3B%0AInsertInto(noteslst%2C%22Time%20to%20cool%20off%22)%3B%0AInsertInto(noteslst%2C%22Good%20Bye%22)%3B%0A%0Axtxt%20%3D%20Concat%20Items(noteslst%2C%22%5C!N%22)%3B%0ASave%20Text%20File(%20%22c%3A%5Ctemp%5CJuly23Notes.txt%22%20%2C%20xtxt)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
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.