Announcement

Collapse
No announcement yet.

Administrator manifest for Vista

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

  • Administrator manifest for Vista

    To test with Vista I've put a link to the executable here http://www.dotysoftware.com/topdog.exe
    Would appreicate knowing the results?

    Would someone look over the .xml code to see if it is correct?
    All other programs (that do not need more rights) do not need a manifest, correct?
    Does TopDog create C:\Program Files\My Test Folder using Vista 32-bit and Vista 64-bit?
    What other manifests do we need to distribute Vista programs (if not using an installer?)
    Getting a Vista box tomorrow.


    'Save as TopDog.Bas
    Code:
    'TopDog.Bas
    #COMPILE EXE
    #DIM ALL
    #RESOURCE "admin.pbr"
    'uiAccess = false or you need to pay Microsoft   can only send messages to equal or lower levels
      #COMPILE EXE
      #DIM ALL
      #RESOURCE "admin.pbr"
      FUNCTION PBMAIN AS LONG
        LOCAL sFolder AS STRING
        sFolder = "c:\Program Files\My Test Folder"
        ? "TopDog with admin privileges"
        MKDIR sFolder
        IF ERR = 0 THEN
            ? "Created " + sFolder + " will now remove."
            RMDIR sFolder
            IF ERR = 0 THEN
              ? "Removed " + sFolder
            ELSE
                ? "Error" + STR$(ERRCLEAR) + " of folder " + sFolder
            END IF
        ELSE
            ? "Unable to create " + sFolder + " error" + STR$(ERRCLEAR)
        END IF
     
      END FUNCTION
    'Save as Admin.Xml
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
      <assemblyIdentity
        version="1.0.0.0"
        processorArchitecture="X86"
        NAME = "TopDog"
        TYPE = "win32" />
        <description>I am the top dog</description>
        <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
          <security>
            <requestedPrivileges>
              <requestedExecutionLevel level="requireAdministrator"  uiAccess="false" />
            </requestedPrivileges>
          </security>
        </trustInfo>
    </assembly>
    'Save as Admin.Rc
    Code:
    1 24 admin.xml

    RC.EXE Admin.Rc ----> creates Admin.Res
    PBRES Admin.Res ----> creates Admin.Pbr


    uiAccess information
    Last edited by Mike Doty; 7 Aug 2008, 12:58 PM. Reason: Cosmetic

  • #2
    Originally posted by Mike Doty View Post
    Would appreicate knowing the results?

    Does TopDog create C:\Program Files\My Test Folder using Vista 32-bit and Vista 64-bit?
    It does create and remove in VISTA64

    Rod

    Comment


    • #3
      Thank you!
      Last edited by Mike Doty; 8 Aug 2008, 11:16 AM.

      Comment


      • #4
        All files are at http://www.dotysoftware.com/topdog/

        The big question is "Does it ask to elevate permission?"






        http://www.dotysoftware.com/topdog/all.zip (everything here)
        http://www.dotysoftware.com/topdog/easy.bat (create .pbr file)

        Last edited by Mike Doty; 8 Aug 2008, 12:34 PM. Reason: Listed each file hoping someone will see if it asks to elevate permisson.

        Comment


        • #5
          Rod,
          Were you running as an admin at the time?
          Did it ask if you wanted to elevate permission?

          Comment


          • #6
            Mike,

            On Vista Home Premium, 32-bit, running as non-admin, it asked for permission, it created the folder, it removed the folder. No problems.

            Comment


            • #7
              Great. Thank you. Just got a Vista box and seeing some interesting changes. I like it, so far.

              Comment


              • #8
                The application has failed to start because its side-by-side configuration is incorrect.
                Please see the application event log or use the command-line sxstrace.exe tool for more detail.

                Using Windows 7 and can't run with the manifest.
                Anyone used sxstrace or see the problem?


                admin.rc
                Code:
                 1 24 admin.xml
                admin.xml
                Code:
                <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
                <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
                  <assemblyIdentity
                    version="1.0.0.0"
                    processorArchitecture="X86"
                    NAME = "topdog.exe"
                    TYPE = "win32" />
                    <description>elevation</description>
                    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
                      <security>
                        <requestedPrivileges>
                          <requestedExecutionLevel level="requireAdministrator"  uiAccess="false" />
                        </requestedPrivileges>
                      </security>
                    </trustInfo>
                </assembly>
                topdog.bas
                Code:
                #COMPILE EXE
                #DIM ALL
                #RESOURCE "admin.pbr"
                  #COMPILE EXE
                  #DIM ALL
                  #RESOURCE "admin.pbr"
                  FUNCTION PBMAIN AS LONG
                    LOCAL sFolder AS STRING
                    sFolder = "c:\Program Files\My Test Folder"
                    MKDIR sFolder
                    IF ERR = 0 THEN
                        ? "Created " + sFolder + " will now remove."
                        RMDIR sFolder
                        IF ERR = 0 THEN
                          ? "Removed " + sFolder
                        ELSE
                            ? "Error" + STR$(ERRCLEAR) + " of folder " + sFolder
                        END IF
                    ELSE
                        ? "Unable to create " + sFolder + " error" + STR$(ERRCLEAR)
                    END IF
                 
                  END FUNCTION
                Last edited by Mike Doty; 19 Mar 2014, 09:58 AM.

                Comment


                • #9
                  In assemblyIdentity the NAME and TYPE should be lowercase. The manifest elements are case-sensitive (http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx, see ELEMENTS).

                  Not sure on the values case-sensitivity so you might also need to also change X86 to x86 under processorArchitecture .
                  Last edited by George Bleck; 19 Mar 2014, 11:46 AM.
                  <b>George W. Bleck</b>
                  <img src='http://www.blecktech.com/myemail.gif'>

                  Comment


                  • #10
                    Thank you, George!
                    That works. Did require x86 to be lower case.

                    For any lurkers:
                    Load admin.rc 1 24 admin.xml into compiler and click compile.
                    That creates admin.res which then creates admin.pbr which
                    is loaded into final program with the line #RESOURCE "admin.pbr"

                    Not sure if all programs should use a manifest like this by changing
                    name = "topdog.exe" to name="program name goes here.exe"?

                    admin.xml
                    Code:
                     <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
                    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
                      <assemblyIdentity
                        version="1.0.0.0"
                        processorArchitecture="x86"
                        name = "topdog.exe"
                        type = "win32" />
                        <description>elevation</description>
                        <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
                          <security>
                            <requestedPrivileges>
                              <requestedExecutionLevel level="requireAdministrator"  uiAccess="false" />
                            </requestedPrivileges>
                          </security>
                        </trustInfo>
                    </assembly>
                    admin.rc
                    Code:
                     1 24 admin.xml
                    Last edited by Mike Doty; 20 Mar 2014, 11:26 AM.

                    Comment

                    Working...
                    X