How do you open a document as another user?
The document type is unkown (could be pdf, .xls, .doc, images etc).
Document is on a network share, username, domain and password are all known.
I have thoroughly researched this question and I do not beleive the question has been answered here. Please prove me wrong.
This question gets close
Open a shared file under another user and domain?
But unfortunately it opens the file to a filestream, I need to open the file in its associated application.
Check out Runas
It is located at
C:\Windows\System32\runas.exeTo open this from a C# application, you could use
Process.Start, with the appropriate flags.Edit
Well, you can skip the use of
Runasentirely, sinceProcess.Startcan do the same job, and still allow you to specify the password however you like (hard-coded internally, or via the UI).Simply use
cmd.exe /c start <pathToFile>to launch the file via the shell with the associated program: