473,811 Members | 3,687 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing arguments to exe

I have created what amounts to a simple GUI email sending program
using Python + wxPython. I have modified the mailto registration in
the Windows Registry so that it launches the script when someone
clicks on someone's email link in a web page.

While this works great if I create a convoluted path command as the
registry entry and pass in the email argument to the script, it
doesn't work at all if I turn my python file into an exe using py2exe.

How does one get a python file to accept arguments when said script
has been turned into an executable?

I'm sure I'm just missing something obvious. I am using Python 2.4 on
Window XP SP2.

Thanks,

Mike
Dec 14 '07 #1
5 4499
On Dec 15, 9:01 am, kyoso...@gmail. com wrote:
I have created what amounts to a simple GUI email sending program
using Python + wxPython. I have modified the mailto registration in
the Windows Registry so that it launches the script when someone
clicks on someone's email link in a web page.

While this works great if I create a convoluted path command as the
registry entry and pass in the email argument to the script,
It would help if you would give an actual code example of what you
mean by "convoluted path command" and "pass in the email argument to
the script".
it
doesn't work at all if I turn my python file into an exe using py2exe.
"it doesn't work" is user-speak. What does it do? Does it execute the
executable at all? If not, check your "convoluted path". If so, what
arguments are received?
>
How does one get a python file to accept arguments when said script
has been turned into an executable?
If the script is expecting its arguments in sys.argv, I would expect
that to work with an executable also. My guess is that you are falling
foul of some argument-quoting problem. I also guess that you have not
tried something like the following at the start of your script:

print >your_log_fil e, "sys.argv:" , repr(sys.argv)

and run it both as a script and an executable.

Have you tried running the executable stand-alone e.g. Start | Run,
type in
your_exe_file b1**@aol.com
or whatever the argument(s) are?

HTH,
John

Dec 14 '07 #2
On Dec 14, 4:51 pm, John Machin <sjmac...@lexic on.netwrote:
On Dec 15, 9:01 am, kyoso...@gmail. com wrote:
I have created what amounts to a simple GUI email sending program
using Python + wxPython. I have modified the mailto registration in
the Windows Registry so that it launches the script when someone
clicks on someone's email link in a web page.
While this works great if I create a convoluted path command as the
registry entry and pass in the email argument to the script,

It would help if you would give an actual code example of what you
mean by "convoluted path command" and "pass in the email argument to
the script".
Ok, I modify HKEY_CLASSES_RO OT\mailto\shell \open\command to do this:

cmd /C "SET PYTHONHOME=\\se rvername\NETLOG ON\Python24&&\\ servername
\netlogon\pytho n24\python.exe \\path\to\my\sc ript\wxsendmail .py %1"

>
it
doesn't work at all if I turn my python file into an exe using py2exe.

"it doesn't work" is user-speak.
I've written posts where I've been quite technical and gotten very
little to no response...admi ttedly, this was pretty vague though...

What does it do? Does it execute the
executable at all? If not, check your "convoluted path". If so, what
arguments are received?
The executable runs, but no argument appears to get passed into it. Of
course, I don't really know that for sure as the executable doesn't
redirect stdout/stderr. I tried doing something like this in the above
reg entry:

cmd /C "c:\program files\myProg.ex e %1"
"c:\program files\myProg.ex e %1"
"c:\program files\myProg.ex e"

None of those worked.
>
How does one get a python file to accept arguments when said script
has been turned into an executable?

If the script is expecting its arguments in sys.argv, I would expect
that to work with an executable also. My guess is that you are falling
foul of some argument-quoting problem. I also guess that you have not
tried something like the following at the start of your script:

print >your_log_fil e, "sys.argv:" , repr(sys.argv)

and run it both as a script and an executable.

I do have my script set up to find its arguments in sys.argv. And no,
I don't have that print screen. As mentioned above, I don't have a
console window open when the exe runs, so I won't see any output from
it. I'll have to modify it to do that when I'm back at my work PC.
>
Have you tried running the executable stand-alone e.g. Start | Run,
type in
your_exe_file b...@aol.com
or whatever the argument(s) are?
No, but that's a good idea. Why didn't I think of that!? (don't answer
that)
>
HTH,
John
Thanks for the suggestions.

Mike
Dec 15 '07 #3
On Dec 15, 11:38 am, kyoso...@gmail. com wrote:
On Dec 14, 4:51 pm, John Machin <sjmac...@lexic on.netwrote:
On Dec 15, 9:01 am, kyoso...@gmail. com wrote:
I have created what amounts to a simple GUI email sending program
using Python + wxPython. I have modified the mailto registration in
the Windows Registry so that it launches the script when someone
clicks on someone's email link in a web page.
While this works great if I create a convoluted path command as the
registry entry and pass in the email argument to the script,
It would help if you would give an actual code example of what you
mean by "convoluted path command" and "pass in the email argument to
the script".

Ok, I modify HKEY_CLASSES_RO OT\mailto\shell \open\command to do this:

cmd /C "SET PYTHONHOME=\\se rvername\NETLOG ON\Python24&&\\ servername
\netlogon\pytho n24\python.exe \\path\to\my\sc ript\wxsendmail .py %1"
it
doesn't work at all if I turn my python file into an exe using py2exe.
"it doesn't work" is user-speak.

