Help with some vbs script

NEODARK

Gawd
Joined
Aug 10, 2004
Messages
1,002
Hey, could anyone give me a hand with a bit of vbs? I'm stuck with some of the logic, and haven't played with vbs is a long time. I'm trying to create a script that will do the following:

1- Check if text file exists, if so, quit.
2- If not, create text file. (So, script doesn't run next time) Then...
3- Check if directiory exists, if so, delete.
4- Run installer
5- End.

However, I'm running into some issues putting it all together, can you help? It's something like this, obviously still not correct.

Code:
On Error Resume Next

dim filetxt, getname, path

Set fso = CreateObject("Scripting.FileSystemObject")

If NOT (fso.FileExists("C:\OK.txt")) Then
	Set filetxt = filesys.CreateTextFile("C:\OK.txt", True)
	path = fso.GetAbsolutePathName("C:\OK.txt")
	getname = fso.GetFileName(path)
	filetxt.WriteLine("Script ran succesfully")
	filetxt.Close
	End If

	NEXT

	If fso.FolderExists("C:\Program Files\Application") = True Then
		fso.DeleteFolder("C:\Program Files\Application")
		End If
	
oShell.run "C:\Setup.exe -q", 1, true

End If

Thanks :D
 
also, if you want the script to quit if the file does already exist, I think you need to add a ELSE before the first End If?
Otherwise I believe it will still run the setup since there's nothing in the script to quit if the file already exists
but I could be wrong, I'm not strong in vbscript
 
Back
Top