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

Run .bat file with arguments?

Community Beginner ,
Jul 31, 2009 Jul 31, 2009

Hi,

   I need to run the .bat file with parameters/arguments in Adode Indesign JavaScript. "File.execute()" executes the file using the appropriate application.It executes the .bat file suceessfully.But I am unable to pass the arguments.I need to execute the command like

Eg : test.bat parameter1 parameter2

var myFile=new File("c:\\test.bat");

myFile.execute();

The above statements works fine. Is it possible to execute the with parameters. Please suggest the solution to above problem.

TOPICS
Scripting
13.9K
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 , Jul 31, 2009 Jul 31, 2009

How 'bout setting environment variables?

type test.bat

echo %BLA% > c:\test.txt

$.setenv("BLA","value");

File("c:\\test.bat").execute();

Dirk

Translate
LEGEND ,
Jul 31, 2009 Jul 31, 2009

How 'bout creating a temporary shell script which executes the batch

with the parameters? You then just execute the shell script which

executes the batch in turn...

Harbs

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
Advocate ,
Jul 31, 2009 Jul 31, 2009

How 'bout setting environment variables?

type test.bat

echo %BLA% > c:\test.txt

$.setenv("BLA","value");

File("c:\\test.bat").execute();

Dirk

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 ,
Jul 31, 2009 Jul 31, 2009

Hi,

  Thank you very much. It is helpful answer and it is working...

Regards

Kumar

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
Participant ,
Nov 05, 2012 Nov 05, 2012

HI,

          I need to run .bat file without showing the command prompt screen. am using Indesign cs5.5 with Windows7 OS.

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
Enthusiast ,
Nov 05, 2012 Nov 05, 2012

Hi,

let VB start the *.bat. this works for me:

#target InDesign

doTheBat('START "" "C:\\Program Files\\Adobe\\Adobe Photoshop CS5.1 (64 Bit)\\Photoshop.exe"')//Start Photoshop, just a example

function doTheBat ( _data ) {  

        try 

        { 

            var _file = new File('~/myTmpBat.bat'); 

        _file.open( 'w' );  

        _file.encoding = 'UTF-8';  

    _file.writeln ( _data );  

    _file.close();  

    //_file.execute(); 

   

    myVBScript = "Set WshShell = CreateObject(\"WScript.Shell\")\r"; 

myVBScript += "WshShell.Run chr(34) & \"C:\\Users\\%USERNAME%\\myTmpBat.bat\" & Chr(34), 0\r"; 

myVBScript += "Set WshShell = Nothing\r";

myVBScript += "\r"; 

app.doScript(myVBScript, ScriptLanguage.VISUAL_BASIC);

    }catch (e){  alert(e);

        } 

}

Good luck

Hans-Gerd Claßen

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
Participant ,
Nov 06, 2012 Nov 06, 2012

sorry, I forget to say... I need this for both windows 7 and MAC...

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
Enthusiast ,
Nov 06, 2012 Nov 06, 2012

You want to execute a *.bat file on a mac?

Sorry but I'm bit of confused ...

Hans-Gerd Claßen

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
Participant ,
Nov 06, 2012 Nov 06, 2012

yes, but the command prompt should be hidden.

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
Enthusiast ,
Nov 06, 2012 Nov 06, 2012

As far as I know ...

A *.bat-file can run commandline commands of a windows- / Dos-System.

On Unixbased Systems (MAC OSX) the equivalent should be a shell-script (*.sh or may be *.rb for Ruby ...)

So: a *.bat-file won't run on a UnixSystem.

I've got no experience with parrallels, but I guess *.bat-files can be executed on a Windows-Parrallels-Installation.

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
Participant ,
Nov 06, 2012 Nov 06, 2012

correct. In MAC called as *.command file, which is similar to *.bat in windows.

So, that vbscript run only in windows isn't it?

I need  that for both(Windows and MAC)...

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
Enthusiast ,
Nov 06, 2012 Nov 06, 2012
LATEST

A 'do shell script'-command in AppleScript will execute a bash-, ruby-, phytonscript ... without opening a terminalwindow.

For example:

do shell script "bash " & quoted form of posix path (MacPath to your Shellscript)

or for Ruby

do shell script "ruby" & quoted form of posix path (MacPath to your Rubyscript)

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 Expert ,
Jul 31, 2009 Jul 31, 2009

How 'bout always writing out the batch file in full, with the parameters already in place? Then you'd only have to execute it.

The consensus here seems to be Adobe didn't count on anyone trying to run an MS-DOS style batch file from within InDesign

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