Skip to main content
IntrepidGeophysics
Participant
May 2, 2019
Answered

Opening a Command Prompt and entering a command

  • May 2, 2019
  • 1 reply
  • 1133 views

I am trying to create a script which opens a command prompt and enters a command line.

var cmdpath = "C://WINDOWS/system32/cmd.exe"

var cmdfile =File(cmdpath)

function cmdrun(){

return cmdfile.execute()

}

cmdfile.execute() // hopefully open with command /C dir

This currently opens a command prompt window (or PowerShell if you change the path correctly), but I have yet to find a way to get a command line entered into cmd.

I have read a variety of ways it can be done in other Adobe programs app.system, system.callSystem, etc but have yet to find a method for FrameMaker. I have seen a person reference an app Method() but I am unable to find this reference again.

Cheers

This topic has been closed for replies.
Correct answer 4everJang

Create a batch file and execute that.

1 reply

4everJang
4everJangCorrect answer
Legend
May 2, 2019

Create a batch file and execute that.

IntrepidGeophysics
Participant
May 2, 2019

As 4everJang​ mentioned, the way to do this is to create a new batch file or write to a preexisting batch file.

var commandpath = "C://FilePath/command.bat

var commandfile = File(commandpath)

var command = "ECHO OFF"+"\n"+"dir"+"\n"+"PAUSE";

commandfile.open("w");

commandfile.write(command);

commandfile.close();

commandfile.execute();