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
Print html files through bat files in xp?
Moderator: DosItHelp
Re: Print html files through bat files in xp?
kumar_kondapalli wrote:it works only in NT
No. It works fine on my Win7. Can't reproduce your problem.
Regards
aGerman
-
- Posts: 32
- Joined: 08 Jul 2011 03:38
Re: Print html files through bat files in xp?
UMMM but i tried in xp it does not and in my win7 as .. Can you please let me know if you have modified any code ?. Also can i get the print dailog box opened so that it gives me an option to select the printers from the drop down.
Thanks,
San
Thanks,
San
Re: Print html files through bat files in xp?
I didn't modify the code. I saved it as PrintHTM.bat. Because the help told me that it prints local HTML files I created a test.html with a basic source text:
... and a callPrintHTM.bat:
Regards
aGerman
Code: Select all
<html>
<head>
<title>Test</title>
</head>
<body>Hello World</body>
</html>
... and a callPrintHTM.bat:
Code: Select all
@echo off
call PrintHTM test.html
Regards
aGerman
-
- Posts: 126
- Joined: 10 Jun 2011 10:30
Re: Print html files through bat files in xp?
Are you getting an error message when you run it in XP?
Re: Print html files through bat files in xp?
Latest only 1 line is necessary for html printing:
... where test.html is only an example, replace it with your html file.
I'm sure this will work in XP as well.
Regards
aGerman
Code: Select all
rundll32 mshtml.dll,PrintHTML "test.html"
... where test.html is only an example, replace it with your html file.
I'm sure this will work in XP as well.
Regards
aGerman
-
- Posts: 32
- Joined: 08 Jul 2011 03:38
Re: Print html files through bat files in xp?
Hey thanks a lot guys .. It works perfectly in xp as well.
German code worked fine
German code worked fine