|XP is just a number|
Getopts with NT4 and Win9x shortcutsby mkmcconn (Chaplain)
|on Jul 24, 2002 at 16:48 UTC||Need Help??|
mkmcconn has asked for the wisdom of the Perl Monks concerning the following question:
This is a perlrun Windows question.
On our network, I provide users with several ways to use perl scripts. The most popular method among Windows users has been to convert the script to a batch file, launched with a shortcut on the desktop. The user can then drag an icon or group of icons onto the shortcut, which provides the script with the argument list of files or folders for the operation.
In several of the more complicated scripts, I use Getopt::Long for parsing the options. But, I have discovered that NT4 and Win9x do not properly handle the options, using this method. When the shortcut is launched without arguments, the options are parsed normally. But if the argument list is provided by dropping file or folder icons onto the shortcut, the options are silently ignored.
Options are parsed as expected in Windows 2000 and XP.
My question: Do you know of a way to cause NT4 and Win9x shortcuts to behave the same as Windows 2000?
A little test script follows the READMORE tag, if you have opportunity to try it for yourself.
In the shortcut to the batchfile, the commandline looks like this:
\\netshare\testprob.bat --noalways -v -c=3 --recursive
On all Windows versions tested, the output without an argument list is:
--noalways|-v|-c=3|--recursive (GetOptions is here) Process completed
Now, dropping a list of icons onto the shortcut, versions behave differently
--noalways|-v|-c=3|--recursive|C:\c-media|C:\bin|C:\bats (GetOptions is here) C:\c-media|C:\bin|C:\bats Process completed
NT4 and Win9x:
C:\c-media|C:\bin|C:\bats (GetOptions is here) C:\c-media|C:\bin|C:\bats Process completed
Note that the options list is never seen by the script. Options are deleted by Windows, and only the argument list is presented to the script.
Can NT4 and Win9x shortcuts be caused to behave the same as Windows 2000?