.bat file

C

Carlos E

I have to take an inventory of our company computers, and I've already
written a .bat file to get the information automatically. I am trying to
make it even more useful, and automatically attach the .txt file the .bat
file creates, and send it back to me via Outlook. I need as little user
intervention as possible. I'd like some script to attach the .txt file, and
all the user has to do is click on send (or eliminate that step completely
if possible, ). Also can anyone verify if there is an script parameter that
will send the e-mail w/o actually clicking the send button. Here's what
I've got. The way it's setup now, the user must copy and paste the contents
into an e-mail. --I send them an e-mail with a link to the getw2k.bat file.

@ECHO OFF
:: GetW2k.bat, Version 1.00
:: Displays default printer plus assigns Dispatch
:: printers for current user on current system.
:: Requires REG.EXE v 2.0 from the Microsoft Windows 2000 Resource Kit
::
:: Written by Dan Horner

SETLOCAL

set FindPrtPath=\\Wwp_1\vol2\WWP_BBS\Software\netapp
set RegBin=\\Wwp_1\vol2\WWP_BBS\Software\Win2K\GETW2K\reg.exe
set BReadBin=\\Wwp_1\vol2\WWP_BBS\Software\Win2K\GETW2K\b_read.exe
set W2kLogFile=c:\drivers\%computername%-%username%.log

ECHO.
echo Please wait while your data is collected...

:: Initialize log file
date /t > %W2kLogFile%
time /t >> %W2kLogFile%
echo. >> %W2kLogFile%
echo Windows 2000 discovery for >> %W2kLogFile%
echo computer: %computername% >> %W2kLogFile%
echo user: %username% >> %W2kLogFile%

:: Get Machine Type and Serial
echo. >> %W2kLogFile%
%BReadBin% | find "Product Name" >> %W2kLogFile%
%BReadBin% | find "Serial" >> %W2kLogFile%

:: List network printers
echo.
ECHO Printers defined for %username%:
echo. >> %W2kLogFile%
:: Delims is a special TAB from REG.EXE OUTPUT
FOR /F "tokens=1,* skip=4 delims= " %%A IN ('%RegBin% QUERY
"HKCU\Software\Microsoft\Windows NT\CurrentVersion\Devices"') DO (
ECHO %%A
ECHO %%A >> %W2kLogFile%
)

:: Get mapped drives
echo.
echo Getting mapped drives.
echo. >> %W2kLogFile%
FOR /F "tokens=2,3* delims= " %%A IN ('net use ^|find /i "Microsoft" ^|find
":"') DO (
ECHO %%A %%B
ECHO %%A %%B >> %W2kLogFile%
)
echo.
FOR /F "tokens=1,2* delims= " %%A IN ('net use ^|find /i "NetWare" ^|find
":"') DO (
ECHO %%A %%B
ECHO %%A %%B >> %W2kLogFile%
)

:EndGetW2k
notepad %W2kLogFile%
@echo off


start mailto:<edited by YensidMod>?SUBJECT=Discovery(Win2kProject)
ENDLOCAL
 
J

Jerry

I dont believe there is a parameter to automatically send
the e-mail.

-----Original Message-----
I have to take an inventory of our company computers, and I've already
written a .bat file to get the information automatically. I am trying to
make it even more useful, and automatically attach the .txt file the .bat
file creates, and send it back to me via Outlook. I need as little user
intervention as possible. I'd like some script to attach the .txt file, and
all the user has to do is click on send (or eliminate that step completely
if possible, ). Also can anyone verify if there is an script parameter that
will send the e-mail w/o actually clicking the send button. Here's what
I've got. The way it's setup now, the user must copy and paste the contents
into an e-mail. --I send them an e-mail with a link to the getw2k.bat file.

@ECHO OFF
:: GetW2k.bat, Version 1.00
:: Displays default printer plus assigns Dispatch
:: printers for current user on current system.
:: Requires REG.EXE v 2.0 from the Microsoft Windows 2000 Resource Kit
::
:: Written by Dan Horner

SETLOCAL

set FindPrtPath=\\Wwp_1\vol2\WWP_BBS\Software\netapp
set RegBin=\\Wwp_1\vol2 \WWP_BBS\Software\Win2K\GETW2K\reg.exe
set BReadBin=\\Wwp_1\vol2 \WWP_BBS\Software\Win2K\GETW2K\b_read.exe
set W2kLogFile=c:\drivers\%computername%-%username%.log

ECHO.
echo Please wait while your data is collected...

:: Initialize log file
date /t > %W2kLogFile%
time /t >> %W2kLogFile%
echo. >> %W2kLogFile%
echo Windows 2000 discovery for >> %W2kLogFile%
echo computer: %computername% >> % W2kLogFile%
echo user: %username% >> %W2kLogFile%

:: Get Machine Type and Serial
echo. >> %W2kLogFile%
%BReadBin% | find "Product Name" >> %W2kLogFile%
%BReadBin% | find "Serial" >> %W2kLogFile%

:: List network printers
echo.
ECHO Printers defined for %username%:
echo. >> %W2kLogFile%
:: Delims is a special TAB from REG.EXE OUTPUT
FOR /F "tokens=1,* skip=4 delims= " %%A IN ('% RegBin% QUERY
"HKCU\Software\Microsoft\Windows
NT\CurrentVersion\Devices"') DO (
 
N

Natarajan

However you could have the code to email in the .vbs file and use .bat
file to run the script using wscript.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top