How to Debug Remote Command

103 views Asked by At

I need to execute this command on our remote Skype server:

SEFAUtil.exe /server:lyncserver.domain1.co.uk sip:[email protected] /addteammember:sip:[email protected] /delayringteam:10

which adds a colleague to my team call group.

I am able to run the command on the server itself, and the code below works when sending other commands to that server:

var processToRun = new[] { process };
var connection = new ConnectionOptions();
var wmiScope = new ManagementScope(String.Format("\\\\{0}\\root\\cimv2", LyncServer), connection);
var wmiProcess = new ManagementClass(wmiScope, new ManagementPath("Win32_Process"), new ObjectGetOptions());
var reason = wmiProcess.InvokeMethod("Create", processToRun);

However, when process is the string:

"cmd /c cd /d C:\\Program Files\\Microsoft Lync Server 2013\\ResKit && SEFAUtil.exe /server:lyncserver.domain1.co.uk sip:[email protected] /addteammember:sip:[email protected] /delayringteam:10"

Then the user is not added to the team call group.


I can see that reason contains the uint 0, which usually indicates success - but the actual command is clearly failing.

I also tried adding > C:\users\user.name\desktop\output.txt and 2> C:\users\user.name\desktop\output.txt to the end of the command, but they just created empty text files, so not very useful!

Update

I tried changing the command to the following:

const string LyncServer = "server.domain1.co.uk";
const string ResKitPath = @"C:\Program Files\Microsoft Lync Server 2013\ResKit";

var command = "SEFAUtil.exe /server:{LyncServer} sip:[email protected] /addteammember:sip:[email protected] /delayringteam:10"; 
var process = $"cmd /c cd /d \"{ResKitPath}\" && {command}";

So that the path containing spaces is double-quoted and the slashes are not being escaped, but with the same results.

Does anyone know of another way of debugging this or retrieving the output for the newly created process?

1

There are 1 answers

0
Jeremy Suttie On

I've had a similar issue, mine was that the command shell needed to run elevated. SEFA is a bit naff at giving good error messages, and fails silently.