use Cwd; use File::Basename; my $scriptPath = File::Basename::dirname($0); chdir($scriptPath) if $scriptPath; $scriptPath = Cwd::getcwd(); my $script = File::Basename::basename($0); my %serviceConfig = ( name => 'mytest', display => 'mytest', description => 'this is my test description', machine => '', path => $^X, parameters => qq{"$scriptPath/$script" --run}, start_type => SERVICE_AUTO_START, );