If exists then quit VBS

user3119717 picture user3119717 · Dec 19, 2013 · Viewed 40.4k times · Source

Please take this script into context with my question:

If objFSO.FileExists("C:\Windows\Fonts\" & objFile.Name) Then
Wscript.Echo "Font already installed: " & objFile.Name

I want a VBS script to quit/exit/terminate if X file already exists. Currently, it will instead give a message box saying "Font Already Installed" as expected.

If I remove the Echo I instead get a blank box, where I still have to hit OK.

I want the script to just automatically end if X already exists with 0 user input.

Is this possible? I have wscript.quit and wscript.exit but just get errors.

The full script can be found here:
http://www.cloudtec.ch/blog/tech/install-font-command-line-script-windows-7.html

So again, in context, I want XYZ fonts to install. If they're already installed I want the script to just simply terminate without the need to hit OK. The intention is to deploy fonts accross a network.

Answer

aphoria picture aphoria · Dec 19, 2013

Try this:

If objFSO.FileExists("C:\Windows\Fonts\" & objFile.Name) Then
  WScript.Quit
End If