@rem = '--*-Perl-*--';
@rem = '
@echo off
perl %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofperl
@rem ';

require 'NT.ph';
#(c) 1995 Microsoft Corporation. All rights reserved. 
#        Developed by hip communications inc., http://info.hip.com/info/

print <<'--end--';
UNINSTALL.BAT:
  This script will remove the registry entries created by the 
  install.bat script.  You can re-install by running install.bat 
  again. 
Continue?(Y/N):
--end--

$in = <STDIN>;
until ( $in eq "\n" || $in =~ /^y/i ) {
	exit if ( $in =~ /^no?\n$/i );
	print "Do you wish to proceed? [Y/n]";
	$in = <STDIN>;
}

#check the registry entries

    NTRegOpenKeyEx ( &HKEY_LOCAL_MACHINE,
	'SOFTWARE\Microsoft\Resource Kit\PERL5',
	&NULL, &KEY_ALL_ACCESS, $PerlKey ) ?
	print "Retrieving Perl dir information from Registry\n":
	warn "Couldn't retrieve Perl dir information from Registry!!\n";

    NTRegQueryValueEx( $PerlKey, 'BIN', &NULL, $type, $bindir );
  
    NTRegDeleteValue( $PerlKey,'BIN')?
	print" deleting BIN value from registry\n":
	warn" cannot delete BIN value from registry!!!\n";

  NTRegDeleteValue( $PerlKey,'PRIVLIB')?
	print" deleting PRIVLIB value from registry\n":
	warn" cannot delete PRIVLIB value from registry!!!\n";

  NTRegDeleteValue( $PerlKey,'HTML-DOCS')?
	print" deleting HTML-DOCS value from registry\n":
	warn" cannot delete HTML-DOCS value from registry!!!\n";

  NTRegDeleteKey( &HKEY_LOCAL_MACHINE,
	'SOFTWARE\Microsoft\Resource Kit\PERL5' )?
	print"Removing Perl from Registry\n":
	warn" Cannon remove Perl from Registry!!!\n";

  NTRegCloseKey( $PerlKey );

#remove the bin directory from the path.

if( Win32::IsWinNT()){
    NTRegOpenKeyEx ( &HKEY_LOCAL_MACHINE,
	'SYSTEM\CurrentcontrolSet\control\Session Manager\Environment',
	&NULL, &KEY_ALL_ACCESS, $hkey ) ?
	print "Retrieving Path information from session manager\n":
	warn "Couldn't retrieve path information from session manager!!\n";

    NTRegQueryValueEx( $hkey, 'Path', &NULL, $type, $pathstring );

    $pathstring =~ s/$bindir;//g;

    NTRegSetValueEx( $hkey, 'Path', &NULL, $type, $pathstring ) ?
	print "Updated path information in session manager\n":
	warn"Couldn't update path information in session manager!!\n";

    NTRegCloseKey( $hkey );
}


   print "NOTE: The changes to the path will not take effect\n";
   print "      until you log off and on again.\n";


__END__
:endofperl
