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

x
  • 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)
            objFont.InvokeVerb("Install")
            Wscript.Echo "Installed Font: " & objFile.Name
            Set objFont = Nothing
        End If
    Next
    Else
        Wscript.Echo "Font Source Path does not exists"
    End If
0
polshek
Asked:
polshek
1 Solution
 
zalazarCommented:
You might try to run the script with Administrative permissions (Run as Administrator).
0
 
Mike TLeading EngineerCommented:
Hi,

The website with the same script including the grammatical error ("does not exists") is here:
http://www.cloudtec.ch/blog/tech/install-font-command-line-script-windows-7.html

has a comment from the author to run as admin.

Mike
0
 
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.
0

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