home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / ntcode / ntperlb / install.cmd next >
Encoding:
Text File  |  1995-05-19  |  2.3 KB  |  74 lines

  1. @rem = '-*- Perl -*-';
  2. @rem = '
  3. @echo off
  4. .\perl %0.cmd %1 %2 %3 %4 %5 %6 %7 %8 %9
  5. goto endofperl
  6. ';
  7.  
  8. #
  9. # this perl script is used to install NT registry keys and environment
  10. # variables for perl. It takes one optional argument, the directory where
  11. # perl resides (defaults to the current directory).
  12. #
  13.  
  14. if (@ARGV == 0) { 
  15.     chop ($perldir = `cd`);
  16.     $perldir =~ tr/A-Z/a-z/;
  17. }
  18. else {
  19.     ($perldir = shift) =~ tr/A-Z/a-z/;
  20. }
  21.  
  22. die "Can't find $perldir\\perl.exe!\n" 
  23.     if ! -e "$perldir\\perl.exe";
  24.  
  25. print "Installing NT Perl in $perldir\n";
  26. unshift (@INC, "$perldir\\lib");
  27. require "registry.pl";
  28.  
  29. #
  30. # First put the keys that perl will use into the registry
  31. #
  32. &RegCreateKeyEx ($HKEY_LOCAL_MACHINE, 
  33.          "SOFTWARE\\Intergraph\\Perl\\4.036\\Parameters", 
  34.          0, 0, $REG_OPTIONS_NON_VOLATILE, 
  35.          $KEY_ALL_ACCESS, 0, $key, $disp) ||
  36.     die "Can't open parameter key: $!\n";
  37.  
  38. &RegSetValueEx($key, "PRIVLIB", 0, $REG_SZ, "$perldir\\lib") ||
  39.     die "Can't set PRIVLIB value in registry: $!\n";
  40. print "Added PRIVLIB key (for locating library files) as $perldir\\lib\n";
  41. &RegSetValueEx($key, "BIN", 0, $REG_SZ, "$perldir") ||
  42.     die "Can't set BIN value in registry: $!\n";
  43. print "Added BIN key (for locating executable files) as $perldir\n";
  44.  
  45. &RegCloseKey($key);
  46.  
  47. #
  48. # Now add the perl directory to the default path
  49. #
  50. &RegOpenKeyEx ($HKEY_LOCAL_MACHINE, 
  51.         "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",
  52.            0, $KEY_ALL_ACCESS, $key) ||
  53.     die "Can't open Session Manager Environment for update: $!\n";
  54. &RegQueryValueEx ($key, "Path", 0, $type, $pathstring) ||
  55.     die "Can't get Session Manager Path value: $!\n";
  56. #
  57. # I had more fun with this than I should be allowed to have!
  58. # The idea here is to check the path string for any old perl paths, omitting
  59. # them if found. Then re-assemble the path string, prepending the new perl 
  60. # path to the path string. All of this in one line...incredible!
  61. #
  62.  
  63. $newstring = 
  64.     "$perldir;" . join (';', grep(!/perl/i, split(/;/, $pathstring))) . ";";
  65.  
  66. &RegSetValueEx($key, "Path", 0, $type, $newstring) ||
  67.     die "Can't set Session Manager Path: $!\n";
  68. &RegCloseKey($key);
  69. print "Updated default path to include $perldir\n";
  70. print "Perl installation finished!\n";
  71.  
  72. __END__
  73. :endofperl
  74.