/build/static/layout/Breadcrumb_cap_w.png

Script to Delete File from Program Files...

Hi,

I have a file I need to delete in "C:\prgram files\Microsoft Office\Office11\Start Up\pwd.dot". Does anyone have a script that would do this? I have tried modifying the scripts I have had posted here before, but have been unsuccsessfull. Plus I have a time limit!

Thanks,

Mike.

0 Comments   [ + ] Show comments

Answers (2)

Posted by: Secondlaw 18 years ago
Third Degree Blue Belt
0
Is there a specific language you must use? Which language are you using?
Posted by: spartacus 18 years ago
Black Belt
0
Try this :

Const FolderName = "Microsoft Office\Office11\StartUp"

Const DeleteEvenIfReadOnly = TRUE
Const FileToDelete = "pwd.dot"

Dim oFSO, oWSH
Dim sProgramFilesFolder

' Instantiate the various objects needed by this script
'
set oFSO = CreateObject("Scripting.FileSystemObject")
set oWSH = CreateObject("Wscript.Shell")

' Find the current Program Files folder - could be on C: or D: drive for example
sProgramFilesFolder = oWSH.ExpandEnvironmentStrings("%ProgramFiles%")
sProgramFilesFolder = sProgramFilesFolder & "\"

On Error Resume Next
If oFSO.FileExists(sProgramFilesFolder & FolderName & "\" & FileToDelete) then
oFSO.DeleteFile(sProgramFilesFolder & FolderName & "\" & FileToDelete), DeleteEvenIfReadOnly
end if

set oFSO = Nothing
set oWSH = Nothing



Regards,

Spartacus
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