当前位置:编程学习 > C#/ASP.NET >>

怎样才能通过自己写的系统服务程序A,以当前用户运行程序B。

--------------------编程问答-------------------- 是不是这个意思:
CODE        Dim imp As New RunAs_Impersonator        Try            imp.ImpersonateStart(DomainName, UserName, Password)  'creates new context using token for user            Add code to run as UserName here  'everything between ImpersonateStart and ImpersonateStop will be run as the impersonated user            imp.ImpersonateStop()         Catch ex As Exception  'make sure impersonation is stopped whether code succeeds or not            MsgBox(ex.Message)            imp.ImpersonateStop()        End Try 

http://www.tek-tips.com/viewthread.cfm?qid=1235871 --------------------编程问答-------------------- 你的代码前提是要知道当前的用户,系统服务程序,用Environment.UserName检测到的用户是“system”不是真正的用户. --------------------编程问答-------------------- 楼主你应该在启动时设置你的B程序用某个帐户启动,因为通常登录的是administrator这类的帐号而不是System这帐号。 --------------------编程问答-------------------- 1、启动服务程序的账号不使用 System,而是本机的一个管理员帐户,例如 Administratro。这样就可以保证不是System启动程序了。
2、服务程序中事先设定好启动程序B的用户名和密码,然后使用这个用户名和密码启动程序B。
补充:.NET技术 ,  VB.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,