Sign in to follow this  
Followers 0
mdwerne

FileDelete...not deleting?

8 posts in this topic

Can anyone see why this might not work? I get the message "The file was not deleted" so I believe it's finding the file.

This is on a Vista machine, but the script will eventually run under Vista or XP.

Dim $SettingsLiveUpdate = "C:\Documents And Settings\All Users\Application Data\Symantec\LiveUpdate\Settings.LiveUpdate"

If FileExists($SettingsLiveUpdate) Then
    FileDelete($SettingsLiveUpdate)
    If FileExists($SettingsLiveUpdate) Then
        MsgBox(0, "Not Deleted", "The file was not deleted.")
    Else
        MsgBox(0, "Deleted", "The file was deleted.")
    EndIf
Else
    MsgBox(0, "Please locate", "Please locate and delete the file 'Settings.LiveUpdate'.")
EndIf

Thanks for any suggestions,

-Mike

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try with

#RequireAdmin

on top of the script. Maybe Vista doesn't allow the operation (UAC?)

Edited by Inverted

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Try with

#RequireAdmin

on top of the script. Maybe Vista doesn't allow the operation (UAC?)

Nope...didn't help.

I keep looking at my assignment of $SettingsLiveUpdate and keep thinking I am assigning the whole path into the variable, not just the file name.

And UAC is disabled.

Edited by mdwerne

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

The help file says : "Some file attributes can make the deletion impossible."

What are the file's attributes ?

Also, try FileRecycle, just for giggles :D

Edited by Inverted

Share this post


Link to post
Share on other sites

The help file says : "Some file attributes can make the deletion impossible."

What are the file's attributes ?

Also, try FileRecycle, just for giggles :D

Cupie doll to Inverted!

There were three issues:

1) The "real" vista path was different, variable was going through a shortcut. I added more code.

2) You were right, file was read only. I thought because I could delete it by hand that it wasn't. Dumb on my part.

3) Because it was read only, filedelete did not work, but FileRecycle DID!!

Here is the final:

#RequireAdmin
If @OSVersion = "WIN_XP" Then
    $SettingsLiveUpdate = "C:\Documents And Settings\All Users\Application Data\Symantec\LiveUpdate\Settings.LiveUpdate"
ElseIf @OSVersion = "WIN_Vista" Then
    $SettingsLiveUpdate = "C:\ProgramData\Symantec\LiveUpdate\Settings.LiveUpdate"
Else
    MsgBox(0, "Error", "Unsupported OS")
    Exit
EndIf
If FileExists($SettingsLiveUpdate) Then
    FileRecycle($SettingsLiveUpdate)
    If FileExists($SettingsLiveUpdate) Then
        MsgBox(0, "Not Deleted", "The file was not deleted.")
    Else
        MsgBox(0, "Deleted", "The file was deleted.")
    EndIf
Else
    MsgBox(0, "Please locate", "Please locate and delete the file 'Settings.LiveUpdate'.")
EndIf

Thanks for the tips!!! My bad for not reading the helpfile more closely. :-(

-Mike

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

It gets even better, you can use directory macros (check help file!)

So, it will work everywhere without hardcoded full paths :-)

@AppDataCommonDir should be the one for "All Users"

EDIT: There are other OSes beside XP and Vista, your OS check is brutal ! :D

Edited by Inverted

Share this post


Link to post
Share on other sites

EDIT: There are other OSes beside XP and Vista, your OS check is brutal ! :D

Not only OSes. Also there are other languages. (eg German :D )

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

You're right ProgAndy, also windows can be installed on other drives, other than C: :D

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  
Followers 0