Hi Viorel-1,
Just to introduce some context, the script I execute from server is (in perl):
eval { $process =
Win32::OLE->GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\" . $serviceAddress . "\\root\\cimv2:Win32_Process"); };
if(defined $process)
{
$objMethod = $process->Methods_("Create");
my $cmdLine = 'cmd /c cd %TEMP% && copy nul _foo.txt && \\\\MySharedFolder\\MyBinary.exe';
Spawn an instance of inParameters and assign the values.
$inParam = $objMethod->inParameters->SpawnInstance_ if (defined $objMethod);
$inParam->{CommandLine} = $cmdLine;
$inParam->{ProcessStartupInformation} = undef;
$outParam = $process->ExecMethod_("Create", $inParam) if (defined $inParam);
if ($outParam->{ReturnValue})
{
print Win32::OLE->LastError, "\n";
}
}
else
{
print Win32::OLE->LastError, "\n";
}
The ExecMethod_ call works fine (since it does not show any error code in standard output). I have added copy command so I have a sided effect visible in the remote machine, and I actually can see that file created there (_foo.txt). Now, if MyBinary.exe lives in any local folder of the remote machine, the binary gets called properly, but if it lives in any shared folder it doesnt.
I have given plenty of permissions to the remote machine for the shared folder and some other persmissions in the context of wmi (basically followed this https://helpdesk.kaseya.com/hc/en-gb/articles/4407333863825-Allowing-Remote-WMI-Access-in-a-WORKGROUP).
I have tried to print in a local file (of the remote machine) the %errorlevel% right after trying to execute MBinary.exe but it does print nothing, it's like it gets aborted. Do you have any suggestion on how to get more info about what may went wrong?
Kind regards,
Jaume