I've written posts where I've been quite technical and gotten very
little to no response...admi ttedly, this was pretty vague though...
What does it do? Does it execute the
executable at all? If not, check your "convoluted path". If so, what
arguments are received?

The executable runs,
how do you know it runs?
but no argument appears to get passed into it.
appears??
Of
course, I don't really know that for sure as the executable doesn't
redirect stdout/stderr. I tried doing something like this in the above
reg entry:

cmd /C "c:\program files\myProg.ex e %1"
"c:\program files\myProg.ex e %1"
"c:\program files\myProg.ex e"

None of those worked.
How does one get a python file to accept arguments when said script
has been turned into an executable?
If the script is expecting its arguments in sys.argv, I would expect
that to work with an executable also. My guess is that you are falling
foul of some argument-quoting problem. I also guess that you have not
tried something like the following at the start of your script:
print >your_log_fil e, "sys.argv:" , repr(sys.argv)
and run it both as a script and an executable.

I do have my script set up to find its arguments in sys.argv. And no,
I don't have that print screen.
"""print >your_log_file, """ implies "print screen"?
As mentioned above, I don't have a
console window open when the exe runs, so I won't see any output from
it. I'll have to modify it to do that when I'm back at my work PC.
Have you tried running the executable stand-alone e.g. Start | Run,
type in
your_exe_file b...@aol.com
or whatever the argument(s) are?

No, but that's a good idea. Why didn't I think of that!? (don't answer
that)
OK, I won't :-)
>

Thanks for the suggestions.
You're welcome.
Dec 15 '07 #4
On Dec 14, 8:06 pm, John Machin <sjmac...@lexic on.netwrote:

<snipped>
>
The executable runs,

how do you know it runs?
because the program's GUI appears on-screen.

but no argument appears to get passed into it.

appears??

Since the TO field doesn't get populated with the email address, it
doesn't appear to receive it as an argument. Whereas if I run it as a
script, it does receive the email address.

Mike

Dec 15 '07 #5
On Dec 15, 6:46 pm, Dennis Lee Bieber <wlfr...@ix.net com.comwrote:
On Fri, 14 Dec 2007 16:38:28 -0800 (PST), kyoso...@gmail. com declaimed
the following in comp.lang.pytho n:
The executable runs, but no argument appears to get passed into it. Of
course, I don't really know that for sure as the executable doesn't
redirect stdout/stderr. I tried doing something like this in the above
reg entry:
cmd /C "c:\program files\myProg.ex e %1"
"c:\program files\myProg.ex e %1"
"c:\program files\myProg.ex e"

What happens if you put the %1 OUTSIDE the quotes...

cmd /c "c:\program files\myProg.ex e" "%1"

After all, if the quotes are being used to keep the command line seeing
"program files" as a single term in the path, then your quotes are also
treating "myProg.exe %1" as a single term.
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfr...@ix.netc om.com wulfr...@bestia ria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: web-a...@bestiaria. com)
HTTP://www.bestiaria.com/
This works:

"c:\program files\myProg.ex e" %1

Thanks for the tip.
Dec 18 '07 #6

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

Similar topics

7
49588
by: Pavils Jurjans | last post by:
Hallo, I have been programming for restricted environments where Internet Explorer is a standard, so I haven't stumbled upon this problem until now, when I need to write a DOM-compatible code. The question is about best practices for passing parameters to an event function. I have, say, the following HTML:
3
14963
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
7
2872
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID parameter to the XSLT stylesheet XsltArgumentList xsltArgList = new XsltArgumentList(); xsltArgList.AddParam("pmID", "", pmID); xmlItems.TransformArgumentList = xsltArgList;
39
7685
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down indicate: a) That I don't know enough b) Passing arguments by ref is bad
5
3919
by: Michael | last post by:
Hi, once I read here that it is not 'a good idea' to pass variables that are not initialized to a function. I have void something ( double *vector ); ....
3
3939
by: Mantorok | last post by:
Hi all I'm pretty new to ASP.Net, is it possible to pass arguments (maybe objects too) to web forms without using a querystring in the URL? Thanks Kev
4
1973
by: Justine | last post by:
Can anyone help? e.g. when you open a vb project property page, in "Configuration Properties" You will see "Command line arguments" in "Start Options". Does anyone knows how to find a way to do arguments passing. Thank you. ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
7
1984
by: Bonzo | last post by:
>From within a function, I want to pass a/some parameters to another function, AND all arguments, passed into this function. e.g. function firstFunction(){ //this function may have been passed, 0, 1, or n arguments... ... //call another function... var someCalculatedValue = 'someValue';
2
4248
by: william.w.oneill | last post by:
I have an application that takes a few command line parameters. As recommended by others in this group, I'm using a named mutex to ensure that only one instance of the application is running. My question is how to elegantly pass a command line parameter from Instance_B to Instance_A where Instance_A was running prior to Instance_B. For example, the user can launch the program by passing a file name as a command line argument. The program...
0
9726
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10384
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10395
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10130
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6887
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4338
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.