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. Windows API
  4. how to change administrator user rights

how to change administrator user rights

Scheduled Pinned Locked Moved Windows API
windows-adminbusinesshelptutorialquestion
10 Posts 3 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.
  • J Offline
    J Offline
    jbalaji84
    wrote on last edited by
    #1

    Hi, I Created a user with admin rights in Vista Business trial version. Account type of the user is 'Administrator'. The following registry access is denied for that user when i tried accessing it through CreateFile() fuction: HKEY_LOCAL_MACHINE\CurrentControlSet\Control\Class\\Properties Even when i tried accessing the above location directly using "REGEDIT", i am getting a pop-up dialog saying "Access restricted". Do we need to do any specific configuration change for resolving this issue? I need to access the above location as a user with Admin rights. How can we acheive that? Balaji.J

    J M 2 Replies Last reply
    0
    • J jbalaji84

      Hi, I Created a user with admin rights in Vista Business trial version. Account type of the user is 'Administrator'. The following registry access is denied for that user when i tried accessing it through CreateFile() fuction: HKEY_LOCAL_MACHINE\CurrentControlSet\Control\Class\\Properties Even when i tried accessing the above location directly using "REGEDIT", i am getting a pop-up dialog saying "Access restricted". Do we need to do any specific configuration change for resolving this issue? I need to access the above location as a user with Admin rights. How can we acheive that? Balaji.J

      J Offline
      J Offline
      Jonathan Darka
      wrote on last edited by
      #2

      See the reply I gave you here regards,


      Jonathan Wilkes Darka[Xanya.net]

      1 Reply Last reply
      0
      • J jbalaji84

        Hi, I Created a user with admin rights in Vista Business trial version. Account type of the user is 'Administrator'. The following registry access is denied for that user when i tried accessing it through CreateFile() fuction: HKEY_LOCAL_MACHINE\CurrentControlSet\Control\Class\\Properties Even when i tried accessing the above location directly using "REGEDIT", i am getting a pop-up dialog saying "Access restricted". Do we need to do any specific configuration change for resolving this issue? I need to access the above location as a user with Admin rights. How can we acheive that? Balaji.J

        M Offline
        M Offline
        Mike Dimmick
        wrote on last edited by
        #3

        I'm not surprised, you cannot pass registry paths to CreateFile because they are not files. Perhaps you should try RegCreateKeyEx instead?

        Stability. What an interesting concept. -- Chris Maunder

        J 1 Reply Last reply
        0
        • M Mike Dimmick

          I'm not surprised, you cannot pass registry paths to CreateFile because they are not files. Perhaps you should try RegCreateKeyEx instead?

          Stability. What an interesting concept. -- Chris Maunder

          J Offline
          J Offline
          jbalaji84
          wrote on last edited by
          #4

          Hi, Thanks for the reply. I am not trying to access Registry path using CreateFile(), i was trying to access manually through REGEDIT. Now after giving permission for that Registry path manually, by right clicking that registry and setting the "Permission", i was able to access that Registry manually. The main problem now is, i am trying to access the device path using its GUID valus,Now the code fails in the following CreateFile() function and when i see the reason using GetLastError(), it says "Access is Denied". The following is the piece of code which fails(Remember, this same code works well in XP and 2000. Only in Vista, i am getting this problem): snprintf(device_path, sizeof(device_path), "\\\\.\\%s.tap",device_guid); thandle =CreateFile (device_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, 0); if ( thandle == INVALID_HANDLE_VALUE) { LOG (stderr,"Error : CreateFile failed on Netdirect device: %s",device_path); exit (1); } Could you tell me why this CreateFile() functin fails in that above case? Thanks in Advance. Balaji.J

          J 1 Reply Last reply
          0
          • J jbalaji84

            Hi, Thanks for the reply. I am not trying to access Registry path using CreateFile(), i was trying to access manually through REGEDIT. Now after giving permission for that Registry path manually, by right clicking that registry and setting the "Permission", i was able to access that Registry manually. The main problem now is, i am trying to access the device path using its GUID valus,Now the code fails in the following CreateFile() function and when i see the reason using GetLastError(), it says "Access is Denied". The following is the piece of code which fails(Remember, this same code works well in XP and 2000. Only in Vista, i am getting this problem): snprintf(device_path, sizeof(device_path), "\\\\.\\%s.tap",device_guid); thandle =CreateFile (device_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, 0); if ( thandle == INVALID_HANDLE_VALUE) { LOG (stderr,"Error : CreateFile failed on Netdirect device: %s",device_path); exit (1); } Could you tell me why this CreateFile() functin fails in that above case? Thanks in Advance. Balaji.J

            J Offline
            J Offline
            Jonathan Darka
            wrote on last edited by
            #5

            Have you tried running your application "As an administrator" so that it is elevated ?


            Jonathan Wilkes Darka[Xanya.net]

            J 1 Reply Last reply
            0
            • J Jonathan Darka

              Have you tried running your application "As an administrator" so that it is elevated ?


              Jonathan Wilkes Darka[Xanya.net]

              J Offline
              J Offline
              jbalaji84
              wrote on last edited by
              #6

              I tried running the application by logging into the "Administrator" user. In that case, there was no problem and everything works fine. But when i log-in in to the user account which is of "Administrator" type in Vista, and tried running my application, it fails in that CreateFile() function call with "Access is Denied" error value. Balaji.J

              J 1 Reply Last reply
              0
              • J jbalaji84

                I tried running the application by logging into the "Administrator" user. In that case, there was no problem and everything works fine. But when i log-in in to the user account which is of "Administrator" type in Vista, and tried running my application, it fails in that CreateFile() function call with "Access is Denied" error value. Balaji.J

                J Offline
                J Offline
                Jonathan Darka
                wrote on last edited by
                #7

                jbalaji84 wrote:

                But when i log-in in to the user account which is of "Administrator" type in Vista, and tried running my application, it fails in that CreateFile() function call with "Access is Denied" error value.

                Try this, from this second account. In explorer, right click on the .exe and select "Run as administrator" from the context menu. If this works, then you need to add a manifest file to your application. regards,


                Jonathan Wilkes Darka[Xanya.net]

                J 1 Reply Last reply
                0
                • J Jonathan Darka

                  jbalaji84 wrote:

                  But when i log-in in to the user account which is of "Administrator" type in Vista, and tried running my application, it fails in that CreateFile() function call with "Access is Denied" error value.

                  Try this, from this second account. In explorer, right click on the .exe and select "Run as administrator" from the context menu. If this works, then you need to add a manifest file to your application. regards,


                  Jonathan Wilkes Darka[Xanya.net]

                  J Offline
                  J Offline
                  jbalaji84
                  wrote on last edited by
                  #8

                  Unfortunately, my application is automatically invoked by CreateProcess() for that. So i cant right click that exe and do so? Is there any other way? OR can u provide the info about how to include manifest file in my code so that i can try that directly??? Balaji.J

                  J 1 Reply Last reply
                  0
                  • J jbalaji84

                    Unfortunately, my application is automatically invoked by CreateProcess() for that. So i cant right click that exe and do so? Is there any other way? OR can u provide the info about how to include manifest file in my code so that i can try that directly??? Balaji.J

                    J Offline
                    J Offline
                    Jonathan Darka
                    wrote on last edited by
                    #9

                    Sure thing,

                    <?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="MyExe.exe"
                    type="win32"/>
                    <description>MyExe Description</description>

                    <!-- Identify the application security requirements. -->
                    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
                    <security>
                    <requestedPrivileges>
                    <requestedExecutionLevel
                    level="asInvoker"
                    uiAccess="false"/>
                    </requestedPrivileges>
                    </security>
                    </trustInfo>
                    </assembly>

                    For a simple test, save this manifest into a text file with the same name as your .exe, but with a .manifest file extension, and put it in the same folder as the .exe you are running, Vista should pick it up automatically. So, if your exe is:

                    Myexe.exe

                    your manifest needs to be called:

                    Myexe.exe.manifest

                    If all this works, you can later embed the manifest into your .exe so you don't need to ship a seperate file. regards,


                    Jonathan Wilkes Darka[Xanya.net]

                    J 1 Reply Last reply
                    0
                    • J Jonathan Darka

                      Sure thing,

                      <?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="MyExe.exe"
                      type="win32"/>
                      <description>MyExe Description</description>

                      <!-- Identify the application security requirements. -->
                      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
                      <security>
                      <requestedPrivileges>
                      <requestedExecutionLevel
                      level="asInvoker"
                      uiAccess="false"/>
                      </requestedPrivileges>
                      </security>
                      </trustInfo>
                      </assembly>

                      For a simple test, save this manifest into a text file with the same name as your .exe, but with a .manifest file extension, and put it in the same folder as the .exe you are running, Vista should pick it up automatically. So, if your exe is:

                      Myexe.exe

                      your manifest needs to be called:

                      Myexe.exe.manifest

                      If all this works, you can later embed the manifest into your .exe so you don't need to ship a seperate file. regards,


                      Jonathan Wilkes Darka[Xanya.net]

                      J Offline
                      J Offline
                      jbalaji84
                      wrote on last edited by
                      #10

                      Thanks for that. I will try this and let you know the status ..... Hope this works :)

                      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