#
# Perl script to update the NT registry with defaults for Perl
#

die "usage: perl regupdat <perl installation path>\n" 
    if (@ARGV != 1);

$installdir = shift;

#
# note: if you change this, change it in the perl source so perl knows
#       where to look!
#
$basekey = "SOFTWARE\\Intergraph\\Perl\\4.036";

print "Starting Registry update for installation directory $installdir\n";

#
# open a key for installing perl
#

&RegCreateKey($HKEY_LOCAL_MACHINE, 
	      $basekey, $key) ||
    do {
	print "cant open registry: $!\n";
	sleep (10);
	die "Can't HKEY_LOCAL_MACHINE\\SOFTWARE\\Intergraph\\Perl\\4.036: $!";
    };

&RegSetValueEx ($key, "PathName", 0, $REG_SZ, "$installdir\\bin\\perl.exe");
&RegSetValueEx ($key, "SoftwareType", 0, $REG_DWORD, 1);
&RegCloseKey ($key);

&RegCreateKey($HKEY_LOCAL_MACHINE, 
	      "$basekey\\Parameters", $key) ||
    do {
	print "can't update parameters: $!\n";
	sleep(10);
	die "Can't HKEY_LOCAL_MACHINE\\$basekey\\Parameters: $!";
    };

&RegSetValueEx ($key, "BIN", 0, $REG_SZ, "$installdir\\bin");
&RegSetValueEx ($key, "PRIVLIB", 0, $REG_SZ, "$installdir\\lib");
&RegCloseKey ($key);

&RegCreateKey($HKEY_LOCAL_MACHINE, 
	      "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",
	      $key) ||
    do {
	print "can't get environment key: $!\n";
	sleep(10);
	die "Can't get environment value: $!\n";
    };

&RegQueryValueEx ($key, "Path", 0, $type, $path) 
    || die "can't get path value:$!\n";

&RegSetValueEx ($key, "Path", 0, $type, "$installdir;$path")
    || die "can't set path to $idir;$path:$!\n";

&RegCloseKey($key);


print "Finished with registry update\n";
sleep (2);

