0

The following code works in my development computer and I am able to see that the service is registered using netsh show urlacl.

ProcessStartInfo netshPSI = new ProcessStartInfo();
                    // Windows XP SP3, Vista SP2, 7 SP1 or 8                    
                    netshPSI.FileName = "netsh.exe";
                    netshPSI.Arguments = "http add urlacl url=http://+:8731/Service1 user=Everyone";
                    netshPSI.CreateNoWindow = true;
                    Process.Start(netshPSI);

However in a target computer it executes without raising an exception and does not register. What am I missing here?

Should I wait for the process to complete?

Both computers are logged in as administrators and the code is executed with elevated rights.

Ranjith Venkatesh
  • 1,322
  • 3
  • 20
  • 57
  • Have you tried to run **netsh**, with it's arguments, directly in a command promt on the target computer ? Far as I remember `Process` has rather limited capabilities when it comes to capturing errors. – Simon Rapilly Aug 16 '13 at 10:26

1 Answers1

0

The problem was the target computer was German and Everyone is "Jeder". I had to dynamically find the name for Everyone before using it with the below code:

var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
var account = (NTAccount) sid.Translate(typeof(NTAccount)); 
string everyoneName = account.ToString();
Ranjith Venkatesh
  • 1,322
  • 3
  • 20
  • 57