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)
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
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)
proc.FileName = "runas"
proc.Arguments = "/env /userOMAIN\ADMIN USER NAME c:\temp\COPYRUNAS.EXE"
proc.WorkingDirectory = "C:\TEMP"
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.