473,652 Members | 3,173 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 5419
Plater
7,872 Recognized Expert Expert
Running the command:
"explorer c:\"
Will open up the c:\ folder.

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


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=fa lse, to open up windows you need to use "explorer.e xe" as filename and the path (ie "c:\") as the arguments

I believe though that if you have shellexecute=tr ue, 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 ProcessStartInf o object.
Aug 1 '07 #6
blacktulip
4 New Member
i used it "Process.StartI nfo".
but if i try to run "explorer.e xe" 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.StartI nfo".
but if i try to run "explorer.e xe" 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
14159
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 Smarty-2.6.7.tar.gz on a system running WindowsXP SP2. Apache and PHP tested out fine. After adding Smarty, I ran the following http://localhost/testphp.php
3
3512
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 to do some of these things easier. Thanx for the help! ---------------------------------------------------------------------------- from time import sleep def Sendfile(password, username): outfile = file(username, "w") outfile.write(password)
6
7118
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 'grp' modules to get that user's user and group ids. What I don't understand is how to then go about launching that new program. I had considered having the launched program switch itself back to the target user (somehow), but the launched...
2
3524
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 have mapped some code to 'c:\documents and settings\%username%\documents' but I dont know how to map the default deployment application folder to that directory. The current default is \ which maps to 'c:\program files\hilda
43
3412
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
1502
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 dialog box, but that this button is greyed out because the user hasn't entered their username yet. Now let's say the user writes some code that sends a message to the dialog box to enable the "Proceed" button even tho the programmer didn't design...
9
2911
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 the text files from the watched folder line by line into variables and then posting them to a SQL table. All of the code for the form is shown below. And it works fine except for 2 issues. First issue: In the Finally of the Try for teh SQL...
10
4953
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 \sitemanager.xml to this location: \\drake\pvt\%USERNAME%\FileZilla-Prefs\ BUTTON 2 - RESTORE PREFS this will do the opposite:
0
13326
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 programatically either from UNIX or Oracle PLSQL. In this Section, I will be explaining about calling a Concurrent program from UNIX using the CONCSUB Command. Pre-requisite: 1. Concurrent Program should be registered in oracle Applications...
0
8367
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8279
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8467
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4145
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2703
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 we have to send another system
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.