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.
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)
Please log in to answer
Posted by:
Secondlaw
17 years ago
Posted by:
spartacus
17 years ago
Try this :
Regards,
Spartacus
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.
so that the conversation will remain readable.