Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Opening a Command Prompt and entering a command

Community Beginner ,
May 01, 2019 May 01, 2019

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

TOPICS
Scripting
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , May 01, 2019 May 01, 2019

Create a batch file and execute that.

Translate
Advocate ,
May 01, 2019 May 01, 2019

Create a batch file and execute that.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 01, 2019 May 01, 2019
LATEST

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();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines