Skip to content

Commit

Permalink
Create application_audit.py
Browse files Browse the repository at this point in the history
Python Script to RDP into a list of IPs and check if the certain application exists or works. In this case notepad.exe
  • Loading branch information
anchalraheja authored Aug 19, 2019
0 parents commit 6a05432
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions application_audit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import win32api
import win32net
from socket import *
import wmi
import os
import wmi, time
from shutil import copyfile
import getpass


username = ("")
password = ("")

def check_ps(ip):

try:
connection = wmi.WMI(ip, user=username, password=password)
print "Connection established"
process_id, return_value = connection.Win32_Process.Create(CommandLine="notepad.exe")
if ( process_id > 0):
print str(ip) + " " +"Working"
update_sheet(ip,"enabled")
else:
print str(ip) +" " +"Disabled"
update_sheet(ip,"disabled")

if (return_value == 0 ):
print str(ip) +" " +"Working"
update_sheet(ip,"enabled")
else:
print str(ip) +" " +"Disabled"
# update_sheet(ip,"disabled")

except wmi.x_wmi:
print "Your Username and Password of "+getfqdn(ip)+" are wrong."
update_sheet(ip,"failed")



def update_sheet(ip,result):
f = open("result.csv","ab")
line = str(ip) + "," + str(result)
f.write(line)
f.write("\n")
f.close()


server_list = open("ip_list.txt")
for x in server_list.readlines():
ip = x.rstrip()
print ip
check_ps(ip)

0 comments on commit 6a05432

Please sign in to comment.