I have a folder "C:\Lumia Browser\Themes". This folder gets removed when my main application closes. I can't delete the folder while my main application is running because it's being used by my main application. So I made VBScript which deletes the folder to avoid the "
File cannot be deleted because it is being used by another process" error.
Script Code (the script is called "
ClearThemes_LBQG67BKkjhb7i.vbs") :
set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFolder("C:\Lumia Browser\Themes")
WScript.Quit
I run this script in the Form_Closed event of my main application. Only problem is that my main application process is still running, this causes an exception (used by another process blablabla same as above).
Code to start the Script:
If ClearThemesOnExit = True Then
Process.Start("C:\Lumia Browser\ClearThemes_LBQG67BKkjhb7i.vbs")
End If
It runs the script when the boolean ClearThemesOnExit is equal to True.
What I could do is instead of running the Script to delete the folder straight away, I run a script which waits until my main application has completely stopped THEN run the script to delete the folder (I could also merge the 2 scripts together instead of having 2 but that I can do easily).
The name of my main application .EXE is "Lumia Browser.exe".
I am very inexperienced with VBScript although it is very similar to VB.NET. Does anyone know how to do this?
(In summary:
Run a script which waits until my main application, "Lumia Browser.exe", has completely stopped THEN run the script, "ClearThemes_LBQG67BKkjhb7i.vbs", to delete the folder "C:\Lumia Browser\Themes")