Oct-07-2018, 08:11 AM
hello all ...
im coding a program to get the internet browsers names and dir's from the windows if he found the process ...
this is my code :
the d variable run this command (wmic process get name | findstr /v "Name 'System Idle Process' System) on the system to get all the process ... i need to modify the code search in this process if he found any item from list name lists[] then run this lines :
qassam = os.popen("dir /s /b {}".format(lists[1])).read().strip()
print qassam
dir1 = os.path.dirname(qassam)
print dir1
if he did not found any browser just print found nothing
im coding a program to get the internet browsers names and dir's from the windows if he found the process ...
this is my code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import os import time def q(): home = os.environ.get( "HOMEDRIVE" ) lol = home + "/" mycurrent = os.getcwd() change = os.chdir(lol) mycurrent = os.getcwd() d = os.popen( """wmic process get name | findstr /v "Name 'System Idle Process' System""" ).read().lower() lists = [ "opera.exe" , "chrome.exe" , "iexplore.exe" , "firefox.exe" , "microsoftedgecp.exe" ] for q in lists: if any (item in q for item in d) : qassam = os.popen( "dir /s /b {}" . format (lists[ 1 ])).read().strip() print qassam dir1 = os.path.dirname(qassam) print dir1 #CreateShortCut_to_Desktop(qassam , dir1) print time.time() else : print "nothing found" break q() |
qassam = os.popen("dir /s /b {}".format(lists[1])).read().strip()
print qassam
dir1 = os.path.dirname(qassam)
print dir1
if he did not found any browser just print found nothing