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

G

GaryLee

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
 
D

Duncan Booth

GaryLee said:
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 %*)
 
G

GaryLee

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top