Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If exists then quit VBS

Tags:

wsh

vbscript

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.

like image 241
user3119717 Avatar asked Dec 19 '13 15:12

user3119717


People also ask

How do you exit a while loop in VBScript?

Using Do While or Do Until allows you to stop execution of the loop using Exit Do instead of using trickery with your loop condition to maintain the While ... Wend syntax. I would recommend using that instead.

What is WScript quit?

Syntax: WScript.Quit ([lngExitCode]) lngExitCode. Receives the code to be returned by the program upon exit. The Quit method causes the current script to terminate and return the specified exit code.

What is WScript echo?

Echo. The Echo method displays parameters in a window (in Wscript.exe) or in a Command Prompt window (in Cscript.exe). Parameters are delimited by one space. Under Cscript.exe, this method outputs a carriage-return/line feed pair (CR LF) after the last parameter displayed.


1 Answers

Try this:

If objFSO.FileExists("C:\Windows\Fonts\" & objFile.Name) Then
  WScript.Quit
End If
like image 176
aphoria Avatar answered Nov 22 '22 06:11

aphoria