Announcement

Collapse
No announcement yet.

UserMgr Plugin

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • UserMgr Plugin

    Hello Ivan,

    I uploaded a new version of the plugin, which has a new Function "GetCurrentDomain".



    This function will return the domainname you are currently logged in to (in your case "mshome").

    Best regards,
    jpderuiter

    P.S.: this is a follow up of the "New Plugin" thread on this forum:
    Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.

  • #2
    Environmental variables changed creating a new user

    Hi all,

    After I created a new user, I make some shortcuts in the start menù, but I find those shortcuts in the "newuser" menù, not in the current user menù. (but I want them in the current user menù!)
    It seems like UserMgr pluging changed the environmental variable when creating the user.

    Any suggestions?

    Many thanks,
    Luca

    This is my nsis code:

    UserMgr::CreateAccountEx "newuser" "password" "-" "-" "-" "UF_PASSWD_CANT_CHANGE|UF_DONT_EXPIRE_PASSWD"
    Pop $0
    ${If} $0 != "OK"
    Quit
    ${EndIf}

    UserMgr::AddToGroup ${AEPUSER} "Users"
    Pop $0
    ${If} $0 != "OK"
    Quit
    ${EndIf}

    UserMgr::BuiltAccountEnv ${AEPUSER} ${AEPPWD}
    Pop $0
    ${If} $0 != "OK"
    Quit
    ${EndIf}

    CreateDirectory "$SMPROGRAMS\myapp"
    CreateShortCut "$SMPROGRAMS\myapp\myapp.lnk" "$INSTDIR\myapp.exe" "" "$INSTDIR\myapp.exe" 0

    Comment


    • #3
      Hello coppolo,

      I tried the following:

      code:

      SetShellVarContext current

      MessageBox MB_OK "$SMPROGRAMS"

      UserMgr::CreateAccountEx "myuserA" "mypassword" "" "" "" "UF_PASSWD_NOTREQD|UF_DONT_EXPIRE_PASSWD"
      Pop $0

      UserMgr::BuiltAccountEnv "myuserA" "mypassword"
      Pop $0

      MessageBox MB_OK "$SMPROGRAMS"

      UserMgr:eleteAccount "myuserA"
      Pop $0

      MessageBox MB_OK "$SMPROGRAMS"

      All 3 Messageboxes show the Startmenu programs folder of the current user, not the new created user.

      But as soon as I comment the first messagebox out, the other 2 Messageboxes both show the Startmenu programs folder of the new created user!

      I'm not sure what is causing this, but as far as I can see the UserMgr plugin does not change the environmental variable at all.

      Anyone else?

      Regards,
      jpderuiter

      Comment


      • #4
        Re: UserMgr Plugin

        Originally posted by jpderuiter
        [B]Hello Ivan,

        I uploaded a new version of the plugin, which has a new Function "GetCurrentDomain".



        This function will return the domainname you are currently logged in to (in your case "mshome").
        Thanks, this is exactly what I need. Unfortunately, when I call this new function the installer just crashes.

        I have an actual domain here, not a workgroup. Not sure if this would affect anything. I tested it on 2 different domains and 2 different machines and the behavior is the same.

        code:
        Exception Information
        Code: 0xc0000005 Flags: 0x00000000
        Record 0x00...00 Address: 0x00...05c

        Comment


        • #5
          Hello Ivan,

          unfortunately I'm in a workgroup, and it was working correctly for me.

          But a used another combination of API's to get the domainname, and I uploaded it to the wiki.

          Can you try if it works now?

          Best regards,
          Jan Pieter

          Comment


          • #6
            Originally posted by jpderuiter
            Hello Ivan,

            unfortunately I'm in a workgroup, and it was working correctly for me.

            But a used another combination of API's to get the domainname, and I uploaded it to the wiki.

            Can you try if it works now?

            Best regards,
            Jan Pieter
            The result is pretty much the same. I have to complete some other work, but I want to come back to this.

            Can you create a pdb file and upload it somewhere so I can debug? It's a pain to build the project myself since I am running different Visual Studio version, and don't have libc.

            Comment


            • #7
              Hello Ivan,

              I'm sorry to hear that, and that I'm unable to help now.

              I sent you a private message with a link to the Debug version, incl the pdb.
              I also altered the GetCurrentDomain again, so maybe it's working now.

              Best regards,
              Jan Pieter

              Comment


              • #8
                This installer crashes every time I try to run it:
                code:
                Name "UsrMgrTest"
                OutFile "UsrMgrTest.exe"
                ShowInstDetails show
                Page instfiles

                Section "" ;No components page, name is not important
                UserMgr::HasPrivilege "Tobbe" "SeInteractiveLogonRight "
                Pop $0
                DetailPrint ">$0<"
                SectionEnd

                Am I doing something wrong here?

                Comment


                • #9
                  Hello all,

                  I uploaded a new version of the plugin with a bugfix for the crashing installer.

                  @Tobbe:
                  I tried your script, and it's not crashing anymore, but it wasn't crashing before on the HasPrivilege call, only when exiting the installer.

                  @Ivan:
                  I tried the GetCurrentDomain function at work, and it's returning the domain properly.

                  @coppolo:
                  Your problem isn't solved yet.
                  A workaround could be creating the shortcuts before calling BuiltAccountEnv, or storing the $SMPROGRAMS string in another variable.

                  Best regards,
                  jpderuiter

                  Comment


                  • #10
                    It still crashes for me. It crashes before it prints anything to the log window.

                    Comment


                    • #11
                      Hmm, strange.

                      I assume you are using NSIS v2.42?
                      Are other UserMgr funtions crashing the installer as well?

                      Comment


                      • #12
                        Hmm, I'm using 2.37. Let me upgrade and I'll report back

                        Comment


                        • #13
                          So I upgraded to 2.42 and now I get different results

                          With the latest version of UserMgr I get this:
                          Invalid command: UserMgr::HasPrivilege
                          Invalid command: UserMgr::GetCurrentUserName

                          UserMgr::GetUserInfo "Tobbe" "HOMEDIR" doesn't give me the Invalid command error, but it only returns an empty string.

                          My installer does not crash however

                          With the old version I don't get any Invalid command errors, but "HasPrivilege" returns ERROR LsaEnumerateAccountRights and GetUserInfo only returns an empty string. GetCurrentUserName does however correctly return "Tobbe"

                          EDIT: With the old version I get the behavior you describe with the installer crashing when closing it.

                          Comment


                          • #14
                            Originally posted by jpderuiter
                            Hmm, strange.

                            I assume you are using NSIS v2.42?
                            Are other UserMgr funtions crashing the installer as well?
                            I am getting a crash from calling any function now - tried a few. I am on NSIS 2.41 but can't upgrade for now.

                            Comment


                            • #15
                              Well, I have used the new NSIS Plugin API coming with NSIS v2.42, so I think that's the reason why it's crashing.
                              So you should upgrade to 2.42 to make the plugin work.

                              For the time being you can use the older plugin version dated 22:06, 1 February 2008:

                              Comment

                              Working...
                              X
                              😀
                              🥰
                              🤢
                              😎
                              😡
                              👍
                              👎