Python Forum
Win32\ping.exe windows pops up -very annoying...
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Win32\ping.exe windows pops up -very annoying...
#1
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.
Reply
#2
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.
Reply
#3
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.
Reply
#4
Is the dos window popping up on the remote host or on the computer running this script?
Reply
#5
my bad again!
It is popping up on my server only, that is where I'm running the script.

Thank you.
Reply
#6
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.
Reply
#7
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!
Reply
#8
Does this work.
result=subprocess.Popen(["ping", "-n", "1", "-w", "255", ip],
                        stdout=limbo, stderr=limbo, creationflags=CREATE_NO_WINDOW).wait()
tester_V likes this post
Reply
#9
It did not.
error:
stdout=limbo, stderr=limbo, creationflags=CREATE_NO_WINDOW).wait()
NameError: name 'CREATE_NO_WINDOW' is not defined
Reply
#10
Also added this:
from subprocess import CREATE_NO_WINDOW
and now it works.

deanhystad! You are DA MAN!

Thank you!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Launcher Pops Up When Py-based App Is Running (Mac) radix_optimus 0 543 Sep-18-2023, 09:22 AM
Last Post: radix_optimus
  Need some guidance on a script to ping a list of ip's cubangt 11 1,838 Aug-10-2023, 02:39 PM
Last Post: snippsat
  non-stop ping script kucingkembar 1 1,365 Aug-23-2022, 06:29 AM
Last Post: menator01
  Python library for win32 console commands eldiener 3 3,470 Aug-24-2021, 10:28 PM
Last Post: bowlofred
  Idle debugger pops up Run.py - library? fred1232 1 1,648 Jul-27-2021, 01:01 AM
Last Post: Larz60+
  Looking for discord bot to make loop ping for address ip tinkode 0 1,831 Jul-26-2021, 03:51 PM
Last Post: tinkode
  Ping command using python 3.6.5 Martin2998 6 17,422 Apr-19-2021, 06:24 PM
Last Post: blazejwiecha
Exclamation binwalk Win32 compile hackstunt 2 3,812 Feb-24-2021, 05:14 PM
Last Post: nilamo
  pyarrow throws oserror winerror 193 1 is not a valid win32 application aupres 2 3,787 Oct-21-2020, 01:04 AM
Last Post: aupres
  GPIO high if network IP has good ping duckredbeard 3 2,338 Oct-12-2020, 10:41 PM
Last Post: bowlofred

Forum Jump:

User Panel Messages

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