# DOS Batch file Challenge



## Quzimotto (Sep 27, 2013)

My boss asked me to edit a batch file he created to capture how many times the user runs it with a date and time stamp and the port identification.

Basically it is a batch file to fix various printer issues and he wants to know when it was run, keeping a tally log file and because this batch file is run at 5 locations, he would like to capture date/time, port (each printer is different, may be LPT1 or USB etc. and store location).

I am an IT tech person and know DOS, but haven't used it for ions ... I came across your site and it seems you guys know this stuff, so I'd like to request your help in getting me started. I have attached the original batch file.

Thanks for any help you have the time to give.


----------



## foxidrive (Oct 20, 2012)

Your code is at the bottom. The last 5 lines are flawed - try this:


```
IF EXIST "C:\Program Files (x86)\LabelVision\PrintMgr.exe" (
"C:\Program Files (x86)\LabelVision\PrintMgr.exe"
) else (
IF EXIST  "C:\Program Files\LabelVision\PrintMgr.exe" "C:\Program Files\LabelVision\PrintMgr.exe"
)
```
As for a log of date and time - this will work but there is no port information anywhere:


```
>>"c:\folder\printer repair.log" echo printer repaired: %date% @ %time%
```
Original code follows:


```
@ECHO OFF
taskkill /im "wscript.exe" /f
taskkill /im "lprinter.exe" /f
taskkill /im "prtonly.exe" /f
taskkill /im "printmgr.exe" /f
taskkill /im "mstopper.exe" /f
taskkill /im "lcnsmgr.exe" /f
taskkill /im "Designer.exe" /f

cd \
cls

ECHO   ------------------------------------------------------------
ECHO.
ECHO    INSTRUCTIONS:
ECHO    Use the Print Manager to send settings to the Printer
ECHO.
ECHO     1) FIRST: If the red light is on on the printer,
ECHO               turn off using back switch for 3 seconds,
ECHO               and then turn back on.
ECHO     2) From the first tab 'Printers'
ECHO     3) Select any one of the 'Datamax' printers in the list
ECHO     4) Click on 'Properties' to the right
ECHO     5) Go to 3rd tab 'Driver'
ECHO     6) Click 'Send to Printer'
ECHO     7) Click 'OK'
ECHO     8) Click 'Close'
ECHO.
ECHO    Have a great Day! (And thanks for fixing the printer)
ECHO.
ECHO   ------------------------------------------------------------

IF NOT EXIST "C:\Program Files (x86)\" GOTO NOx86DIR
"C:\Program Files (x86)\LabelVision\PrintMgr.exe"
END
:NOx86DIR
"C:\Program Files\LabelVision\PrintMgr.exe"
```


----------



## Quzimotto (Sep 27, 2013)

Thanks Foxdrive for your speedy reply and help. 

When you said "...no port information anywhere." I realize in my original batch file there was no code to log what kind of port the printer is on, but IS there a way to capture and log a specific port designation?

What I am after is to know from the log file at-a-glance ... what printer ports are involved to see if at the 5 locations we might be having more issues say for example with LPT1 ports or USB ports etc. I suppose we'll just know by seeing how active each log is at each location, but it would make the log report look more useful  

Q


----------

