I have a set of PDF documents that prints very slowly via a command line call to the Acrobat Reader executable that skips the Print dialog, versus including the Print dialog (or using the Acrobat GUI).
When I use this command line:
"C:\Program Files (x86)\Adobe\Reader 8.0\Reader\AcroRd32.exe" /t "C:\0003.pdf" "OKI C9650(PS)"
It opens Acrobat, skips the print dialog, but takes about 180 seconds to print.
However, if I print the file through the Acrobat's print dialog, it prints in about 20 seconds.
"C:\Program Files (x86)\Adobe\Reader 8.0\Reader\AcroRd32.exe" /P "C:\0003.pdf"
Does anyone know why this could be?
Related
I run a program like notepad.exe via command line.
After the process terminated itself after completion of task of the started application, I need to run another program via command line, for example winword.exe.
So I would like a behavior like a scheduler, waiting in background up to completion of first process and then initiate start of another process.
Can I achieve this in Windows? And if yes, how?
Batch file solutions
For the example Notepad.exe and Winword.exe the solution is quite simple with following batch file:
#echo off
%SystemRoot%\Notepad.exe
start Winword.exe
Windows command interpreter cmd.exe first starts Windows Notepad and halts execution of the batch file until Notepad.exe terminated itself which means the user
pressed Alt+F4 on keyboard, or
clicked on X symbol on right side of title bar of Notepad window, or
clicked in menu File on menu item Exit, or
double clicked on application symbol on left side of title bar of Notepad window, or
clicked once on application symbol on left side of title bar of Notepad window and clicked next on last application context menu item Close.
Then internal command START of cmd.exe is used to start Microsoft Word in a separate process parallel to running command process. For that reason cmd.exe continues the batch file processing immediately after executing START while Microsoft Word is running parallel and exits because there is no more command line.
The application to start must be specified usually with full path if the directory containing the executable is not included in environment variable PATH, enclosed in double quotes if the path contains a space or one of these characters &()[]{}^=;!'+,`~. Please take a look on What is the reason for '...' is not recognized as an internal or external command, operable program or batch file? for details on how Windows command interpreter finds executables and scripts specified on command line or in a batch file without path (and without file extension). So best would be as second line something like:
start "" "%ProgramFiles(x86)%\Microsoft Office\Office14\Winword.exe"
This command line starts 32-bit Microsoft Word 2010 installed in standard installation directory on a computer running 64-bit Windows. The additional empty argument string "" is necessary because command START would interpret otherwise the full qualified name of application to start enclosed in double quotes as title for a new console window. So the command START would start a new command process with the title C:\Program Files (x86)\Microsoft Office\Office14\Winword.exe for the console window without specifying explicitly an empty title with "" as first argument.
Why is using just start Winword.exe working?
The directory containing Winword.exe is not included in environment variable PATH. But as long as Winword.exe is installed at all, this command line nevertheless results in starting Microsoft Word. The reason is correct registration of application Winword.exe in Windows registry during installation. For that reason the command START is capable to find out where Winword.exe is installed and execute it. For details on how this works see answer on Where is “START” searching for executables?
The three lines in batch file can be also optimized to a single line with multiple commands:
#%SystemRoot%\Notepad.exe & start Winword.exe
But this single command line can't be used directly in a command prompt window because of cmd.exe executes in this case Windows Notepad and Microsoft Word parallel.
Command line solutions
The command line solution for usage directly from within a command prompt window is:
start /wait Notepad.exe & start Winword.exe
This starts Windows Notepad in a separate process using command START with explicitly waiting for termination of Notepad.exe because of using additionally the START parameter /wait before one more START is executed to start Microsoft Word. There is no need of "" as empty title string here because of no argument string in this command line is enclosed in double quotes.
But this command line solution has one disadvantage: the command prompt window can't be used further as long as Windows Notepad is running.
So better would be starting from within current command prompt window a new command process with minimized window which first executes Windows Notepad, halts command line execution until Notepad terminates itself, then starts Microsoft Word and exits immediately after starting Winword.exe. This can be done with following command line:
start "Notepad & Winword" /min cmd.exe /C "start /wait Notepad.exe & start Winword.exe"
This command line results in starting cmd.exe as separate process, with a console window being minimized because of option /min of command START, with a console window title Notepad & Winword, which closes itself because of option /C of CMD, after first starting Notepad.exe and waiting for Notepad termination before starting Winword.exe not waiting for termination.
Well, the additional, minimized console window with title Notepad & Winword is in real of no usage for the user. Therefore better would be the command line:
start "" /B cmd.exe /C "start /wait Notepad.exe & start Winword.exe"
The additional command process is started in this case with no window (in background) because of usage of option /B of command START. An empty title is specified here as no console window is shown at all.
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
cmd /?
echo /?
start /?
Objective:
This daemon maintain logs at what time which text file is opened.
Step I:
I made one empty batch file and this file would be going to log the events into one temporary log file.
Step II:
Associating text files with this batch file program
i) I right clicked on one text file.
ii) I clicked on "open with" option
iii) Then I chose my batch file program.
Now as I open any text file my batch file program starts running.
Step III:
Batch file development:
i) I opened the batch file which I created as empty in Step I
ii) I wrote following batch file commands in order to above objective:
#echo off
echo %1 >>logs.txt
time >> logs.txt
notepad %1
exit
Step IV:
i) As I open any txt file, then this batch file runs, but the problem is as it comes to "time" command I have to manually press enter, so is there any command in batch file programming which can produce keystrokes.
ii) Second thing which I need is as I open my text file, cmd window pops up, I want it to remain hidden from user, so that user doesn't know about logging of events.
iii) Third thing which I need is to start the notepad process in background, so that my batch file script can proceed further.
Use %time% (see set /?) on same line as %1 to have time / filename on same line. Else type time /? for help esp time /t.
Console programs have a console. Use a different technology. VBScript can start programs hidden but you would do everything in vbscript. 0 is hidden.
Set WshShell = WScript.CreateObject("WScript.Shell")
msgbox FormatNumber(WshShell.Run("cmd /k dir c:\windows\*.*", 0, false))
As above but with 6 or 8.
I am using Windows 7
How can i run an input file (text file of commands) in an exe progam in CMD please.
Using other questions on the site, i have tried:
CMD /c ""C:/Program Files/Mplus/Mpluswin.exe" "C:/Users/jj/Desktop/mplus/test_mplus.inp""
which opens the input file in the program but does not run it
and this, which opens the program, but not the script
CMD /c "C:/Program Files/Mplus/Mpluswin.exe" < "C:/Users/jj/Desktop/mplus/test_mplus.inp"
Does this depend on the exe program?
Edit:
At present, the first command above launches the exe program and opens the text file within it (this is a file of program specific commands that will read in data, run calculations and output automatically). I can then run the commands in the exe program that has been opened (by selecting run in a menu) . But, I would like to pass the file to the exe program and it to be run automatically, ideally in the background. I am not sure of the correct terminology to use, so sorry if my description is unclear.
I've just noticed that you enclosed the entire term in an extra set of double quotes, and used linux forward slashes - try this batch file and also see if there is any error message on the console.
#echo off
cd /d "%userprofile%\Desktop\mplus"
"C:\Program Files\Mplus\Mpluswin.exe" "test_mplus.inp"
echo mplus was launched
pause
I have a program which I want to start using the command prompt and at the same time I want to pass 2 parameters to it.
So, for example, when I wanted to start my program I would open the command prompt (in XP: start > run, type cmd, press return) and then type:
c:\rand\anotherfolder\myprogram.exe 10 20
Since I know nothing about batch files, I'm asking two things:
Can I create a batch file to automatize this process?
If yes, how :D?
I'll edit this if you respond to my comment but if you want to simply execute this command via a batch file (and you know nothing about batch files):
Open a text editor (e.g.Notepad)
Type in your command (e.g. c:\rand\aotherfolder\myprogram.exe 10 20)
Save the file as mybatchfile.cmd
Double click the file (in Windows Explorer etc.)
I am trying to open several PDF documents using a simple batch file:
ECHO OFF
CLS
cd Program Files\Adobe\Reader 9.0\Reader
Acrord32.exe C:\Users\BW1.pdf
Acrord32.exe C:\Users\BW2.pdf
Acrord32.exe C:\Users\BW3.pdf
Acrord32.exe C:\Users\BW4.pdf
Acrord32.exe C:\Users\BW5.pdf
Acrord32.exe C:\Users\BW6.pdf
EXIT
The above batch file opens the first PDF only, then waits until I close it for the next PDF file to open. How can I have all the PDF documents open at the same time? (Like going to Acrobat Reader, file->Open->xx.pdf)
Use start:
start acrord32.exe 1.pdf
start acrord32.exe 2.pdf
start acrord32.exe 3.pdf
Or even (as Johannes Rössel suggests in the comment below):
start 1.pdf
start 2.pdf
start 3.pdf
Would probably work as well (depending on your default PDF viewer).
Note that when using start you have to be careful when using quoted arguments, as the following won't work (the first quoted argument is interpreted as the title for a new console window):
start "1.pdf"
Instead you'll have to do the following:
start "" "1.pdf"
It's an annoying quirk of start, but you have to effectively supply a dummy title in this case to properly open the specified file (even though the title is unnecessary as this won't create a new console window).
A list of other available batch commands.
For me it works even without the start command. I use:
c:\path\to\my.pdf
in cmd.exe windows frequently, and it always opens Acrobat Reader (my default viewer on Windows). In a batchfile I've written to generate PDF via Ghostscript, my last two lines are:
"%ouptutpath%\%outputfile%.pdf"
"%outputpath%\%outputfile%-optimized.pdf"
which automatically opens both generated PDFs in two different Reader windows. (My %outputpath% contains spaces, the %outputfile% may also have some...)
Have you tried whether Acrobat Reader allows for more files on the commandline, ie.
start acrord32.exe 1.pdf 2.pdf 3.pdf
Thank you!
Using start did the trick. I had to use start as many times as the number of pdf documents I want to open. For some reason
start acrord32.exe 1.pdf 2.pdf 3.pdf
opens only the first document. So I guess Acrobat reader might not allow for more files on the command line.
I rally appreciate your answers.
Thanks for the above answers.
I also tried below, working fine:
start /B excel.exe "D:\my first file.xlsx" "E:\my second file.xlsx" "D:\working folder\my third file.xlsx"
For every pdf file in the specified directory, use the start command on that file:
for %f in ("C:\Users\*.pdf") do start %f
As per the Microsoft Docs:
For runs a specified command for each file in a set of files.
for {%variable|%%variable} in (set) do command [ CommandLineOptions]
This is follow up to the answer given by JSON C11 above.
I checked in Windows 10 OS, the command given as below with the error ("C:\Users*.pdf") was unexpected at this time.
for %f ("C:\Users*.pdf") do start %f
What is missing is 'in'. Correct code is...
for %f in ("C:\Users\*.pdf") do start %f
If you have a binary to open that particular type of file, and you like to open in maximized view, you can use the following code.
for %f in ("C:\Users\*.pdf") do start /max <path to binary> %f