Copy link to clipboard
Copied
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.
How 'bout setting environment variables?
type test.bat
echo %BLA% > c:\test.txt
$.setenv("BLA","value");
File("c:\\test.bat").execute();
Dirk
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
How 'bout setting environment variables?
type test.bat
echo %BLA% > c:\test.txt
$.setenv("BLA","value");
File("c:\\test.bat").execute();
Dirk
Copy link to clipboard
Copied
Hi,
Thank you very much. It is helpful answer and it is working...
Regards
Kumar
Copy link to clipboard
Copied
HI,
I need to run .bat file without showing the command prompt screen. am using Indesign cs5.5 with Windows7 OS.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
sorry, I forget to say... I need this for both windows 7 and MAC...
Copy link to clipboard
Copied
You want to execute a *.bat file on a mac?
Sorry but I'm bit of confused ...
Hans-Gerd Claßen
Copy link to clipboard
Copied
yes, but the command prompt should be hidden.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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)...
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
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