Solved runas in vb.net

coremd

New Member
Messages
2
In VB.net I wrote an installation program that periodically needs updating.
The first installation must be done by an administrator in order to create program files folders and register DLL's etc..
But I need to make updates to the program every once in a while requiring the user to simply copy a file located on a mapped network drive to a location in program files.
Normal Users cannot make this simple copy so I want to be able to supply a domain administrator's username and password (from an encrypted database) to just make the copy.

I have tried the following two programs without success
copyrunas.exe is a program I wrote in VB.net that performs a simple system.io.file.copy(from mapped location, to program files location)

1)
Dim startInfo As New ProcessStartInfo()
startInfo.FileName = "copyrunas.exe"
startInfo.Arguments = ""
startInfo.WorkingDirectory = "c:\temp"
Dim PW As String = "domain admin password"
Dim securePassword As New Security.SecureString()
For Each c As Char In PW
securePassword.AppendChar(c)
Next c
startInfo.UserName = "DOMAIN ADMIN USERNAME"
startInfo.Password = securePassword
startInfo.Verb = "RUNAS"
Dim USERX As String = System.Security.Principal.WindowsIdentity.GetCurrent.Name
startInfo.Domain = USERX.Substring(0, USERX.IndexOf(""))
startInfo.UseShellExecute = False
startInfo.CreateNoWindow = True
Dim PPP As Process = System.Diagnostics.Process.Start(startInfo)
PPP.WaitForExit()

2)
proc.FileName = "runas"
proc.Arguments = "/env /user:DOMAIN\ADMIN USER NAME c:\temp\COPYRUNAS.EXE"
proc.WorkingDirectory = "C:\TEMP"
Process.Start(proc)

Can someone help?
 

My Computer

System One

  • OS
    windows 7
    Computer type
    PC/Desktop
    System Manufacturer/Model
    self made

My Computer

System One

  • OS
    PC-DOS v1.0
    Computer type
    PC/Desktop
    System Manufacturer/Model
    IBM
    CPU
    Intel 8088, 4.77MHz
    Memory
    16K, 640K max
    Graphics Card(s)
    What's that?
    Sound Card
    Not quite
    Screen Resolution
    80 X 24 text
    Hard Drives
    dual 160KB 5.25-inch disk drives
Fantastic!

Just a note
I could get access to the mapped drive and was unable to re-map the drive in impersonate mode so before I impersonated the administrator I copied the file from the mapped share to a local folder then used the impersonate mode to copy from the local file into the program files folder I needed.

Thanks
 

My Computer

System One

  • OS
    windows 7
    Computer type
    PC/Desktop
    System Manufacturer/Model
    self made
Back
Top