Results 1 to 6 of 6

Thread: my program can't delete an .exe file in Win7

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2012
    Posts
    26

    my program can't delete an .exe file in Win7

    I download my program to win7 computer; my program at startup is suppose to delete the "30day trial" setup file, but I have not been able to delete(Kill) the setup file per code; works great on xp computers. I'm sure it is a file security problem, but how do I solve it programmically? Thanks for any help

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: my program can't delete an .exe file in Win7

    Where is this "30 day trial" setup file located? Is your program running as Administrator when you attempt to delete the file? Can you tell us more about what your program is trying to accomplish?



    (Note that you've posted in the wrong forum. Please let us know which programming language your app is coded so that your thread can be moved to the appropriate forum.)
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: my program can't delete an .exe file in Win7

    Thread moved from the 'CodeBank VB6' forum (which is for you to post working code examples, not questions) to the 'VB6 and earlier' forum


    I suspect it will be useful to read the article Where should I store the files that my program uses/creates? from our Classic VB FAQs (in the FAQ forum)

  4. #4
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: my program can't delete an .exe file in Win7

    your program hasn't administrator elevated privilege and the UAC is in a high level? if not, can't delete a file that is inside "program files", add a manifest for giving it administrator elevation when executing it.

    other case, is that .EXE already running?, if it is an open process you can't erase it.

    In XP the workaround was to rename it to a meaningless name, broking that way the app. In Win Vistas and later it don't let to rename an opened file.

    other case, is you trying to access to a file that don't have the correct NTFS security rights?

  5. #5
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    759

    Re: my program can't delete an .exe file in Win7

    A program installed on Windows 7 will go somewhere under C:\Program Files*.
    The installer is allowed to write to this location.
    Regular users are not and so cannot delete the file.

    It's far, far better to simply disable functionality within the program after the trial period. That way, if and when the user registers the program, they only have to enter a registration key (still within the application) and don't have to re-install the whole program again.

    Incidentally, using a manifest to force the program to run with elevated privileges is not the proper way to handle this. Unless they've chosen to install something, or clicked on a properly-"marked" control (i.e. one with the UAC shield icon on it), users should never see a U.A.C. challenge in their daily work. The whole point of U.A.C. is that it intervenes when any program tries to do something it "shouldn't" and so Windows asks the user "Is this OK?". If your users are seeing this popping up every day, then they'll get used to it, learn to ignore it and, eventually, install something that does some real damage to their machine.
    U.A.C is here to stay; learn to work with it.

    Regards, Phill W.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Feb 2012
    Posts
    26

    Re: my program can't delete an .exe file in Win7

    I appreciate all replys; I appreciate Phil comment; I may have to consider the disable function instead of deleting the whole program when the "trial" period is up... After installing my program, I really wanted to remove the "trial setup file" from the computer...


    Quote Originally Posted by Phill.W View Post
    A program installed on Windows 7 will go somewhere under C:\Program Files*.
    The installer is allowed to write to this location.
    Regular users are not and so cannot delete the file.

    It's far, far better to simply disable functionality within the program after the trial period. That way, if and when the user registers the program, they only have to enter a registration key (still within the application) and don't have to re-install the whole program again.

    Incidentally, using a manifest to force the program to run with elevated privileges is not the proper way to handle this. Unless they've chosen to install something, or clicked on a properly-"marked" control (i.e. one with the UAC shield icon on it), users should never see a U.A.C. challenge in their daily work. The whole point of U.A.C. is that it intervenes when any program tries to do something it "shouldn't" and so Windows asks the user "Is this OK?". If your users are seeing this popping up every day, then they'll get used to it, learn to ignore it and, eventually, install something that does some real damage to their machine.
    U.A.C is here to stay; learn to work with it.

    Regards, Phill W.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width