Need help to overwrite file in vbscript

Posted on 2014-08-07
Last Modified: 2014-09-05
Hello Experts -

I am trying to install additional fonts for windows 7 users via a vbscript.  The problem is that I want to overwrite the existing font if it exists.  With the code below, it will prompt to overwrite if the file is existing.  Is there a way to just overwrite without prompting ?   thanks...

Here is the code :

Option Explicit
' Installing multiple Fonts in Windows 7
Dim objShell, objFSO, wshShell
Dim strFontSourcePath, objFolder, objFont, objNameSpace, objFile
Set objShell = CreateObject("Shell.Application")
Set wshShell = CreateObject("WScript.Shell")
Set objFSO = createobject("Scripting.Filesystemobject")
Wscript.Echo "--------------------------------------"
Wscript.Echo " Install Fonts "
Wscript.Echo "--------------------------------------"
Wscript.Echo " "
strFontSourcePath = "\\servername\sharefolder\stdfonts\"
If objFSO.FolderExists(strFontSourcePath) Then
Set objNameSpace = objShell.Namespace(strFontSourcePath)
Set objFolder = objFSO.getFolder(strFontSourcePath)
For Each objFile In objFolder.files
    If LCase(right(objFile,4)) = ".ttf" OR LCase(right(objFile,4)) = ".otf" Then
                    Set objFont = objNameSpace.ParseName(objFile.Name)
            Wscript.Echo "Installed Font: " & objFile.Name
            Set objFont = Nothing
        End If
        Wscript.Echo "Font Source Path does not exists"
    End If
Question by:polshek
    LVL 11

    Accepted Solution

    You might try to run the script with Administrative permissions (Run as Administrator).
    LVL 16

    Expert Comment

    by:Mike T

    The website with the same script including the grammatical error ("does not exists") is here:

    has a comment from the author to run as admin.

    LVL 44

    Expert Comment

    by:Martin Liss
    This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Join & Write a Comment

    The purpose of this article is to demonstrate how we can use conditional statements using Python.
    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    The viewer will learn how to implement Singleton Design Pattern in Java.
    The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now