Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
find any item in the list
#1
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 :

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()
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
Reply


Messages In This Thread
find any item in the list - by evilcode1 - Oct-07-2018, 08:11 AM
RE: find any item in the list - by snippsat - Oct-07-2018, 09:45 AM
RE: find any item in the list - by evilcode1 - Oct-07-2018, 09:58 AM
RE: find any item in the list - by snippsat - Oct-07-2018, 01:29 PM
RE: find any item in the list - by evilcode1 - Oct-08-2018, 07:23 AM
RE: find any item in the list - by snippsat - Oct-08-2018, 01:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Program to find Mode of a list PythonBoy 6 1,303 Sep-12-2023, 09:31 AM
Last Post: PythonBoy
  find random numbers that are = to the first 2 number of a list. Frankduc 23 3,704 Apr-05-2023, 07:36 PM
Last Post: Frankduc
  Find (each) element from a list in a file tester_V 3 1,348 Nov-15-2022, 08:40 PM
Last Post: tester_V
  read a text file, find all integers, append to list oldtrafford 12 4,031 Aug-11-2022, 08:23 AM
Last Post: Pedroski55
Question Finding string in list item jesse68 8 2,049 Jun-30-2022, 08:27 AM
Last Post: Gribouillis
  find some word in text list file and a bit change to them RolanRoll 3 1,646 Jun-27-2022, 01:36 AM
Last Post: RolanRoll
  How to find the second lowest element in the list? Anonymous 3 2,197 May-31-2022, 01:58 PM
Last Post: Larz60+
  Python Program to Find the Total Sum of a Nested List vlearner 8 5,235 Jan-23-2022, 07:20 PM
Last Post: menator01
  how to easily create a list of already existing item CompleteNewb 15 3,900 Jan-06-2022, 12:48 AM
Last Post: CompleteNewb
  Remove an item from a list contained in another item in python CompleteNewb 19 6,125 Nov-11-2021, 06:43 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020