#  ConfigService.pl
#  Example 8.5:
#  ----------------------------------------
#  From "Win32 Perl Scripting: Administrators Handbook" by Dave Roth
#  Published by New Riders Publishing.
#  ISBN # 1-57870-215-1
#
#  This script reconfigures a Win32 service.
#  You need to modify the %ServiceConfig hash to reflect an
#  existing service otherwise it will result in errors.
#
print "From the book 'Win32 Perl Scripting: The Administrator's Handbook' by Dave Roth\n\n";


use Win32::Daemon;
%ServiceConfig = (
    name    =>  'w3svc',
    user    =>  'MyDomain\Foo',
    pwd     =>  'bar',
    machine =>  "\\\\" . Win32::NodeName(),
);
if( Win32::Daemon::ConfigureService( \%ServiceConfig ) )
{
    print "The '$ServiceConfig{name}' service was successfully re-configured.\n";
}
else
{
    print "Failed to configure the '$ServiceConfig{name}' service.\n";
    print "Error: ";
    print Win32::FormatMessage( Win32::Daemon::GetLastError() ), "\n";
}

