複数のCMDコマンドを実行するにはどうすればよいですか?こんにちは、
コマンドプロンプトを使用してJMPからzipファイル(TGZ)を簡単に抽出しようとしていますが、次のアプローチを使用してそれを行うことはできません(多くのばかげたアイデアを試しましたが、どれもうまくいかないようです...) :
Names Default To Here( 1 );
path1="C:/Users/niros/Downloads/";
path2="C:/Program Files/WinRAR/WinRAR.exe";
path3="C:/Users/niros/Downloads/LP.tgz";
RP = RunProgram(
Executable( "CMD.EXE" ),
Options( { {"cd", path1}, {"mkdir", "testing"}, {"cd", "testing"}, {path2,"x", path3} } ),
Read Function("text")
);
ありがとう!
スクリプティングRe:複数のCMDコマンドを実行するにはどうすればよいですか?スクリプトインデックスの例3
RunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeRunProgram set up to feed commands to CMD.exeコマンドをCMD.exeにフィードするように設定されたRunProgram
片道です。
別の方法は、パラメーター内でコマンドセパレーターを使用することです。 例1から変更:
RP = Run Program(
Executable( "CMD.EXE"/*path probably not needed*/ ),
Options( {"/a", "/q", "/c dir && echo hello && ping localhost"} ),
ReadFunction( Function( {this}, Write( this << read ) ) )
);
(上記の両方は、実行時にcmd.exeから読み取り、JMPログに回答を書き込むように設定されています。 readfunction( "text")を使用した元の例は、すべての出力を収集して最後に表示する、より単純で柔軟性の低い方法です。)
Re:複数のCMDコマンドを実行するにはどうすればよいですか?すべてのコマンドを1つのCMDファイルに書き込んで実行することもできます。
path1="C:/Users/niros/Downloads/";
path2="C:/Program Files/WinRAR/WinRAR.exe";
path3="C:/Users/niros/Downloads/LP.tgz";
//-------------------------------------------------------------------------------
// Create a command file to run multiple commands
cmd_file_text = evalinsert(
"rem Run multiple commands\!N
C:\!N
cd ^path1^\!N
mkdir testing\!N
cd testing\!N
^path2^ x ^path3^\!N
pause\!N
");
cmd_file_name = "c:\temp\run_commands.cmd";
// Save command file to disk
save text file(cmd_file_name, cmd_file_text, mode("replace"));
//-------------------------------------------------------------------------------
// The /c option carries out the command before terminating
run_cmds = runprogram(executable("cmd.exe"), options("/c " || cmd_file_name), readfunction("text"));
nw = new window("Output", << modal,
panel box("CMD output:",
text box(run_cmds, set width(800), set wrap(800),
<< Set Font( "Courier New" )),
)
);
Re:複数のCMDコマンドを実行するにはどうすればよいですか?価値のあることとして、RunProgramの使用には注意が必要です... 私たちのほとんどは、それを機能させる前に、多くのばかげたアイデアを試さなければならないのではないかと思います:)
Re:複数のCMDコマンドを実行するにはどうすればよいですか?「\!N」を使用してJSLによって生成された.cmdファイルにハードリターンを追加する必要がありました。
Re:複数のCMDコマンドを実行するにはどうすればよいですか?いつもありがとう! PMROZあなたの答えはまさに私が探していたものです!
私の最後の欠点は、\!"文字で簡単に解決できるパスのスペースです...
解決:
path1="C:/Users/niros/Downloads/";
path2="\!"C:/Program Files/WinRAR/WinRAR.exe\!"";
path3="C:/Users/niros/Downloads/LP.tgz";
//-------------------------------------------------------------------------------
// Create a command file to run multiple commands
cmd_file_text = evalinsert(
"rem Run multiple commands\!N
cd ^path1^\!N
mkdir testing\!N
cd testing\!N
^path2^ x ^path3^\!N
pause\!N
");
cmd_file_name = "c:\temp\run_commands.cmd";
// Save command file to disk
save text file(cmd_file_name, cmd_file_text, mode("replace"));
//-------------------------------------------------------------------------------
// The /c option carries out the command before terminating
run_cmds = runprogram(executable("cmd.exe"), options("/c " || cmd_file_name), readfunction("text"));
nw = new window("Output", << modal,
panel box("CMD output:",
text box(run_cmds, set width(800), set wrap(800),
<< Set Font( "Courier New" )),
)
);