Jump to content
  • Announcements

    • AndalayBay

      Orphan Attachments   07/31/2018

      I have been doing some housekeeping lately and I've noticed that I had a lot of orphaned attachments. Attachments get orphaned when the PM or post is deleted without removing the attachment first. Deleting a PM or post does not delete the attachment and the file or image remain on the server. I'd like to ask all members to go through their attachments and delete any attachments you don't need anymore or those that have been orphaned. Where can I get a list of my attachments? Click on your display name in the upper right corner of the forums and pick "My Attachments" from the drop-down list. How can I tell an attachment is orphaned? If the PM has been deleted, you'll see a message like this in your attachment list: Unfortunately there is no message if the post has been deleted, so please check your old posts. We do purge old birthday threads every once in a while. Also some hosted projects have been shut down, so you may have orphaned attachments on one of those locations. Thanks!
Sign in to follow this  
Malonn

Windows API and Programming Questions

Recommended Posts

Posted (edited)

I am trying to figure out something that Windows makes a real pain in the ass.  I hope some of the programmers here have some of degree of familiarity with Windows and can help.  Here's the deal: big picture is I am trying to gain access to a registry key that has only admin access permission.  Apparently the calling script does not have admin permissions.  So, I've been reading Micorsoft docs and what I need to do is enable the SE_TAKE_OWNERSHIP_NAME privilege and open the protected key with WRITE_OWNER access.  Sounds simple, but it's not, at least to a noob like me.  So the way I've tried to go about it is to get the calling script's process handle and pass that to OpenProcessToken (where I'm stuck--I'll get back to that), from there I'd like to enable the privilege to read and delete a sub-key.  See here for the basics of what I'm trying to do (I'm writing in Python).  But when I call OpenProcessToken to get the token needed to adjust privileges, it return the ErrorCode 5 Access Denied.  So, how do I go about getting access to the token for the calling scripts process?  I've read about impersonating a token, but all I can dig up for that is using a thread (which I've tried) and that returns that it's not a valid thread.

I have ran the script as administrator through the caller (which works), but it's not ideal to me. It hits the line to ask for admin permission, then Windows prompts, you have to say yes, yadayada.  I like to avoid that if at all possible cuz this is ultimately going to be attached to a GUI, and it's bad juju to me.  Plus this is a good, albeit frustrating, learning exercise.

I hope you all can help.  Python forums gave me bumpkiss except the running as administrator way.

Edited by Malonn
clarify some things

Share this post


Link to post
Share on other sites

What exactly are you trying to do?  Perhaps you can provide a bigger picture that includes why you are trying to gain access to a privileged registry key. 

Share this post


Link to post
Share on other sites

It's actually a sub-key of the key I chose to fight with.  But I want to delete a certain key.  It's a thing where every so often this key comes back (it's not needed.  It's a second network connection--I only need the one 'correct' one) and I don't like it being in my registry.   It's more about coding practice than deleting the key.  I just don't like giving up without a fight; I'm fighting Microsoft.  They'll prolly win, but I'll go down swinging.

I know I can easily use Regedit or run the script as an administrator--it's just practice.  Trying to learn a programming language (Python).  Maybe I should avoid the Windows API for the time being?

Share this post


Link to post
Share on other sites

Messing with Windows authentication is probably not a good place to start; there is a lot of arcane legacy stuff in there to confound the beginner.  Besides, if you really want something difficult to do in Python you should try machine learning.  It looks like TensorFlow is now supported in Windows (used to be just Unix/Mac).  

Share this post


Link to post
Share on other sites

I hear ya.  After a few days break from the problem I'm not as attached to it.

I must say, I don't want something difficult to learn any time soon.  I wouldn't even call myself a true beginner yet.  I'm pre-beginner.

But, thanks for the response.  I think I'll move on--use one of the other ways to delete the key I want to.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×