c#


How can I start a new process with same credentials as the process I am running?


My machine is logged on as User A and running a scheduled task as User B. The scheduled task is a monitor that starts other processes as required.
User B has more privileges than user A.
When the monitor process starts another process, that second process appears to be running as User A. How do I start it as User B.
(I do not want to code the password for user B anywhere, but to 'pick it up' from the environment of the main monitor process.
My code for starting the processes:
public void StartProcess()
{
try
{
if (!string.IsNullOrEmpty(StartCommand))
{
ProcessStartInfo psi = new ProcessStartInfo(StartCommand)
{
WorkingDirectory = StartWorkingDirectory,
Arguments = StartArguments
};
SimpleLog.Log("Starting {0}\\{1} {2}", StartWorkingDirectory, StartCommand, StartArguments);
System.Diagnostics.Process prc = new System.Diagnostics.Process();
prc.StartInfo = psi;
bool start = prc.Start();
IsAlerted = false;
RestartAppearsToHaveFailed = !start;
RestartFailReason = string.Empty;
}
}
catch (Exception e)
{
RestartAppearsToHaveFailed = true;
RestartFailReason = e.Message;
SimpleLog.Log("ERROR: Can't start {0} with {1}: {2}",
Name, StartCommand, e);
}
}

Related Links

How can I generate LINQ queries automatically from IQueryable<T> and LINQ POCO classes?
Ajax / LinqtoSql / multiple insert conflict primary key
tinyint in SQL Server to byte in C#
How can I bind a datatemplate to a observablecollection so that they all show up?
C# click on control
Sharing memory between managed and unmanaged code with P/Invoke
How to download and store an image using Windows.Web.Http?
Namespace path in WPF XAML
Angle Normalization C#
Can't pass value from textbox to controller using textboxfor
Awaiting a task is taking forever or not working at all
how to check a remote port is open
How to produce JWT with Google OAuth2 compatible algorithm RSA SHA-256 using System.IdentityModel.Tokens.Jwt?
Transform LINQ to normal Foreach
Reading the last child item in a hierarchy using Linq
How to change resources dynamically

Categories

HOME
marie
itunesconnect
leaflet
network-programming
snappy
ms-application-insights
artifactory
swap
multipartform-data
rmarkdown
wavefront
osx-yosemite
minimax
guidewire
jetbrains
pylint
jquery-easyui
xforms
hl7-fhir
rndis
mattermost
opengraph
quality-center
scrapy-spider
libxml2
large-files
pypy
r-factor
schedule
overflow
opencsv
kubectl
openvms
asp.net-webhooks
ragel
campaign-monitor
redhat-brms
jibx
area
nscollectionview
compiled-query
uitextview
superclass
intervention
smooth-streaming
cakephp-3.2
gridgain
html-entities
taleo
spring-webflow-2
ear
wink
fluent-nhibernate-mapping
richtext
senti-wordnet
try-catch-finally
pyautogui
fileopendialog
scikit-image
class-design
networkstream
altova
hotkeys
calc
code-translation
methodology
newlib
biginsights
windows-phone-8-emulator
syncano
tokudb
pdcurses
stereotype
cakephp-2.6
grails-3.0.9
connection-timeout
conkeror
xmla
backtrace
optimistic-locking
static-files
frisby.js
powerpoint-2010
worklight-appcenter
rpt
dateadd
sendy
mdp
vbaccelerator
php-amqplib
scidb
grape-api
octokit
nokogiri
mosix
nsautoreleasepool
tasklist
doxia
erlide
jmesa
yii-cactiverecord
rollover
nstoolbar
google-local-search
datadude
data-formats
djangoappengine
moores-law
urlscan

Resources

Encrypt Message