[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 621
  • Last Modified:

Need help to overwrite file in vbscript

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
1 Solution
You might try to run the script with Administrative permissions (Run as Administrator).
Mike TLeading EngineerCommented:

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.

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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now