正文

以另一个用户的名义运行某一进程2012-05-02 20:50:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/iamben250/53450.html

分享到:

Start a Process as a Different User By Peter Rekdal Sunde, published on 09 May 2006 | Filed in 0 Comments .NET Security 1Tweet 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

阅读(3952) | 评论(1)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

loading...
您需要登录后才能评论,请 登录 或者 注册