Results 1 to 7 of 7

Thread: VB NTService

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2004
    Posts
    16

    Resolved VB NTService

    Hi Guys,

    I have implemented a service using VB6(NTSVC.OCX) and it is working fine without any errors. My problem is whenever I installling my service, it is installing with "Log on as" field as "Localsystem". I want to install this service as "Log on as" field as current username. How would i do that? I know that we can change "LOg on as " field after installing the service in "services", but I want to how we can make "Log on as" field as current username before installing the service itself.


    Any input is appreciated,ASAP

    Thanks a bunch in advance,
    DilSe.
    Last edited by DilSe; Oct 1st, 2004 at 08:09 AM.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Aug 2004
    Posts
    16
    throw some falsh guys...


    DilSe..

  3. #3
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353
    There is an api call to get username, you well have to do it in the logon code. We us C++ for our logon.
    just 2 cent
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  4. #4
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713
    Here is a function for getting the current windows username.
    VB Code:
    1. Private Declare Function GetUserName Lib "advapi32.dll" _
    2. Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    3.  
    4. Public Function CurrentUser() As String
    5.  
    6.     Dim strBuff As String * 256
    7.     Dim x As Long
    8.    
    9.     CurrentUser = ""
    10.     x = GetUserName(strBuff, Len(strBuff) - 1)
    11.     If x > 0 Then
    12.         x = InStr(strBuff, vbNullChar)
    13.         If x > 0 Then
    14.             CurrentUser = UCase(Left$(strBuff, x - 1))
    15.         End If
    16.     End If
    17.  
    18. End Function
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Aug 2004
    Posts
    16
    I guess I am not clear to u guys. Let me make it clear to you. I want to know how we can start an NTService with "Logonname" as current username instaed of Local system because if we install the NT service, By default it installs with the "LocalSystem" as Logon user.

    I want to know how we can change and where we can change the default settings while installing the Nt Service using VB6 so that insteadof LocalSystem our username should be there.


    Let me know if I am still not clear..

    Thanks for the responses,

    DilSe..

  6. #6
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713
    I dont think the control supports username. I cant remember
    off hand. I create my services using al APIs. Its allot of work and
    code, but you get full control.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Aug 2004
    Posts
    16
    Thanks alot robDog...I will try to find a way out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width