473,503 Members | 3,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

run program with different username in c#

4 New Member
hey,
i'm trying to run programs from within c# code, with different username (runAs).
if i'm running it directly, like this:
Expand|Select|Wrap|Line Numbers
  1. Process.Start("c:",username,password,domain);
i'm getting "access denied" error.
i managed to bypass it by:
Expand|Select|Wrap|Line Numbers
  1. Proccess pr = new Proccess();
  2. pr.UserName=username;
  3. pr.Password=password;
  4. pr.Domain=domain;
  5. pr.FileName="cmd";
  6. pr.Arguments="start /c c:";
  7. pr.UseShellExecute=false;
  8.  
  9. - or -
  10.  
  11. pr.FileName="c:\progra~1\intern~1\iexplore";
  12. pr.Arguments="http:\\..";
  13.  
the first used for files, the second for links.
the problem is opening directory located in other computer (with iexplorer), opening as shared folder and changes i make there won't appear until i refresh the page.
the first one, with cmd, also causing some problems in some scenarios.

can someone help me resolve the problem so i can open everything the ordinary way?
Aug 1 '07 #1
7 5392
Plater
7,872 Recognized Expert Expert
Running the command:
"explorer c:\"
Will open up the c:\ folder.

Running the command:
"explorer \\someComputerName"
Will open up the shares list of \\someComputerName.


Is your problem that your user does not have the priviledges to run these?
I didn't really see what the problem you had was.
Aug 1 '07 #2
blacktulip
4 New Member
running the command
explorer c:\
throw error "the system can't find the file specified".

running the command
explorer
with the arguments
c:\
does nothing.
Aug 1 '07 #3
Plater
7,872 Recognized Expert Expert
wierd, maybe you have to give the exact location of explorer.exe
Aug 1 '07 #4
blacktulip
4 New Member
no, i tried that either.
if i write
Expand|Select|Wrap|Line Numbers
  1. Process.Start(filename)
it works, if i write "explorer c:" or just "c:".
but if i try to use username
Expand|Select|Wrap|Line Numbers
  1. Process.Start("explorer c:",username,password)
it's not working. i can't pass arguments as part of the file, and even if i pass them in the arguments part, explorer does nothing.
Aug 1 '07 #5
Plater
7,872 Recognized Expert Expert
Well maybe I am not understanding what you are trying to do.

You just want your program to open up a file folder browser window right?
(Like if you went to Start->Run: "c:\")

It you have shellexecute=false, to open up windows you need to use "explorer.exe" as filename and the path (ie "c:\") as the arguments

I believe though that if you have shellexecute=true, then you can just set filename="C:\" and have no arguments.


If you are trying to start the process under a different user, I think you need to use the ProcessStartInfo object.
Aug 1 '07 #6
blacktulip
4 New Member
i used it "Process.StartInfo".
but if i try to run "explorer.exe" as filename (with the full path) and "c:" as arguments, it doesn't open anything.
Aug 2 '07 #7
Plater
7,872 Recognized Expert Expert
i used it "Process.StartInfo".
but if i try to run "explorer.exe" as filename (with the full path) and "c:" as arguments, it doesn't open anything.
Really? it opens up the folder for me
Aug 2 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
14143
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
3
3507
by: tjland | last post by:
This is my first version of this program, im kinda new to python and i was wondering if someone could help me with this. Their are some errors that i just cant find, and i want some advice on how...
6
7109
by: dwelch91 | last post by:
Greetings- This is on Linux... I have a daemon running as root and I want to execute another Python program as another user (a regular user). I have the name of the user and can use the 'pwd' and...
2
3512
by: queanbeyan | last post by:
Hi I have found that many of my potential users of my application are not able to write to their program files directory on C:\program files, however they have access to 'My documents'. i...
43
3381
by: davidkoree | last post by:
I mean not about cookie. Does it have something to do with operating system or browser plugin? I appreciate any help.
6
1487
by: =?iso-8859-1?q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
Usually someone writes a program and guarantees its behaviour so long as people don't deliberately go and try to make it malfunction. For instance, let's say we have a "Proceed" button on the...
9
2901
by: Keith G Hicks | last post by:
I'm having a lot of trouble with "file in use" errors in my "folder watcher" project. Starting and stopping the watcher and reading my XML file work fine. Once the watcher is started, I'm reading...
10
4941
by: Jason | last post by:
I want to create a simple program with Two buttons on the form. BUTTON 1 - BACKUP PREFS this will do the following: Copy C:\Documents and Settings\%USERNAME%\Application Data\FileZilla...
0
13288
amitpatel66
by: amitpatel66 | last post by:
There is always a requirement that in Oracle Applications, the Concurrent Program need to be execute programatically based on certain conditions/validations: Concurrent programs can be executed...
0
7192
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7315
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7445
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5559
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1492
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
369
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.