473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How To Handle RUNAS Password Using The Process Object

I'm trying to use the Process object to have RUNAS run DOS commands. I have
no problem getting the Process object to run DOS commands and return the
resulting text back to the program. However, if I'm using RUNAS (e.g. in
order to move files to a protected network share), I run into the problem
that RUNAS requires a two-step process to get it started.

If you're calling RUNAS from the command prompt, after entering the command
line text and hitting ENTER, you're then asked for the password. RUNAS's
command line does now allow you to include the password, so it's a two-step
process.

I've been trying to work with objMyProcess.RedirectStandardInput and
objMyProcess.StandardInput to feed it the password, but nothing seems to be
working.

The following is my code. The MsgBox line returns "Enter password for
MyDomain\MyUsername:RUNAS ERROR: Unable to change echo mode"
Dim p As New Process()
Dim psi As New ProcessStartInfo("C:\WINNT\system32\runas.exe", _
"/profile /user:MyDomain\MyUsername " & """" & "c:\winnt\system32\xcopy.exe
/V /Y C:\MyFile.txt \\MyServer\MyShare\SomeFolder" & """")

psi.UseShellExecute = False
psi.RedirectStandardInput = True
psi.RedirectStandardOutput = True
psi.RedirectStandardError = True
psi.CreateNoWindow = True
p.StartInfo = psi
p.Start()
p.StandardInput.AutoFlush = True
p.StandardInput.WriteLine("MyPassword")
MsgBox(p.StandardOutput.ReadToEnd)
p.StandardInput.Flush()
p.StandardInput.Close()
p.StandardOutput.Close()
p.Close()
p = Nothing

Nov 20 '05 #1
0 4183

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Neil Ginsberg | last post by:
I have ODBC linked tables to a SQL 7 database in an A2K database. The linked tables do not have the password stored in them, so the first time the user accesses them, they need to enter the SQL...
5
by: scorpion53061 | last post by:
I would like your thoughts and impressions of the events of today and ask how you would handle this or if I am wrong and this is "normal" behaviour for a web provider and IIS. I am normally a...
3
by: Jarod_24 | last post by:
Dim p As Diagnostics.Process Debug.WriteLine(p.Id) Debug.WriteLine(p.Handle) What is the difference between a process's ID and Handle I see that they are different, and i know that the...
1
by: MS MVP ??? for VB.NET | last post by:
Dear all, I am trying to get the Process UserName by using System.Enviorment.Username, I have no problem by normal "run" and by "runas". I can get the process Username with correct value....
3
by: Mr. Novice | last post by:
Hello, I work for a company where the server administrators have two login ID's. One without admin right that we use to log into our workstations and one with admin rights that we use to for...
4
by: Katit | last post by:
Here is what I need to accomplish: 1. Start new process using Process.Start 2. Get it's handle and save to text file. On next execution I read text file and see if process with same...
2
weaknessforcats
by: weaknessforcats | last post by:
Handle Classes Handle classes, also called Envelope or Cheshire Cat classes, are part of the Bridge design pattern. The objective of the Bridge pattern is to separate the abstraction from the...
14
by: masaniparesh | last post by:
Hi Friends, The basic issue is "To read stdin and stdout in the same program" The following program is i have wrote using thread but i figured out that stdout is working but it is not working when...
5
by: =?Utf-8?B?R3JhbnQ=?= | last post by:
Hi, In a WinForms application, how can you get the identity of the remote credentials used when kicking off the application with RunAs /NetOnly? I can get local Identity information with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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
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...

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.