I have a piece of C# code which I am using to remotely register a *.tlb file in C#. I am deploying it using PsExec (Powershell) with the following command:
.\PsExec.exe \\* -u "username" -p "password" -h -c "MyExe.exe"
It works fine on x86 machines, but falls over on x64 machines with the following error: -2146232576
.
If I run the *.exe locally on the 64 bit machine, it works fine. The code is below:
static void Main(string[] args)
{
try
{
Directory.CreateDirectory(@"C:\Directory");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
try
{
File.Copy(@"\\x.x.x.x\MyDll.dll", @"C:\Directory\MyDll.dll");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
try
{
var p = new Process
{
StartInfo =
{
FileName = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe",
Arguments = @"C:\Directory\MyDll.dll",
UseShellExecute = false
}
};
var q = new Process
{
StartInfo =
{
FileName = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe",
Arguments = @"C:\Directory\MyDll.dll /tlb",
UseShellExecute = false
}
};
var r = new Process
{
StartInfo =
{
FileName = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe",
Arguments = @"C:\Directory\MyDll.dll /codebase",
UseShellExecute = false
}
};
p.Start();
q.Start();
r.Start();
}
catch(Exception z)
{
Console.WriteLine(z.Message);
}
}
Console.WriteLine("Done and Done");
}
}
The error you are getting is 1792 = ERROR_NETLOGON_NOT_STARTED = "An attempt was made to logon, but the network logon service was not started."
This article by Mark Russinovich talks about the security aspects of PsExec.
try running this with -i option.