![]() |
Win32\ping.exe windows pops up -very annoying... - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Win32\ping.exe windows pops up -very annoying... (/thread-34574.html) |
Win32\ping.exe windows pops up -very annoying... - tester_V - Aug-10-2021 Greetings! I'm running a script that uses: import wmi from socket import *I'm scanning a subnet and if found an active IP it checks if remote hosts have particular services started, it runs every 15min. Now I have a problem, every 15 minutes DOS windows(...win32\pin.exe) popping up for each host that is very annoying. Is there any way I can suppress the DOS window? Thank you. RE: Win32\ping.exe windows pops up -very annoying... - deanhystad - Aug-10-2021 This is so lacking in information its pathetic. Is that your entire program? How do you expect any help if this is all you are willing to provide. Try again. RE: Win32\ping.exe windows pops up -very annoying... - tester_V - Aug-10-2021 Well, you are right I should of posted more code. But you have to understand, for most of us that asking for your help, you guys like a code Megicianc. Some kind of woodo stuff... Here is the short version of the code that makes DOS pop up. import wmi from socket import * proc =open('D:/HSMV/Host_staus.txt','w') hlist = ['AMC4TCM1901.BPH.corp.com,101.232.422.12','AMC4TCM1902.BPH.corp.com,101.232.422.14','AMC4TCM1910.BPH.corp.com,101.232.422.15','AMC4TCM1915.BPH.corp.com,101.232.422.16'] for ehl in hlist : proc_name = False proc_name2 = False ehl=ehl.strip() hnm,hip = ehl.split(",") ## <--- Splitting for Host Name and Host IP ip = hip ## <------------------- Host IP hnm_sp,*nothing = hnm.split(".") try: connection = wmi.WMI(ip) print(f" Connection established -- {hnm_sp}") for process in connection.Win32_Process () : if process.Name == 'FuseepAgentService.exe' : print (f" Fusseep started -------> {process.Name}") proc_name = 'UP' elif process.Name == 'OpenZBR_x64.exe' : print (f" OpenZBR started ------> {process.Name}") proc_name2 = process.Name proc_name2 = 'UP' if proc_name == False : proc_name = 'Down' print(f" Fusseep_Service -- DOWN") if proc_name2 == False : proc_name2 = 'Down' print(f" OpenZBR_Service ------ DOWN") proc.write(hnm_sp+","+proc_name+","+proc_name2+"\n") except wmi.x_wmi: print(f"------------------------------------------------------------"+"\n") print(f" Cannot connect to -> {hnm_sp}") print(f"------------------------------------------------------------"+"\n") proc.close()Sorry again! And thank you. RE: Win32\ping.exe windows pops up -very annoying... - deanhystad - Aug-10-2021 Is the dos window popping up on the remote host or on the computer running this script? RE: Win32\ping.exe windows pops up -very annoying... - tester_V - Aug-10-2021 my bad again! It is popping up on my server only, that is where I'm running the script. Thank you. RE: Win32\ping.exe windows pops up -very annoying... - tester_V - Aug-11-2021 HI, Have an update. I changed the extension of the script from.pyw to .py and the .'..windows32.ping.exe' windows stopped popping up, now I have just one window that pops up. it is the script Python.exe. Is there any other way I could suppress this window? Thank you. RE: Win32\ping.exe windows pops up -very annoying... - tester_V - Aug-11-2021 Sorry for the confusion!!! I found I had a problem with a different part of my script. this is where the 'ping' is called and that is where the 'DOS windows pop-ups' coming from. Does anybody know how to fix it? f_active1 = open ("C:/02/IP_Active1.txt","w") with open(os.devnull, "wb") as limbo: for n in range(1, 255): ip="11.21.12.{0}".format(n) result=subprocess.Popen(["ping", "-n", "1", "-w", "255", ip], stdout=limbo, stderr=limbo).wait() if result: print (f" Not Active -. {ip}") #, file=f_inactive1) pass else: print (ip, "active") f_active1.write(ip+"\n") f_active1.close()Sorry again for the confusion!!! And thank you! RE: Win32\ping.exe windows pops up -very annoying... - deanhystad - Aug-11-2021 Does this work. result=subprocess.Popen(["ping", "-n", "1", "-w", "255", ip], stdout=limbo, stderr=limbo, creationflags=CREATE_NO_WINDOW).wait() RE: Win32\ping.exe windows pops up -very annoying... - tester_V - Aug-12-2021 It did not. error: stdout=limbo, stderr=limbo, creationflags=CREATE_NO_WINDOW).wait() NameError: name 'CREATE_NO_WINDOW' is not defined RE: Win32\ping.exe windows pops up -very annoying... - tester_V - Aug-12-2021 Also added this: from subprocess import CREATE_NO_WINDOWand now it works. deanhystad! You are DA MAN! Thank you! |