If exists then quit VBS
Asked Answered
P

1

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.

Pacifier answered 19/12, 2013 at 15:29 Comment(1)
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).Millionaire
A
13

Try this:

If objFSO.FileExists("C:\Windows\Fonts\" & objFile.Name) Then
  WScript.Quit
End If
Atomism answered 19/12, 2013 at 15:35 Comment(1)
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 muchPacifier

© 2022 - 2024 — McMap. All rights reserved.