Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to run program at windows startup with administrator rights (on VISTA and Windows 7 )?

How to run program at windows startup with administrator rights (on VISTA and Windows 7 )?

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aseem Sharma
    wrote on last edited by
    #1

    Hi friends, My application needs administrator rights to function properly. If user wants to launch the application manually, he has to right click to pop context menu up and then selecting the option "Run as Administrator". But it could be irritating to so many users. How can the application be started with full/administrator/escalated rights when it is being launched automatically at windows startup? I need to do this on VISTA and Windows 7. Also is it possible that the application, irrespective of if it is launched manually or automatically at startup, always get started with administrator rights? I need to do this thing programmatically (using C# or installshield). Please help me. Thanks in advance, Aseem

    modified on Tuesday, November 2, 2010 1:01 PM

    L D P 3 Replies Last reply
    0
    • A Aseem Sharma

      Hi friends, My application needs administrator rights to function properly. If user wants to launch the application manually, he has to right click to pop context menu up and then selecting the option "Run as Administrator". But it could be irritating to so many users. How can the application be started with full/administrator/escalated rights when it is being launched automatically at windows startup? I need to do this on VISTA and Windows 7. Also is it possible that the application, irrespective of if it is launched manually or automatically at startup, always get started with administrator rights? I need to do this thing programmatically (using C# or installshield). Please help me. Thanks in advance, Aseem

      modified on Tuesday, November 2, 2010 1:01 PM

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Hi,

      Aseem Sharma wrote:

      But it could be irritating to so many users.

      It would be more irritating if some application ran with more rights than I assigned to it :)

      Aseem Sharma wrote:

      How can the application be started with full/administrator/escalated rights when it is being launched automatically at windows startup? I need to do this on VISTA and Windows 7.

      Proces.Start[^]. Needless to say that you'll need to supply the password of the local administrator before you're allowed to do that. Good luck :)

      I are Troll :suss:

      P 1 Reply Last reply
      0
      • A Aseem Sharma

        Hi friends, My application needs administrator rights to function properly. If user wants to launch the application manually, he has to right click to pop context menu up and then selecting the option "Run as Administrator". But it could be irritating to so many users. How can the application be started with full/administrator/escalated rights when it is being launched automatically at windows startup? I need to do this on VISTA and Windows 7. Also is it possible that the application, irrespective of if it is launched manually or automatically at startup, always get started with administrator rights? I need to do this thing programmatically (using C# or installshield). Please help me. Thanks in advance, Aseem

        modified on Tuesday, November 2, 2010 1:01 PM

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        You need a manifest file to launch the app with admin permissions, provided the user has them in the first place! In the application manifest file, there is a line that looks like this:

        <requestedExecutionLevel level="asInvoker" uiAccess="false" />
        

        You have to change that line to read:

        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
        

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak

        A 1 Reply Last reply
        0
        • L Lost User

          Hi,

          Aseem Sharma wrote:

          But it could be irritating to so many users.

          It would be more irritating if some application ran with more rights than I assigned to it :)

          Aseem Sharma wrote:

          How can the application be started with full/administrator/escalated rights when it is being launched automatically at windows startup? I need to do this on VISTA and Windows 7.

          Proces.Start[^]. Needless to say that you'll need to supply the password of the local administrator before you're allowed to do that. Good luck :)

          I are Troll :suss:

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          Ha! I did something like that* on my last job. I wrote a little app to monitor the health of the system -- availability of the databases, status of the many Windows Services, etc. But the users (operators) didn't have the same access as the Services -- so I used a Process to execute various things (always read-only). The username and password for the Services was already stored in a database (mostly out of laziness), so I access that; the user doesn't know the password, doesn't even know that the app executes under a different user. :laugh: * But not actually an administrator, just a user with access to more systems.

          1 Reply Last reply
          0
          • A Aseem Sharma

            Hi friends, My application needs administrator rights to function properly. If user wants to launch the application manually, he has to right click to pop context menu up and then selecting the option "Run as Administrator". But it could be irritating to so many users. How can the application be started with full/administrator/escalated rights when it is being launched automatically at windows startup? I need to do this on VISTA and Windows 7. Also is it possible that the application, irrespective of if it is launched manually or automatically at startup, always get started with administrator rights? I need to do this thing programmatically (using C# or installshield). Please help me. Thanks in advance, Aseem

            modified on Tuesday, November 2, 2010 1:01 PM

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            Aseem Sharma wrote:

            needs administrator rights to function properly

            You'll have to prove that, or redesign. What is it that you are trying to do? Will a Web Service be of any help?

            A 1 Reply Last reply
            0
            • D Dave Kreskowiak

              You need a manifest file to launch the app with admin permissions, provided the user has them in the first place! In the application manifest file, there is a line that looks like this:

              <requestedExecutionLevel level="asInvoker" uiAccess="false" />
              

              You have to change that line to read:

              <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
              

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak

              A Offline
              A Offline
              Aseem Sharma
              wrote on last edited by
              #6

              Hi Dave, Thanks for your reply. Actually I am new in .Net technologies. I don't know how to create a manifest file. I don't know how to ship it with installer. My requirement: My application can allow/revoke the right of changing system time and date to any user but only if it is being run from an administrator user. When I run my app while logged on as an non-admin user, my application cannot allow or disallow any right to any user (this is desired behavior and its working fine). But same thing happens even when I log on as a user with admin rights. The only way my app can allow or revoke rights to any user is **first-**the current user should have admin rights, **second-**application run with "Run as administrator" option. Please help me in below things: 1 How to create a manifest file? 2 Is it sufficient to just place it in the same directory where the application exe is present? (If yes then while installing I would just need to copy it along with the application exe in the same directory) 3 If application starts automatically on Windows startup, what would happen if a non-administrator (restricted user) log on? (would the application run with admin rights or with the rights of logged on user?) 4 Are there some registry entries where if an application exe is specified, it will run (on Windows startup) with all the rights the current user have? Please help me in this problem. Best Regards Aseem

              1 Reply Last reply
              0
              • P PIEBALDconsult

                Aseem Sharma wrote:

                needs administrator rights to function properly

                You'll have to prove that, or redesign. What is it that you are trying to do? Will a Web Service be of any help?

                A Offline
                A Offline
                Aseem Sharma
                wrote on last edited by
                #7

                Hi Piebald, Thanks for your reply. My requirement: My application can allow/revoke the right of changing system time and date to any user but only if it is being run from an administrator user. When I run my app while logged on as an non-admin user, my application cannot allow or disallow any right to any user (this is desired behavior and its working fine). But same thing happens even when I log on as a user with admin rights. The only way my app can allow or revoke rights to any user is first-the current user should have admin rights, second-application run with "Run as administrator" option. If you can suggest me any solution, plz let me know. Best Regards Aseem

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups