|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Windows Service AuthorizationI need to run this type of code in my windows Service: /////////////////////////////////////////////////////////////////////////////// Protected Overrides Sub OnStart(ByVal args() As String) If User= "Administrator" Then 'do code Else 'do nothing End If End ///////////////////////////////////////////////////////////////////////////////// Can I check who is logged in to the computer with help of service? When I try to: ///////////////////////////////////////////////////////////////////////////////// If My.User.IsInRole(ApplicationServices.BuiltInRole.Administrator) Then or If My.User.CurrentPrincipal.Identity.Name = "Administrator" Then ////////////////////////////////////////////////////////////////////////////// It does't work (goes directly to 'Else).. Best Regards
Show quote
Hide quote
"matisq" <mati***@tlen.pl> wrote in message Environment.UserName? Your service may need to be set to allow interaction news:1159803472.252951.135240@m73g2000cwd.googlegroups.com... > Hello > > I need to run this type of code in my windows Service: > /////////////////////////////////////////////////////////////////////////////// > Protected Overrides Sub OnStart(ByVal args() As String) > > If User= "Administrator" Then > 'do code > Else > 'do nothing > End If > > End > ///////////////////////////////////////////////////////////////////////////////// > Can I check who is logged in to the computer with help of service? > > When I try to: > ///////////////////////////////////////////////////////////////////////////////// > If My.User.IsInRole(ApplicationServices.BuiltInRole.Administrator) Then > or > If My.User.CurrentPrincipal.Identity.Name = "Administrator" Then > ////////////////////////////////////////////////////////////////////////////// > It does't work (goes directly to 'Else).. > with the desktop though. Also, check what your service logs on as - it might be "LocalSystem" or similar.
Q: closing forms
CURRENT INDEX of Iteration on ILIST collection ? 1.1 equivalent for Drawing.Icon.ExtractAssociatedIcon? Help with using bits in an integer Accessing the Class Name of a Shared Method Strings, a couple of questions like difference between += and &= new form copy and paste into webbrowser Set Statement vs Function chm and application.startuppath |
|||||||||||||||||||||||