Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    180
    Rep Power
    9

    python, need help gaining acess


    i am using python to make a small program to maintain my Temporary internet files since i don't know how to do it in the C language yet. heres the python code that i use.

    [
    def deltemps():
    from glob import glob
    import os
    import time
    count = 0
    temps = glob("C:\\Documents and Settings\\*\\Local Settings\\Temporary Internet Files\\Content.IE5\\*\\*")
    for temp in temps:
    if temp == "C:\\Documents and Settings\\marizion_2\\Local Settings\\Temporary Internet Files\\Content.IE5\\4HQ3K1I3\\dns[1].htm":
    continue
    #print "%s\n" % temp
    count += 1
    os.remove(temp)
    print "%d files deleted" % count
    time.sleep(30)
    if __name__ == "__main__":
    deltemps()
    raise SystemExit
    ]

    but sometimes when i use the program it keeps telling me "acess denied, cannot delete" a certain file even though i was running the program from an account with administrator privilages , so i added a specific test for that file as u can see in the code but after it happened for other files too. so how do i get acess for my program?

    thanks in advance
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Maybe the program is being used by another process? For instance, AIM contains files in that directory and many times that are being read from by AIM itself, thus causing you not to be able to delete them.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    180
    Rep Power
    9
    Originally Posted by †Yegg†
    Maybe the program is being used by another process? For instance, AIM contains files in that directory and many times that are being read from by AIM itself, thus causing you not to be able to delete them.


    but i do not have aim, i only have msn running on my pc, so i don't think thats the case at all. i shut down all running programs on my pc and i still got the same results so i don't think its an open file. and i can delete the files from the folder by manually deleting them and i don't get the acess denied warning so i don't know why it keeps giving me that warning with my program. do u have any other ideas
  6. #4
  7. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    I didn't say if you had AIM or not, I was using that as an example. Are there only certain files you have this problem with? Or all of them, also, have you tried restarting the pc and then running your application?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    180
    Rep Power
    9
    Originally Posted by †Yegg†
    I didn't say if you had AIM or not, I was using that as an example. Are there only certain files you have this problem with? Or all of them, also, have you tried restarting the pc and then running your application?
    ok, the files it happens with changes from time to time. i don't know if the files it keeps has problems with are virus infected. thats the whole reason i made the program, because every time i scan my pc for viruses i only find them in my temporary internet files.

    thanks for ur help anyways, i really appreciate the time, is u got anything else to say ur welcome to say it
  10. #6
  11. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Viruses are a possibility. But some kind of service or "hidden" application could also be using them for reading/writing from and to.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    11
    and if you have viruses how about getting a anti-virus that does not even allow them to go in your computer
    Those people who think they know everything are a great annoyance to those of us who do.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    180
    Rep Power
    9
    the reason i do have viruses is because i usually turn off the anti virus programs. its because i only have 128 ram and the virus protections programs usually slow down my computer, so after i'm done scanning for viruses i just turn them off, and mostly ever time i do scan i only get viruses in my temporary internet files. so i just wanna make a program to delete all the files in my temporary internet files and set it to run everytime windows starts.

    and i have another question, can i set my programs to run on startup. not through windows but through typing code into my source file. is there any functions or anything else that python offers to make my programs run at startup?
  16. #9
  17. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Originally Posted by monkeyman23555
    and if you have viruses how about getting a anti-virus that does not even allow them to go in your computer
    There's no such thing as an anti-virus program that "does not allow" viruses to get onto your pc.
  18. #10
  19. (retired)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2003
    Location
    The Laboratory
    Posts
    10,101
    Rep Power
    0
    Yes there is - it's called "Firefox".

    --Simon

    Comments on this post

    • Yegg` agrees : Go Simon!
    • andywhitt agrees : yep i agree
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    180
    Rep Power
    9
    Originally Posted by SimonGreenhill
    Yes there is - it's called "Firefox".

    --Simon
    are u answering my question about making ur program run at startup or are u talking about a virus protection program that lets viruses get into your computer?
  22. #12
  23. (retired)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2003
    Location
    The Laboratory
    Posts
    10,101
    Rep Power
    0
    No, I'm making a joke: if you used a modern web browser (NOT Internet Explorer) such as firefox, you'd avoid most of the viruses.

    Secondly, drop by the antivirus & windows forums here and get some tips on software to run which will help protect lock down those Temporary Internet Files. It's definitely time to check for spyware and viruses, since, as far as I know, those files should be deletable. When they're not, it's usually because you've got something running out of there. When you've got something running out of the temp. dir, you've usually got a virus or spyware.

    --Simon
  24. #13
  25. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    588
    Rep Power
    64

    Smile


    I would agree it is probably spyware stuff!
    I hope it's not that darn space in directory name issue! Windoze is a little wacky on that.
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    180
    Rep Power
    9
    thanks for answering my questions, but one question i have is if it is spyware wouldn't it prevent me from deleting it manually, like windows would tell me its being used or something so. i can delete it manually but my program can't.

    [/code]
    def deltemps():
    from glob import glob
    import os
    import time
    count = 0
    nd = 0
    temps = glob("C:\\Documents and Settings\\*\\Local Settings\\Temporary Internet Files\\Content.IE5\\*\\*")
    for temp in temps:

    print "(%d) %s\n" % (count,temp)

    try:
    os.remove(temp)
    count += 1
    except OSError:
    nd +=1
    temp2 = glob("C:\\Document and Settings\\*\\Local Settings\\Temp\\*")
    for temp in temp2:
    try:
    os.remove(temp)
    count += 1
    except OSError:
    nd +=1
    print "%d files deleted and %d not deleted" % (count,nd)
    time.sleep(30)
    if __name__ == "__main__":
    deltemps()
    raise SystemExit
    [/code]

    this is the python code that dosen't work, i know it looks a lil messy but i just added the code to delete the Temp folder in a rush.
  28. #15
  29. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Spyware shouldn't prevent you from deleting files. Maybe you should try using the os module's listdir() function to gather all files in a specific directory.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo