Title: checking for the existence of a win2k service

Hello
I am trying to determine if a service on a win2k server machine exists, and if it doesn't exist create the service in question.  I thought I could use something like:

Win32::Lanman::QueryServiceStatus("\\\\$hostname", '', "Myservice", \%status);
print "test";
if (%status){
        print "\nGood, Myservice already installed.\n";
}else{
        Win32::Lanman::CreateService("\\\\$hostname", ' ', { name => 'MyService',
                                                                 display => 'Myservice',
                                                                 type => &SERVICE_WIN32_OWN_PROCESS,
                                                                 start => &SERVICE_AUTO_START,
                                                                 control => &SERVICE_ERROR_IGNORE,
                                                                 filename => "C:\\WINNT\\myservice.exe",
                                                                 account => 'LocalSystem',});
}

In this case "myservice" doesn't exist and the script hangs right after print "test".  
Thanks
Eric

_________________
Eric Logeson
919-680-5679
www.dukece.com


Reply via email to