Click here to Skip to main content
15,887,262 members
Home / Discussions / C#
   

C#

 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer012-May-13 17:39
SledgeHammer012-May-13 17:39 
GeneralRe: Can't run SC remotely to config service Pin
Dave Kreskowiak3-May-13 1:21
mveDave Kreskowiak3-May-13 1:21 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 4:08
SledgeHammer013-May-13 4:08 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 7:21
SledgeHammer013-May-13 7:21 
GeneralRe: Can't run SC remotely to config service Pin
Dave Kreskowiak3-May-13 7:52
mveDave Kreskowiak3-May-13 7:52 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 8:04
SledgeHammer013-May-13 8:04 
GeneralRe: Can't run SC remotely to config service Pin
Dave Kreskowiak3-May-13 8:26
mveDave Kreskowiak3-May-13 8:26 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 9:40
SledgeHammer013-May-13 9:40 
Dave Kreskowiak wrote:
The impersonation code that you're using does NOT affect the process you launch
with Start. The only thing that changes that is using the Start overload that
accepts a username and password.
 
I'm not the "Smarty Pants" here.
The CMD prompt is telling you exactly what you need to know and you're ignoring
it! That little window is telling you that using the Impersonator class has no
effect on which account another process is launched as.


Ok, that makes sense. I guess the methods that ARE working under impersonation are File.Copy() and ServiceController which will run under impersonation.

Kind of weird though, I'm launching PSKILL using Process.Start() and that is working, but I'm using both the impersonation and the built in username & password thing... seems like that one required both... if I just had one or the other, it wouldn't work.

Regardless of all that, obviously, yeah, I gotta get Start() working with the username & password... this is my code for that:

System.Security.SecureString ss = new System.Security.SecureString();

foreach (char ch in _strPassword)
ss.AppendChar(ch);

System.Diagnostics.ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo("cmd.exe");

si.UseShellExecute = false;
si.RedirectStandardInput = true;
si.RedirectStandardError = true;
si.RedirectStandardOutput = true;
si.UserName = _strUsername;
si.Password = ss;
si.Domain = "xxx"; // obviously censored for the forums Smile | :)
si.Arguments = "/K";

System.Diagnostics.Process.Start(si);

This gets a:

An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
Additional information: Access is denied
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 11:10
SledgeHammer013-May-13 11:10 
AnswerRe: Can't run SC remotely to config service Pin
Richard MacCutchan2-May-13 21:37
mveRichard MacCutchan2-May-13 21:37 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 4:02
SledgeHammer013-May-13 4:02 
GeneralRe: Can't run SC remotely to config service Pin
Richard MacCutchan3-May-13 4:22
mveRichard MacCutchan3-May-13 4:22 
AnswerRe: Can't run SC remotely to config service Pin
Alan N2-May-13 22:50
Alan N2-May-13 22:50 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 4:08
SledgeHammer013-May-13 4:08 
GeneralRe: Can't run SC remotely to config service Pin
Alan N22-May-13 4:33
Alan N22-May-13 4:33 
QuestionRestoring Initial UI State Pin
Matt U.2-May-13 2:53
Matt U.2-May-13 2:53 
AnswerRe: Restoring Initial UI State Pin
Alan Balkany2-May-13 5:19
Alan Balkany2-May-13 5:19 
GeneralRe: Restoring Initial UI State Pin
Matt U.2-May-13 5:39
Matt U.2-May-13 5:39 
GeneralRe: Restoring Initial UI State Pin
Jasmine25012-May-13 7:10
Jasmine25012-May-13 7:10 
GeneralRe: Restoring Initial UI State Pin
Matt U.2-May-13 7:15
Matt U.2-May-13 7:15 
GeneralRe: Restoring Initial UI State Pin
Dave Kreskowiak2-May-13 11:06
mveDave Kreskowiak2-May-13 11:06 
GeneralRe: Restoring Initial UI State Pin
Jasmine25012-May-13 12:36
Jasmine25012-May-13 12:36 
GeneralRe: Restoring Initial UI State Pin
Dave Kreskowiak2-May-13 15:35
mveDave Kreskowiak2-May-13 15:35 
GeneralRe: Restoring Initial UI State Pin
Jasmine25013-May-13 5:08
Jasmine25013-May-13 5:08 
GeneralRe: Restoring Initial UI State Pin
Eddy Vluggen2-May-13 12:21
professionalEddy Vluggen2-May-13 12:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.