Script install fonts powershell -


I have a script that installs fonts, after checking that fonts exist or not. However, I'm having trouble validating the existence of the font.

  $ font = 0x14; $ Pathpath = "c: \ fonts"; $ ObjShell = New Object - Com Object Shell Application; $ ObjFolder = $ ObjShell.Namespace ($ FONTS); $ CopyOptions = 4 + 16; $ Copyflag = [string] :: format ("{0: x}", $ CopyOptions); Foreign exchange ($ $ in file (Get-ChildItem -Path $ FromPath)) {if ((test-path "c: \ windows \ fonts \ $ $ $ $. $ $ $ $ $ $ $ $ $ $ $ $ $ ") CopyFlag = [string] :: format (" {0: x} ", $ CopyOptions); $ ObjFolder.Copyhere ($ File.fullname, $ CopyOptions); New item property -name $ file. Full name-path "HKLM: \ software \ Microsoft \ Windows NT \ CurrentVersion \" font-type property- value $ $ file}}  

If your statement is incorrect

  if ((test path "c: \ windows \ fonts \ $ $ File.name)") -X $ wrong)  

test path ritter If the file exists and if it is not, the file does not exist in case you have false -eq false = True so nothing is executed. To copy the item, your code is already present if it is called.

Solution:

  if (test path "c: \ windows \ fonts \ $ $ $ .name)")  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -