Ajax
ASP
C,C++
C#,.NET
CSS,HTML
Delphi,Kylix
Experience
Flash
Java
JavaScript
PHP
Python
QT
SQL
ShellScript
VB
U :
P :
Register
Lost Password
Other Links
Code Archive
Save Giovanni
C#,.NET Category Code
Real Name
:
SharingCode.NET User
Subject
:
Start a Process as a Different User
Description
:
To use this code please create a new module or add it to your existing project.
Function ConvertToSecureString(ByVal str As String) Dim password As New SecureString For Each c As Char In str.ToCharArray password.AppendChar(c) Next Return password End Function Sub Main() dim username as string = "Administrator" dim password as SecureString = ConvertToSecureString("my password") dim domain as string = Nothing dim filename as string = "notepad.exe" ' %SYSTEMROOT%\system32 Try System.Diagnostics.Process.Start(filename,username, password, domain) Catch ex As Win32Exception MessageBox.Show("Wrong username or password.", _ "Error logging in as administrator", MessageBoxButtons.OK, _ MessageBoxIcon.Error) End Try End Sub
Rating
:
4.00
(out of 5)
Visitor Voting Booth
:
Excellent
Very Good
Good
Fair
Poor
Copyright © 2006 SharingCode.NET . All rights reserved. Hosted By: SisNetworks