Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Can't see the arguements when use Python in WSH.

Reply
Thread Tools

Can't see the arguements when use Python in WSH.

 
 
GaryLee
Guest
Posts: n/a
 
      09-16-2007
Hi, Folks:

I am using Python in WSH. However, I got a strange problem on my
computer. Here is a small program to show the problem.

# xxx.pys
objArgs = WScript.Arguments
for i in xrange(objArgs.Count()):
WScript.Echo(objArgs(i))
WScript.Echo('Total %d arguments.' % objArgs.Count())

If I execute this document by following command, the objArgs.Count()
always return 0 and no argument was included.
> xxx.pys 1 2 3 4


Because, the script will show "Totals 0 arguments", the program can be
executed normally. It just can't get the arguments. However, if I use
following command to execute the script. I can get the arguments.
> wscript.exe xxx.py 1 2 3 4


If I drag some documents and drop them onto the icon of xxx.pys file,
it still can't get the arguments. I am sure that the DropHandler has
been set properly.

Finally, I use a wsf file to embeded the same script file. It looks
like this:

<?xml version="1.0" ?>
<package id="xxx">
<job id="myjob">
<comment>blah blah</comment>
<script language="python">
<![CDATA[
objArgs = WScript.Arguments
for i in xrange(objArgs.Count()):
WScript.Echo(objArgs(i))
WScript.Echo('Total %d arguments.' % objArgs.Count())
]]>
</script>
</job>
</package>

This wsf file can work very well. When I drop some files onto it, it
can show the path of those documents. However, I just want to know why
my pys file can't work.

Does anyone have the same situation? Is it my pywin32 package
corrupted? I've downloaded the last pywin32 package and executed the
site-packages\win32comext\axscript\client\pyscript.py to register the
PyScript. But, the problem is still there.

Sincerely yours,
Gary

 
Reply With Quote
 
 
 
 
Duncan Booth
Guest
Posts: n/a
 
      09-16-2007
GaryLee <(E-Mail Removed)> wrote:

> Does anyone have the same situation? Is it my pywin32 package
> corrupted? I've downloaded the last pywin32 package and executed the
> site-packages\win32comext\axscript\client\pyscript.py to register the
> PyScript. But, the problem is still there.
>

I've no idea why pyscript.py doesn't set up the registry correctly, but it
should all work if you run the command:

ftype pysFile=%SystemRoot%\System32\WScript.exe "%1" %*

(If you wish you can try "ftype pysFile" first to see the current setting.
On my system the file association wasn't set at all but it sounds like on
yours it may be set but missing the %*)
 
Reply With Quote
 
 
 
 
GaryLee
Guest
Posts: n/a
 
      09-17-2007
On 9 16 , 9 09 , Duncan Booth <(E-Mail Removed)> wrote:
> GaryLee <(E-Mail Removed)> wrote:
> > Does anyone have the same situation? Is it my pywin32 package
> > corrupted? I've downloaded the last pywin32 package and executed the
> > site-packages\win32comext\axscript\client\pyscript.py to register the
> > PyScript. But, the problem is still there.

>
> I've no idea why pyscript.py doesn't set up the registry correctly, but it
> should all work if you run the command:
>
> ftype pysFile=%SystemRoot%\System32\WScript.exe "%1" %*
>
> (If you wish you can try "ftype pysFile" first to see the current setting.
> On my system the file association wasn't set at all but it sounds like on
> yours it may be set but missing the %*)


I am sure that my setting in registry is correct. After run ftype
pysFile, I got the following response.

> ftype pysFile

pysFile=%SystemRoot%\System32\WScript.exe "%1" %*

I've also checked the DropHandler setting in registry. The value is
correct.
I just don't want to re-install my python 2.4, because I've installed
too many package.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ReadOnly Properties - Arguements For/Against Rob Meade ASP .Net 5 12-05-2005 03:53 PM
Error Installing Eng-US Language Packs, 208 Invalid Arguements, Firefox 1.0.2 pixturesk@hotmail.com Firefox 6 03-26-2005 01:50 AM
explict keyword for constructors with no arguements ? Ganesh Gella C++ 2 11-02-2004 07:40 AM
explict keyword for constructors with no arguements ? Ganesh Gella C++ 1 11-01-2004 10:05 PM
sending command line arguements to HTML Tidy d davis Perl 0 04-27-2004 02:23 PM



Advertisments