Solved

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

Posted on 2009-04-15
2
675 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
Comment Utility
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
Comment Utility
Process..::.Start Method (String, String, SecureString, String)
http://msdn.microsoft.com/en-us/library/sxf2saat.aspx
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now