JSI Tip 9101. How can I generate a CSV file of all the scheduled job in my domain?

Using Schtasks.exe and NetViewC.bat, I have scripted ScheduleCSV.bat to generate a CSV (Coma Separated Value) file containing all the scheduled jobs on all of the computers in a domain.

NOTE: Tip 4806 » Windows XP contains a full featured command-line scheduler.

NOTE: Tip 5335 » Can I use the Windows XP command line scheduler in Windows 2000?

The each line in the CSV file contains the following information about a scheduled job:

"Next Run Time"
"Last Run Time"
"Last Result"
"Task To Run"
"Start In"
"Scheduled Task State"
"Scheduled Type"
"Start Time"
"Start Date"
"End Date"
"Run As User"
"Delete Task If Not Rescheduled"
"Stop Task If Runs X Hours and X Mins"
"Repeat: Every"
"Repeat: Until: Time"
"Repeat: Until: Duration"
"Repeat: Stop If Still Running"
"Idle Time"
"Power Management"
The syntax for using ScheduleCSV.bat is:



CSVFile         is the fully qualified CSV file path.

NetBIOS_DOMAIN  is the NetBIOS domain name, like JSIINC.

USER_SAMID      is the User Logon ID, like Jerry, of a domain administrator account.

PASSWORD        is the password of the USER_SAMID account.
ScheduleCSV.bat contains:
@echo off
if \{%4\}==\{\} @echo Syntax: ScheduleCSV CSVFile NetBIOS_DOMAIN USER_SAMID PASSWORD&goto :EOF
set out="%TEMP%\ScheduleCSV_%RANDOM%.TMP"
set csvfile=%1
set dom=%2
set user=%3
set pwd=%4
set work=%dom%\%user%
set user="%work:"=%"
set Head=N
if exist %csvfile% del /q %csvfile%
for /f "Tokens=*" %%c in ('netviewc %dom%') do (
 if "!Head!" EQU "Y" schtasks /query /S "%%c" /U %user% /P %pwd% /FO CSV /NH /V>>%out%
 if "!Head!" EQU "N" set Head=Y&schtasks /query /S "%%c" /U %user% /P %pwd% /FO CSV /V>%out%
for /f "Tokens=*" %%a in ('type %out%') do (
 @echo %%a>>%csvfile%
del /q %out%

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.