In the following script I can't get the reg key to unload. Anyone got
any ideas? I can load and save the key without any problems. I can
unload the key from regedit and have checked security on the key. The
docs don't mention any special privileges are needed
(SeRestorePrivilege should do it). I'm stumped. Cheers peeps, MW.
import ntsecuritycon
import win32security
import win32api
import _winreg
import win32con
flags = ntsecuritycon.TOKEN_ADJUST_PRIVILEGES |
ntsecuritycon.TOKEN_QUERY
htoken = win32security.OpenProcessToken(win32api.GetCurrent Process(),
flags)
Loadid = win32security.LookupPrivilegeValue(None, 'SeRestorePrivilege')
#Saveid = win32security.LookupPrivilegeValue(None, 'SeBackupPrivilege')
LoadPrivilege = [(Loadid, ntsecuritycon.SE_PRIVILEGE_ENABLED)]
#SavePrivilege = [(Saveid, ntsecuritycon.SE_PRIVILEGE_ENABLED)]
win32security.AdjustTokenPrivileges(htoken, 0, LoadPrivilege)
#win32security.AdjustTokenPrivileges(htoken, 0, SavePrivilege)
key = _winreg.HKEY_USERS
hkey = win32api.RegLoadKey(key,'Marc','c:\\ntuser.dat')
okey =
win32api.RegOpenKeyEx(key,'Marc\\test',0,win32con. KEY_ALL_ACCESS)
win32api.RegSetValueEx(okey,'test',0,_winreg.REG_D WORD,0)
#win32api.RegSaveKey(okey,'c:\\ntuser2.dat',None)
#win32api.RegFlushKey(_winreg.HKEY_USERS)
win32api.RegUnLoadKey(key,'Marc') 2 5069
I've worked out that I can open and close the key fine if I don't open
a subkey. I've tried adding flush and close statements after opening
the key and still get access denied when trying to unload.
solved it!
I need to close the key first
import ntsecuritycon
import win32security
import win32api
import _winreg
import win32con
flags = ntsecuritycon.TOKEN_ADJUST_PRIVILEGES |
ntsecuritycon.TOKEN_QUERY
htoken = win32security.OpenProcessToken(win32api.GetCurrent Process(),
flags)
Loadid = win32security.LookupPrivilegeValue(None, 'SeRestorePrivilege')
Saveid = win32security.LookupPrivilegeValue(None, 'SeBackupPrivilege')
LoadPrivilege = [(Loadid, ntsecuritycon.SE_PRIVILEGE_ENABLED)]
SavePrivilege = [(Saveid, ntsecuritycon.SE_PRIVILEGE_ENABLED)]
win32security.AdjustTokenPrivileges(htoken, 0, LoadPrivilege)
win32security.AdjustTokenPrivileges(htoken, 0, SavePrivilege)
key = _winreg.HKEY_USERS
hkey = win32api.RegLoadKey(key,'Marc','c:\\ntuser.dat')
okey = win32api.RegOpenKeyEx(key,'Marc\\test',0,win32con. KEY_SET_VALUE)
win32api.RegSetValueEx(okey,'test',0,_winreg.REG_D WORD,0)
win32api.RegCloseKey(okey)
win32api.RegUnLoadKey(key,'Marc') This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: calfdog |
last post by:
Hello,
Does anyone know a workaround for calling fireEvent.
With the latest from Microsoft OS XP2 and Hot fixes to
IE it now gives an "access denied" error in Python when called.
Here is what...
|
by: Steve |
last post by:
Hi,
Yesterday I signed up for another dedicated linux server with the hosting
company I use and I am having problems getting MySQL 4.1.3 working on it.
I've tried just about everything I can...
|
by: |
last post by:
Hi All,
I have allready tried to ask a similar question , but got no answer until now. In the meantime, I
found, that I cannot understand some thread-settings for the Main() function
.
If I use...
|
by: ASP.Confused |
last post by:
The old message looked a little stale, so I am re-posting it here. Anybody
have any ideas of what I could do?!? The previous responses to this
question are below. If you want to look at the...
|
by: Ron Weldy |
last post by:
I have a test server runinng 2003/IIS 6 with a mixture of asp and asp.net
files. On my workstation I have a share set up to the folder where the web
files reside. I am just doing quick and dirty...
| |
by: Shailesh Humbad |
last post by:
I figured out what was causing the "Access is Denied" error when
calling functions from referenced DLLs in my service. I've tried to
be very detailed, so bear with me.
It turns out that...
|
by: Jeremy Ames |
last post by:
I am trying to move an application from my system to a new test system. I really should have tried an easier program first, but I didn't really have a chance. My application was originally written in...
|
by: private.anders |
last post by:
Hi David!
Really need assistance since I have been struggling with a problem
long time now.
I am running a web application on a Win 2003 Std (Active Directory).
Everything works fine. I have...
|
by: private.anders |
last post by:
Really need your assistance since I have been struggling with a
problem long time now.
I am running a web application on a Win 2003 Std (Active Directory).
Everything works fine. I have...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |