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

Discussion in 'Python' started by GaryLee, Sep 16, 2007.

  1. GaryLee

    GaryLee Guest

    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
     
    GaryLee, Sep 16, 2007
    #1
    1. Advertising

  2. GaryLee

    Duncan Booth Guest

    GaryLee <> 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 %*)
     
    Duncan Booth, Sep 16, 2007
    #2
    1. Advertising

  3. GaryLee

    GaryLee Guest

    On 9 16 , 9 09 , Duncan Booth <> wrote:
    > GaryLee <> 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.
     
    GaryLee, Sep 17, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Flip
    Replies:
    3
    Views:
    1,003
    Tony Morris
    Feb 9, 2004
  2. misiek3d
    Replies:
    1
    Views:
    391
    Dino Viehland
    Jun 28, 2007
  3. Aaron Bertrand - MVP

    How can I list all files of a directory with fso or wsh....?

    Aaron Bertrand - MVP, Feb 11, 2004, in forum: ASP General
    Replies:
    1
    Views:
    157
    Vilmar Braz√£o de Oliveira
    Feb 11, 2004
  4. ben h

    Can I call a WSH from ASP?

    ben h, Jul 8, 2004, in forum: ASP General
    Replies:
    1
    Views:
    107
    Michael Harris \(MVP\)
    Jul 8, 2004
  5. Sojwal

    Can't execute WSH script from bat file

    Sojwal, Aug 13, 2004, in forum: ASP General
    Replies:
    0
    Views:
    110
    Sojwal
    Aug 13, 2004
Loading...

Share This Page