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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Registry Restore Using A Service

Registry Restore Using A Service

Scheduled Pinned Locked Moved C / C++ / MFC
windows-adminhelp
2 Posts 2 Posters 1 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.
  • N Offline
    N Offline
    nagadravid
    wrote on last edited by
    #1

    Hi, I have implemented a service which will create and restore registry back ups. Service runs under local system account. I am able to take backup and restore in admin mode using the service. But in Guest user mode I m unable to resore the Registry back up. Any one can help me out in this.

    V 1 Reply Last reply
    0
    • N nagadravid

      Hi, I have implemented a service which will create and restore registry back ups. Service runs under local system account. I am able to take backup and restore in admin mode using the service. But in Guest user mode I m unable to resore the Registry back up. Any one can help me out in this.

      V Offline
      V Offline
      vipin_nvk
      wrote on last edited by
      #2

      hm.. i faced a similar problem last week. The problem is that a windows service runs in a LOCAL SYSTEM account and not in the account in which the user is currently logged in. Hence, if you try to take backups under registry key HKCR then the registry back up would fail. What you have to do under this condition is write a code something like this: HKEY hKey; long error; HANDLE hToken = NULL; BOOL bEnablePrivilege = TRUE; // obtain the explorer handle to get the hToken if(GetExplorerToken(hToken)) // write ur function to get explorer token!! { if(hToken != NULL) { ImpersonateLoggedOnUser(hToken); error = RegOpenKeyEx(HKEY_CURRENT_USER,strRegPath,0,KEY_ALL_ACCESS,&hKey); RevertToSelf(); } } Now, you can use the hKey obtained to open the required registry key under HKCR and take the back up!! Cheers

      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