VBscript copy and replace file, prompt if locked
Hi
I want some help with a script that copys and replacec a file i an location, and if the file is locked becourse its beeing used, a prompt will appear telling the user to close the program, and when the user closes the program and presses ok, the script will copy and replace the file.
Thank you
I want some help with a script that copys and replacec a file i an location, and if the file is locked becourse its beeing used, a prompt will appear telling the user to close the program, and when the user closes the program and presses ok, the script will copy and replace the file.
Thank you
0 Comments
[ + ] Show comments
Answers (3)
Please log in to answer
Posted by:
Bula
12 years ago
Hi,
You can try to use this.
ON error resume next
Function DeleteFIle ()
ON error resume next
file1 = "c:\temp\1.msi"
file2 = "c:\temp\2.msi" 'destination filee
Set fso = CreateObject("Scripting.FileSystemObject")
Set plik = fso.GetFile(file1)
plik.Copy file2 'copy file to destination folder
If Err.Number <> 0 Then
WScript.Echo "Please close program"
Err.Clear
wscript.sleep 5000 'time in ms
result = DeleteFIle()
else
WScript.Echo "File was repleced"
end if
End function
result = DeleteFIle()
msgbox "THX"
You can try to use this.
ON error resume next
Function DeleteFIle ()
ON error resume next
file1 = "c:\temp\1.msi"
file2 = "c:\temp\2.msi" 'destination filee
Set fso = CreateObject("Scripting.FileSystemObject")
Set plik = fso.GetFile(file1)
plik.Copy file2 'copy file to destination folder
If Err.Number <> 0 Then
WScript.Echo "Please close program"
Err.Clear
wscript.sleep 5000 'time in ms
result = DeleteFIle()
else
WScript.Echo "File was repleced"
end if
End function
result = DeleteFIle()
msgbox "THX"
Posted by:
andys0123
12 years ago
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.