You could iterate through .ses
files in a directory via a for loop and use start to execute the executable and pass it the file name of the .ses
file. Within the loop per each iteration you can use variable substitutions to get the file name from the .ses
file excluding the extension.
You can pass the file name (without the extension) as the first argument (%~1
) to call after the subroutine label name. That first argument could be incorporated into some dynamic VBScript logic using sendkeys to type in the desired output .pdf
from the Save PDF File As dialogue window.
Lastly, use cscript to execute the dynamically built VBScript so it will perform the emulated keystroke commands accordingly and manipulate the dialogue windows to help further automate—it's still batch but with some Windows native extended, controllable, and adjustable easy to understand logic.
Script (Batch Example)
Note: You may need to play with the timeout /t <#>
to specify more or less seconds to wait depending on how long once the ses
is read into the exe before that window of Save PDF File As opens. Same with the sendkeys TAB <#>
for the number of tabs to press on that window since I was only able to slightly test with Save Print Output As title and virtual PDF printer.
@ECHO ON
SET "WinTitle=Save PDF File As"
SET "sesDir=C:\Folder\sesFiles"
SET "exe=C:\Folder\abc.exe"
FOR %%A IN ("%sesDir%\*.ses") DO (
start "" %exe% -batch "%%~A"
timeout /t 10
CALL :dynVBS "%%~NA"
)
EXIT
:dynVBS
SET TempVBSFile=%temp%\~tmp_SavePDFFileAs_Temp.vbs
IF EXIST "%TempVBSFile%" DEL /F /Q "%TempVBSFile%"
ECHO Set WshShell = WScript.CreateObject("WScript.Shell") >"%TempVBSFile%"
ECHO Wscript.Sleep 900 >>"%TempVBSFile%"
ECHO WshShell.AppActivate "%WinTitle%" >>"%TempVBSFile%"
ECHO Wscript.Sleep 900 >>"%TempVBSFile%"
ECHO WshShell.SendKeys "^a" >>"%TempVBSFile%"
ECHO Wscript.Sleep 500 >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{DEL}" >>"%TempVBSFile%"
ECHO Wscript.Sleep 500 >>"%TempVBSFile%"
ECHO WshShell.SendKeys "%~1.pdf" >>"%TempVBSFile%"
ECHO Wscript.Sleep 500 >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{TAB 3}" >>"%TempVBSFile%"
ECHO Wscript.Sleep 500 >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{ENTER}" >>"%TempVBSFile%"
CSCRIPT //nologo "%TempVBSFile%"
GOTO :EOF
Further Resources
for
- Variable Substitutions (FOR /?)
In addition, substitution of FOR variable references has been
enhanced. You can now use the following optional syntax:
%~I - expands %I removing any surrounding quotes (")
%~nI - expands %I to a file name only
start
- timeout
- call
- sendkeys
- appactivate
- cscript