Skip to content

Instantly share code, notes, and snippets.

@wdormann
Last active September 2, 2020 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wdormann/89fae036e58ea6043bd82bca9515749a to your computer and use it in GitHub Desktop.
Save wdormann/89fae036e58ea6043bd82bca9515749a to your computer and use it in GitHub Desktop.
List privileged scheduled tasks in Windows that don't come with Windows 10
# Don't use this version!
# Try https://gist.github.com/wdormann/8afe4edf605627ee4f203861b6cc3a1c instead
#
# Utility for listing SYSTEM-privileged scheduled tasks on Windows
# Tasks that come with Windows 10 are not included.
# Admin privileges are required to list all scheduled tasks.
import csv
import subprocess
import tempfile
import os
with tempfile.NamedTemporaryFile(suffix='.csv', delete=False) as tempcsv:
csvoutput = subprocess.call(['schtasks', '/v', '/fo', 'csv'], stdout=tempcsv)
with open(tempcsv.name) as f:
tasksreader = csv.reader(f)
for row in tasksreader:
enabled = row[3]
taskname = row[1]
if enabled != 'Disabled' and '\\Microsoft\\Windows' not in taskname and '\\Microsoft\\XblGameSave' not in taskname:
priv = row[14]
if priv.lower().strip() == 'system' or priv.lower().strip() == 'nt authority\\system':
if row[8].lower() != 'com handler':
print('%s : %s' %(row[10],row[8]))
os.remove(tempcsv.name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment