473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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("ipconfig /all", "r")
msg = MIMEText(fp.read())
fp.close()

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

h = "smtp.vt.edu"
s = smtplib.SMTP(h)
s.sendmail(f, t, msg.as_string())
s.quit()
Jul 18 '05 #1
10 9606
On 15 Dec 2003 13:28:01 -0800, hokiegal99 wrote:
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.


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: dm**@dman13.dyndns.org
Jul 18 '05 #2
> On 15 Dec 2003 13:28:01 -0800, hokiegal99 wrote:
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.


Use a better OS? <0.5 wink>

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


How can I specify pythonw.exe over python.exe? The task scheduler has
no place for this sort of thing.
Jul 18 '05 #3
ho********@hotmail.com (hokiegal99) writes:
On 15 Dec 2003 13:28:01 -0800, hokiegal99 wrote:
> 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.


Use a better OS? <0.5 wink>

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


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


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

Thomas
Jul 18 '05 #4
hokiegal99 wrote:
How can I specify pythonw.exe over python.exe? The task scheduler has
no place for this sort of thing.


Give your script a .pyw extension:
[0] d:\ >ftype | grep py
Python.CompiledFile=C:\Python23\python.exe "%1" %*
Python.File=C:\Python23\python.exe "%1" %*
Python.NoConFile=C:\Python23\pythonw.exe "%1" %*

[0] d:\ >assoc | grep Python
..py=Python.File
..pyc=Python.CompiledFile
..pyo=Python.CompiledFile
..pyw=Python.NoConFile

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

Jul 18 '05 #5
Thomas Heller wrote:
Name the script 'myscript.pyw' instead of 'myscript.py'.

Thomas


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

Thanks again!!!
Jul 18 '05 #6
On Tue, 16 Dec 2003 18:06:16 -0500, hokieghal99 wrote:
Thomas Heller wrote:
Name the script 'myscript.pyw' instead of 'myscript.py'.

Thomas


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


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: dm**@dman13.dyndns.org
Jul 18 '05 #7
Derrick 'dman' Hudson wrote:
Thanks for the tip... that did it. I need to read up on the difference
between python.exe and pythonw.exe.

Same program, linked in different ways. See below.
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.
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).
The latter is an "MFC" (or whatever the proper term is)
The "windows" subsystem.
The difference is the specific functions the C runtime calls to notify
Windows of which sort of app it is during startup.


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>


Jul 18 '05 #8
In article <ma*************************************@python.or g>, Fredrik Lundh wrote:
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)


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 :
Jul 18 '05 #9
Dave Benjamin <ra***@lackingtalent.com> writes:
In article <ma*************************************@python.or g>,
Fredrik Lundh wrote:
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)


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?


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.activestate.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
Jul 18 '05 #10
In article <fz**********@python.net>, Thomas Heller wrote:
Dave Benjamin <ra***@lackingtalent.com> writes:
In article <ma*************************************@python.or g>,
Fredrik Lundh wrote:
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)
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?


Several I can think of.

- untested, but you get the idea:

try:
main()
except:
import traceback
traceback.print_exc()
raw_input()


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. ;)
- set the PYTHONINSPECT env variable during runtime
I didn't even know it existed. =)
- or even fire up the debugger when a problem occurs:

<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65287>
Cool!
And, by the way, py2exe 0.5 (still officially unreleased and
undocumented) created console-less programs automatically write
exceptions into a logfile.


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 :
Jul 18 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Noozer | last post by:
When using the WebBrowser control, is it possible to cause popup windows to appear within the WebBrowser control itself instead of a new window? This is what I've written in the NewWindow2 event,...
6
by: Baffin Shea | last post by:
Dear All, I am a beginner in javascript and looking for help, I put the following script in the original.asp: function NewWindows() { window.open("abc.asp", "new") }
2
by: Moon | last post by:
Seems I still haven't got the hang of all those window generating code in Javascript. I've got a page with about 15 photo thumbnails. When you click on a thumbnail a new window pops up which shows...
5
by: Obantec Support | last post by:
Hi i leached some code and strung together a popup i need for a page with 5 help buttons. Now i could use 5 scripts and pre-load the values but i would rather get a better understanding of how...
15
by: | last post by:
So many websites can get around my Googlebar's popup blockers. Even Opera 8 can not stop those popups. I looked into the codes, and I can find nothing showing me how it is done. Can anyone help me...
4
by: Davey | last post by:
I have a website which has a popup window (this only opens when the user chooses to open it). In the popup window I have a <select> control which lists a selection of "classes". Each class has a...
7
by: anthony.turcotte | last post by:
Hi, I've looked for a solution to this problem on google, read posts in this newsgroup and I still haven't found anything that could help me. Here's the scenario. 1. User accesses...
1
by: sachin jain | last post by:
hi all, I am facing this problem ...i av a datagrind with buttoncolumn as linkbutton. on clicking it i m opening a popup window and on this popup window i av a button on whose clickevent i m using...
3
by: tess | last post by:
We are coding a popup window on exit of our site. We do not want this popup to occur if someone hits the back button. How do we stop this. Any hints?
3
by: mark4asp | last post by:
How can I stop my Calendar control from firing the form validation events? I have a form containing several controls which have several validation controls each. One control is a TextBox...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.