Print html files through bat files in xp?
Posted: 09 Jul 2011 06:54
Hi Dos developers,
The below code is used to print HTML files from a batch file.
But the clause is it works only in NT, can any one modify so that it works in windows xp/windows7?
@ECHO OFF
SETLOCAL
:: Command line parsing
SET File2Print=%*
ECHO.%File2Print% | FIND "?" >NUL
IF NOT ERRORLEVEL 1 GOTO Syntax
:: Strip leading space in NT 4 only
VER | FIND "Windows NT" >NUL
IF NOT ERRORLEVEL 1 IF DEFINED File2Print SET File2Print=%File2Print:~1%
IF DEFINED File2Print SET File2Print=%File2Print:"=%
IF NOT DEFINED File2Print GOTO Syntax
IF NOT EXIST "%File2Print:"=%" GOTO Syntax
:: Actual print command
RUNDLL32.EXE MSHTML.DLL,PrintHTML "%File2Print%"
:: Done
GOTO End
:Syntax
ECHO.
ECHO PrintHTM.bat, Version 1.11 for Windows NT
ECHO Prints a local HTML file from the command line
ECHO.
ECHO http://www.google.com
ECHO.
ECHO Usage: %~n0 ^<html_file^>
:End
ENDLOCAL
Thanks,
San
The below code is used to print HTML files from a batch file.
But the clause is it works only in NT, can any one modify so that it works in windows xp/windows7?
@ECHO OFF
SETLOCAL
:: Command line parsing
SET File2Print=%*
ECHO.%File2Print% | FIND "?" >NUL
IF NOT ERRORLEVEL 1 GOTO Syntax
:: Strip leading space in NT 4 only
VER | FIND "Windows NT" >NUL
IF NOT ERRORLEVEL 1 IF DEFINED File2Print SET File2Print=%File2Print:~1%
IF DEFINED File2Print SET File2Print=%File2Print:"=%
IF NOT DEFINED File2Print GOTO Syntax
IF NOT EXIST "%File2Print:"=%" GOTO Syntax
:: Actual print command
RUNDLL32.EXE MSHTML.DLL,PrintHTML "%File2Print%"
:: Done
GOTO End
:Syntax
ECHO.
ECHO PrintHTM.bat, Version 1.11 for Windows NT
ECHO Prints a local HTML file from the command line
ECHO.
ECHO http://www.google.com
ECHO.
ECHO Usage: %~n0 ^<html_file^>
:End
ENDLOCAL
Thanks,
San