• Capture Computer ID – Forms (MS Outlook 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Outlook and email programs » Capture Computer ID – Forms (MS Outlook 2000)

    Author
    Topic
    #404318

    I am creating a form and I need to know which computer the form request comes from so I need to capture the ComputerID. I also want to capture the UserID from the loging. I don’t want them to type in their name. Not sure how to enter this in the vb script.

    Viewing 3 reply threads
    Author
    Replies
    • #821581

      The easiest way, if IS always sets these parameters per machine in your entity, is to get them from the environment space:

      strUserID = Environ(“username”)
      strComputerID = Environ(“computername”)

      Adjust the environment names as applicable (to see them, at the command line, type SET). (This works in VBA, I assume it’ll be fine in VBS).

      If this doesn’t work, there are API ways to get UserID, search the VBA forum, not sure about ComputerID.

    • #821582

      The easiest way, if IS always sets these parameters per machine in your entity, is to get them from the environment space:

      strUserID = Environ(“username”)
      strComputerID = Environ(“computername”)

      Adjust the environment names as applicable (to see them, at the command line, type SET). (This works in VBA, I assume it’ll be fine in VBS).

      If this doesn’t work, there are API ways to get UserID, search the VBA forum, not sure about ComputerID.

    • #821607

      (Edited by jscher2000 on 29-Apr-04 14:02. On second thought.)

      In a pure VBScript environment, you’d have to go out to the Windows Script Host for this information. Assuming the Outlook Forms security model lets you do that, see post 130373 for some sample code.

      Added: Actually, if you can get this information from the Office or Outlook object model instead of Windows Script Host, that might work better. However, I haven’t trawled the object browser to see if it’s there. Please post whatever solution you end up using, as I suspect others might be interested in the same thing in the future.

      • #821654

        Thanks for the VBS script. VBS doesn’t let you read the environment space?

        FWIW, Word and Excel have ‘Application.Username‘, but I don’t see the Property in Outlook.

      • #821655

        Thanks for the VBS script. VBS doesn’t let you read the environment space?

        FWIW, Word and Excel have ‘Application.Username‘, but I don’t see the Property in Outlook.

        • #821699

          VBS doesn’t have much intelligence about the system without invoking other objects. There is a way to access the environment through the Shell, but I haven’t tried to code it up. This page gives an overview of the WSH objects and collections, which can be scripted: Windows Script Host Object Model.

          • #821816

            Thanks for the examples. I will try these out and see what I come up with.

          • #821817

            Thanks for the examples. I will try these out and see what I come up with.

          • #823241

            Resurrecting this older thread, I guess I didn’t look far enough for the Outlook User; it’s a Property of NameSpace:

            Function GetCurrentUser() As String
            Dim objOLApp As Outlook.Application
            Dim nsNS As NameSpace
            Set objOLApp = CreateObject(“Outlook.Application”)
            Set nsNS = objOLApp.GetNamespace(“MAPI”)
            GetCurrentUser = vbNullString
            On Error Resume Next
            GetCurrentUser = nsNS.CurrentUser.Name
            Set objOLApp = Nothing
            Set nsNS = Nothing
            End Function

          • #823242

            Resurrecting this older thread, I guess I didn’t look far enough for the Outlook User; it’s a Property of NameSpace:

            Function GetCurrentUser() As String
            Dim objOLApp As Outlook.Application
            Dim nsNS As NameSpace
            Set objOLApp = CreateObject(“Outlook.Application”)
            Set nsNS = objOLApp.GetNamespace(“MAPI”)
            GetCurrentUser = vbNullString
            On Error Resume Next
            GetCurrentUser = nsNS.CurrentUser.Name
            Set objOLApp = Nothing
            Set nsNS = Nothing
            End Function

        • #821700

          VBS doesn’t have much intelligence about the system without invoking other objects. There is a way to access the environment through the Shell, but I haven’t tried to code it up. This page gives an overview of the WSH objects and collections, which can be scripted: Windows Script Host Object Model.

    • #821608

      (Edited by jscher2000 on 29-Apr-04 14:02. On second thought.)

      In a pure VBScript environment, you’d have to go out to the Windows Script Host for this information. Assuming the Outlook Forms security model lets you do that, see post 130373 for some sample code.

      Added: Actually, if you can get this information from the Office or Outlook object model instead of Windows Script Host, that might work better. However, I haven’t trawled the object browser to see if it’s there. Please post whatever solution you end up using, as I suspect others might be interested in the same thing in the future.

    Viewing 3 reply threads
    Reply To: Capture Computer ID – Forms (MS Outlook 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: