Stop popup cmd window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hokiegal99

    Stop popup cmd window

    How can I make this script run w/o seeing a cmd popup window on the
    screen? The script works well, but each hour (when the task scheduler
    runs it) a brief cmd window appears and then goes away. It's only on
    the screen for a second or two, but it's noticable.

    u = "User Name"
    f = "from address"
    t = "to address"

    fp = os.popen("ipcon fig /all", "r")
    msg = MIMEText(fp.rea d())
    fp.close()

    msg["Subject"] = "%s's IPconfig Report" % u
    msg["From"] = f
    msg["To"] = t

    h = "smtp.vt.ed u"
    s = smtplib.SMTP(h)
    s.sendmail(f, t, msg.as_string() )
    s.quit()
  • Derrick 'dman' Hudson

    #2
    Re: Stop popup cmd window

    On 15 Dec 2003 13:28:01 -0800, hokiegal99 wrote:[color=blue]
    > How can I make this script run w/o seeing a cmd popup window on the
    > screen? The script works well, but each hour (when the task scheduler
    > runs it) a brief cmd window appears and then goes away. It's only on
    > the screen for a second or two, but it's noticable.[/color]

    Use a better OS? <0.5 wink>

    Run it with pythonw.exe instead of python.exe.

    --
    One OS to rule them all, one OS to find them,
    One OS to bring them all and in the darkness bind them,
    In the Land of Redmond, where the Shadows lie.

    www: http://dman13.dyndns.org/~dman/ jabber: dman@dman13.dyn dns.org

    Comment

    • hokiegal99

      #3
      Re: Stop popup cmd window

      > On 15 Dec 2003 13:28:01 -0800, hokiegal99 wrote:[color=blue][color=green]
      > > How can I make this script run w/o seeing a cmd popup window on the
      > > screen? The script works well, but each hour (when the task scheduler
      > > runs it) a brief cmd window appears and then goes away. It's only on
      > > the screen for a second or two, but it's noticable.[/color]
      >
      > Use a better OS? <0.5 wink>
      >
      > Run it with pythonw.exe instead of python.exe.[/color]

      How can I specify pythonw.exe over python.exe? The task scheduler has
      no place for this sort of thing.

      Comment

      • Thomas Heller

        #4
        Re: Stop popup cmd window

        hokiegal99@hotm ail.com (hokiegal99) writes:
        [color=blue][color=green]
        >> On 15 Dec 2003 13:28:01 -0800, hokiegal99 wrote:[color=darkred]
        >> > How can I make this script run w/o seeing a cmd popup window on the
        >> > screen? The script works well, but each hour (when the task scheduler
        >> > runs it) a brief cmd window appears and then goes away. It's only on
        >> > the screen for a second or two, but it's noticable.[/color]
        >>
        >> Use a better OS? <0.5 wink>
        >>
        >> Run it with pythonw.exe instead of python.exe.[/color]
        >
        > How can I specify pythonw.exe over python.exe? The task scheduler has
        > no place for this sort of thing.[/color]

        Name the script 'myscript.pyw' instead of 'myscript.py'.

        Thomas

        Comment

        • Daniel Dittmar

          #5
          Re: Stop popup cmd window

          hokiegal99 wrote:[color=blue]
          > How can I specify pythonw.exe over python.exe? The task scheduler has
          > no place for this sort of thing.[/color]

          Give your script a .pyw extension:
          [0] d:\ >ftype | grep py
          Python.Compiled File=C:\Python2 3\python.exe "%1" %*
          Python.File=C:\ Python23\python .exe "%1" %*
          Python.NoConFil e=C:\Python23\p ythonw.exe "%1" %*

          [0] d:\ >assoc | grep Python
          ..py=Python.Fil e
          ..pyc=Python.Co mpiledFile
          ..pyo=Python.Co mpiledFile
          ..pyw=Python.No ConFile

          You can also give a full commandline to the scheduler, including the path to
          pythonw.exe and the path to your script as the first argument.

          Daniel



          Comment

          • hokieghal99

            #6
            Re: Stop popup cmd window

            Thomas Heller wrote:
            [color=blue]
            > Name the script 'myscript.pyw' instead of 'myscript.py'.
            >
            > Thomas[/color]

            Thanks for the tip... that did it. I need to read up on the difference
            between python.exe and pythonw.exe.

            Thanks again!!!


            Comment

            • Derrick 'dman' Hudson

              #7
              Re: Stop popup cmd window

              On Tue, 16 Dec 2003 18:06:16 -0500, hokieghal99 wrote:[color=blue]
              > Thomas Heller wrote:
              >[color=green]
              >> Name the script 'myscript.pyw' instead of 'myscript.py'.
              >>
              >> Thomas[/color]
              >
              > Thanks for the tip... that did it. I need to read up on the difference
              > between python.exe and pythonw.exe.[/color]

              The difference is a Microsoft one. The former has stdin, stdout and
              is a normal program. Microsoft dictates that on Windows such programs
              must have a black window appear for the life of the program. The
              latter is an "MFC" (or whatever the proper term is) program with no
              stdin or stdout. On MS Windows this means that you don't get a black
              box appearing, and it also means that the 'print' statement and
              raw_input() function are useless. The difference is the specific
              functions the C runtime calls to notify Windows of which sort of app
              it is during startup. On non-Windows platforms (eg UNIX) there is no
              such distinction. All (UNIX) apps have stdin and stdout, though they
              aren't necessarily connected to the user in any way, but could be if
              run in such a context.

              HTH,
              -D

              --
              For society, it's probably a good thing that engineers value function
              over appearance. For example, you wouldn't want engineers to build
              nuclear power plants that only _look_ like they would keep all the
              radiation inside.
              (Scott Adams - The Dilbert principle)

              www: http://dman13.dyndns.org/~dman/ jabber: dman@dman13.dyn dns.org

              Comment

              • Fredrik Lundh

                #8
                Re: Stop popup cmd window

                Derrick 'dman' Hudson wrote:
                [color=blue][color=green]
                > > Thanks for the tip... that did it. I need to read up on the difference
                > > between python.exe and pythonw.exe.[/color][/color]

                Same program, linked in different ways. See below.
                [color=blue]
                > The difference is a Microsoft one. The former has stdin, stdout and
                > is a normal program. Microsoft dictates that on Windows such programs
                > must have a black window appear for the life of the program.[/color]

                Programs linked for the "console" subsystem (aka "character-mode
                applications") have to be connected to a console window. If they're
                not, Windows creates one for them.

                (I'm pretty sure this is done by the loader and not the C runtime).
                [color=blue]
                > The latter is an "MFC" (or whatever the proper term is)[/color]

                The "windows" subsystem.
                [color=blue]
                > The difference is the specific functions the C runtime calls to notify
                > Windows of which sort of app it is during startup.[/color]

                A linker option, usually (/subsystem)

                A console program may use the Windows API to disconnect from the
                console, or create a window, and a window program may use the API
                to create a console if it needs one (a version of pythonw that did this
                if/when the application prints to sys.stderr would be quite useful, btw)

                </F>




                Comment

                • Dave Benjamin

                  #9
                  Re: Stop popup cmd window

                  In article <mailman.272.10 71697837.9307.p ython-list@python.org >, Fredrik Lundh wrote:[color=blue]
                  > A console program may use the Windows API to disconnect from the
                  > console, or create a window, and a window program may use the API
                  > to create a console if it needs one (a version of pythonw that did this
                  > if/when the application prints to sys.stderr would be quite useful, btw)[/color]

                  Yes! Especially if it paused afterwards, so you could actually read the
                  error message! Speaking of which, is there any way to keep the console
                  window on the screen after double-clicking on a .py file so that syntax
                  errors don't result in a spead-reading test?

                  Thanks,
                  Dave

                  --
                  ..:[ dave benjamin (ramenboy) -:- www.ramenfest.com -:- www.3dex.com ]:.
                  : d r i n k i n g l i f e o u t o f t h e c o n t a i n e r :

                  Comment

                  • Thomas Heller

                    #10
                    Re: Stop popup cmd window

                    Dave Benjamin <ramen@lackingt alent.com> writes:
                    [color=blue]
                    > In article <mailman.272.10 71697837.9307.p ython-list@python.org >,
                    > Fredrik Lundh wrote:[color=green]
                    >> A console program may use the Windows API to disconnect from the
                    >> console, or create a window, and a window program may use the API to
                    >> create a console if it needs one (a version of pythonw that did this
                    >> if/when the application prints to sys.stderr would be quite useful,
                    >> btw)[/color]
                    >
                    > Yes! Especially if it paused afterwards, so you could actually read
                    > the error message! Speaking of which, is there any way to keep the
                    > console window on the screen after double-clicking on a .py file so
                    > that syntax errors don't result in a spead-reading test?[/color]

                    Several I can think of.

                    - untested, but you get the idea:

                    try:
                    main()
                    except:
                    import traceback
                    traceback.print _exc()
                    raw_input()

                    - set the PYTHONINSPECT env variable during runtime

                    - or even fire up the debugger when a problem occurs:

                    <http://aspn.activestat e.com/ASPN/Cookbook/Python/Recipe/65287>

                    And, by the way, py2exe 0.5 (still officially unreleased and
                    undocumented) created console-less programs automatically write
                    exceptions into a logfile.

                    Thomas

                    Comment

                    • Dave Benjamin

                      #11
                      Re: Stop popup cmd window

                      In article <fzfg92gl.fsf@p ython.net>, Thomas Heller wrote:[color=blue]
                      > Dave Benjamin <ramen@lackingt alent.com> writes:
                      >[color=green]
                      >> In article <mailman.272.10 71697837.9307.p ython-list@python.org >,
                      >> Fredrik Lundh wrote:[color=darkred]
                      >>> A console program may use the Windows API to disconnect from the
                      >>> console, or create a window, and a window program may use the API to
                      >>> create a console if it needs one (a version of pythonw that did this
                      >>> if/when the application prints to sys.stderr would be quite useful,
                      >>> btw)[/color]
                      >>
                      >> Yes! Especially if it paused afterwards, so you could actually read
                      >> the error message! Speaking of which, is there any way to keep the
                      >> console window on the screen after double-clicking on a .py file so
                      >> that syntax errors don't result in a spead-reading test?[/color]
                      >
                      > Several I can think of.
                      >
                      > - untested, but you get the idea:
                      >
                      > try:
                      > main()
                      > except:
                      > import traceback
                      > traceback.print _exc()
                      > raw_input()[/color]

                      This is the sort of thing I usually do, but it doesn't catch syntax errors.
                      I wind up in this state of self-conflict, unsure if I should just run the
                      program again, and read really fast (which rarely works, because it always
                      runs faster the second time) or if I should just bite the bullet and open up
                      a command window. Sometimes, it takes me awhile to recover. ;)
                      [color=blue]
                      > - set the PYTHONINSPECT env variable during runtime[/color]

                      I didn't even know it existed. =)
                      [color=blue]
                      > - or even fire up the debugger when a problem occurs:
                      >
                      ><http://aspn.activestat e.com/ASPN/Cookbook/Python/Recipe/65287>[/color]

                      Cool!
                      [color=blue]
                      > And, by the way, py2exe 0.5 (still officially unreleased and
                      > undocumented) created console-less programs automatically write
                      > exceptions into a logfile.[/color]

                      Can py2exe produce a custom Python interpreter? Kind of like how freewrap
                      did this with Tcl, where your "wrapped" program could be used as an
                      interpreter to run other scripts in an environment of your choice?

                      Thanks for the info.

                      --
                      ..:[ dave benjamin (ramenboy) -:- www.ramenfest.com -:- www.3dex.com ]:.
                      : d r i n k i n g l i f e o u t o f t h e c o n t a i n e r :

                      Comment

                      Working...