Win32::Symboliclink - Perl extension to create a symbolic link.
use Win32::Symboliclink;;
#Create SymbolicLink my $lastCreateErrorRet = CreateSymLink("C:\\SYSWOW64","C:\\Windows\\System32"); print "Returncode: $lastCreateErrorRet \n" ; my $lastCreateErroMsg = GetSyLinkError() ; print "Message: $lastCreateErroMsg\n" ;
#Remove SymbolicLink my $lastRemoveErrorRet = RemoveSymLink("C:\\SYSWOW64") ; print "Returncode: $lastRemoveErrorRet \n" ; my $lastRemoveErrorMsg = GetSyLinkError() ; print "Message: $lastRemoveErrorMsg\n" ;
With this module you can create a symbolic link <SYMLINKD> (not <JUNCTION>) under Windows Vista and higher. This module requires Windows Vista or higher.
Link The symbolic link to be created.
Destination is the name of the target for the symbolic link to be created. It can either be a file or a folder.
Create a symbolic link. If the function succeeds, the return value is zero. If the function fails, the return value is nonzero (GetLastError). To get extended error information call GetSyLinkError()
.
=head3 RemoveSymLink ( Link )
Link The symbolic link to be deleted.
Remove a symbolic link. Alternativ you can use unlink or rmdir. If the function succeeds, the return value is zero. If the function fails, the return value is nonzero (GetLastError). To get extended error information call GetSyLinkError()
. Deleting a symbolic link does not affect the source file.
NOTE: A link can also be removed with rmdir or unlink.
This function returns the last error message (string). The last error code is return by the functions thereselves.
Alternative you can use Win32::API of course.
Win32::API - http://search.cpan.org/~cosimo/Win32-API-0.59/API.pm
my $lpSymlinkFileName = "C:\\Windows\\SysWOW32";
my $lpTargetFileName = "C:\\Windows\\System32";
my $dwFlags = "";
my $CreateSymbolicLink = new Win32::API('kernel32', "CreateSymbolicLink",['P','P','N'],'I'); $CreateSymbolicLink->Call($lpSymlinkFileName,$lpTargetFileName,$dwFlags) or die "Could not create Symboliclink: $^E"
NOTE: A link can be removed with rmdir or unlink.
Win32::SymLink
Win32::Hardlink
Henrik P., <hendriks@cpan.org>
Copyright (C) 2010 by Henrik P.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.