8

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.

freginold
  • 3,946
  • 3
  • 13
  • 28
user3119717
  • 81
  • 1
  • 1
  • 2
  • 2
    Where in that code did you use `WScript.Quit`? Please show the full code you used as well as the exact error you got (error number, message, line number). – Ansgar Wiechers Dec 19 '13 at 15:40

1 Answers1

13

Try this:

If objFSO.FileExists("C:\Windows\Fonts\" & objFile.Name) Then
  WScript.Quit
End If
aphoria
  • 19,796
  • 7
  • 64
  • 73
  • Thank You, I had a littler more tweaking to do but eventually managed to get the script to execute properly. The only drawback is that if it for example I have 5 fonts (A,B,C,D,E) if B already existing then font A will be installed the the script terminates at B, before C, D and E. But in reality as it's a new font this scenario is very unlikey to happen. Thanks agains ever so much – user3119717 Dec 20 '13 at 13:22