Solved

Is it possible to change process owner? "System.Diagnostics.Process"

Posted on 2009-04-15
2
683 Views
Last Modified: 2013-12-17
Hi,

I have a .net exe that is launched by a very limited user.
the user does this by clicking a batch file that uses runas to run the exe using the Admin account on the box.
so the exe is running as the Admin.

However i then call another bat file using System.Diagnostics.Process from within code that basically consists of an Xcopy from a server share.
Because the exe is running as the Admin the batch files fails because you have to be a member of a group to access the share.
the logged on user is a member and can access the share but not via the exe, presumebaly because the exe is running under Admin account.
is it possible to run the xcopy batch file under the logged on user account?

cheers

0
Comment
Question by:caoimhincryan
  • 2
2 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
ID: 24147261
Runas.exe doesn't let you specify the password on the command line.  
In .NET 2.0, Process.Start() does have an overload that allows specifying the user and password.

System.Diagnostics.Process, RunAs and hidden windows
http://tourist.spaces.live.com/blog/cns!851D2B32CC1B64B4!573.entry?sa=460302768
0
 
LVL 53

Assisted Solution

by:Dhaest
Dhaest earned 500 total points
ID: 24147273
Process..::.Start Method (String, String, SecureString, String)
http://msdn.microsoft.com/en-us/library/sxf2saat.aspx
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question