Re: Perl & Window's system stuff: Can they get along?
by orbital (Scribe) on Mar 19, 2001 at 04:26 UTC
|
To open long filenames with spaces enbedded use single quotes.
To make a shortcut use Win32::Shortcut, it comes standard with the ActiveState distrubution.
To find out the system path I probably wouldn't do it through perl I would probably use a system call to the Dos shell and use the Enviromental Variables there it would be much easier to access. Otherwise the only way I can think of off hand is to use Win32::TieRegistry or Win32::Registry.
great sources of Win32 info is http://perl.dada.it or David Roth's Site Roth has written many Win32 modules and has several very good book on the subject on programming and administrating a Win32 environment. Be careful his books aren't intended for the novice they assume a solid understanding of perl's core functions. | [reply] [Watch: Dir/Any] |
|
On an NT-based system, there's no need to do a system call to the shell to determine the Windows directory. $ENV{windir} (or $ENV{SystemRoot}) has it.
Update: As pointed out below, $ENV{windir} works on 9x systems as well.
| [reply] [Watch: Dir/Any] [d/l] [select] |
|
$ENV{'windir'} also works fine on 9x.
In 9x the start menu can be found in the registry :
'HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Start Menu'
I dont know about NT/2k, but it should be the same.
hope this helps you
Braindead One
| [reply] [Watch: Dir/Any] |
|
|
|
(crazyinsomniac: so lazy, what a shame) Re: Perl & Window's system stuff: Can they get along?
by crazyinsomniac (Prior) on Mar 19, 2001 at 12:51 UTC
|
I'm suprised you did not look at your perl documentation, look what I found just in the table of contents.
All of the following come with the standard perl distribution:
(at least ActivePerl and Indigoperl)
perl5004delta
perlamiga
perlcygwin
perldos
perlhpux
perlmachten
perlos2
perlos390
perlvms
perlwin32 <<<<< See that, that's part of the standard documentat
+ion
Win32 <<<<< just like perldata, perlop, perlsyn, perlre ...
use Win32;
Win32::CopyFile(FROM, TO, OVERWRITE)
Win32::CopyFile()
Win32::GetFullPathName(FILENAME)
Win32::GetShortPathName()
Win32::GetLongPathName()
Win32::Spawn(COMMAND, ARGS, PID)
File::Spec::Win32
Win32::File;
Win32
API
AuthenticateUser
ChangeNotify
Clipboard
Console
DBIODBC
DDE
Callback
Client
Event
EventLog
File
FileSecurity
Internet
IPC
Mutex
NetAdmin
NetResource
ODBC
OLE
Browser
Browser
Const
Enum
NEWS
NLS
TPJ
Variant
PerfLib
Pipe
Process
Registry
Semaphore
Service
Sound
TieRegistry
Win32API
File
Net
Registry
___crazyinsomniac_______________________________________
Disclaimer: Don't blame. It came from inside the void
perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;" | [reply] [Watch: Dir/Any] [d/l] |
Re: Perl & Window's system stuff: Can they get along?
by Corion (Patriarch) on Mar 19, 2001 at 03:50 UTC
|
I suggest you have a close look at how the IndigoPerl installer does the installation / setup of IndigoPerl. They create links to Apache in the Start Menu.
For the name and location of the special system folders, you could either dig in the registry for the keys that hold these values (Win32::TieRegistry would be a good module) or you could use the appropriate Win32 system calls (Win32::API is the module for that).
| [reply] [Watch: Dir/Any] |
Re: Perl & Window's system stuff: Can they get along?
by damian1301 (Curate) on Mar 19, 2001 at 03:14 UTC
|
1. unless(-e 'C:/Bah/bah/black/sheep'){print "doesn't exist";} 2.you open it. This will automatically create it. 3. File::find might work for this, I am not too sure though.
Almost a Perl hacker. Dave AKA damian
I encourage you to email me | [reply] [Watch: Dir/Any] [d/l] [select] |
Re: Perl & Window's system stuff: Can they get along?
by clemburg (Curate) on Mar 19, 2001 at 15:28 UTC
|
Also, to get filename handling with DOS-like wildcards
under Win32 right,
you will need to use File::DosGlob in your
scripts.
Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com
| [reply] [Watch: Dir/Any] |
Re: Perl & Window's system stuff: Can they get along?
by thabenksta (Pilgrim) on Mar 19, 2001 at 20:07 UTC
|
As far as the filename, in dos you can use the first six letters(w\o spaces) a '~' and a sequential number. Ex.
C:\Program Files\ would be C:\progra~1, and C:\Programming would be C:\progra~2.
Hope this helped.
thaben~1
| [reply] [Watch: Dir/Any] |
|
This is fairly dangerous advice. If you have two files / directories with long names, say "directory_A" and
"directory_B", they don't get the same short name,
"direct~1", but they get "direct~1" and "direct~2" on a first-come, first-served base.
If, under Windows NT (SP3 and higher I believe), the number of long filenames gets larger than 100, NT ditches the serial assignment of short filenames due to performance reasons (always looking at all filenames to get the next number takes too long) and uses a hash of the long filename to create the short name and moves on if collisions were found. Thus, under NT, it's quite possible to see filenames such as "dir~DEAD" as the short name for any of the two long names.
Also, if prior to the installation of Windows on a harddisk already formatted with the FAT32 filesystem, there already exists a directory with the name "Programming" (or, as with the german installation of Windows, where the directory "Program Files" has been correctly translated into "Programme") without "Program Files" having been there before, "Program Files" will have the short name "Progra~2". I can also tell you that hardcoding "C:/Program Files" into your programs will only bring you aggravated international users, as the name
"Program Files" is not universal over the various language versions of Windows.
| [reply] [Watch: Dir/Any] |
|
ok,ok. not a good idea. so sorry. (jk)
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |