ps1 font install script not working

BatchPatch Forums Home Forums BatchPatch Support Forum ps1 font install script not working

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #8941
    deepfriedbutter
    Participant

    I can run this script locally on the box and it works fine, but it does not work when I run it through batchpatch. It does not work through deployment, remote command or remote command logged. It just exits with code 0 and that’s it, so it appears to work, but it does not. Please help!

    Thanks in advance

    $FONTS = 0x14

    # Set path to the fonts dir
    $FromPath="\nasserverDocumentsbatchpatchfonts_2017"

    $objShell = New-Object -ComObject Shell.Application
    $objFolder = $objShell.Namespace($FONTS)

    $CopyOptions = 4 + 16
    $CopyFlag = [String]::Format("{0:x}", $CopyOptions)

    #loop through each directory in the specified path looking for files with extensions starting with .tt or .o
    foreach($File in $(Get-ChildItem -Path $FromPath -Include *.ttf,*.otf,*.fon,*.fnt -Recurse)) {
    If (test-path "c:windowsfonts$($File.name)")
    # {"$File already exists - not copying"} #Useful for testing
    {}
    Else
    {
    $CopyFlag = [String]::Format("{0:x}", $CopyOptions)
    # "copying $($file.fullname)" # Useful for debugging

    #installs fonts found in above loop to the Fonts directory
    $objFolder.CopyHere($File.fullname, $CopyOptions)

    New-ItemProperty -Name $File.fullname -Path "HKLM:SoftwareMicrosoftWindows NTCurrentVersionFonts" -PropertyType string -Value $File

    }
    }

    #10400
    doug
    Moderator

    I would suggest a few things to try:

    1. Change the ‘remote execution context’ to ‘Elevated token’ and then try again and see if it works.

    BatchPatch Remote Execution Context

    2. Change the \nasserver path in the script to a local/relative path instead of one that reaches out to a remote server. If your script is made to *not* access a remote path and instead is made to access the files locally (locally on the target computer), I suspect it will work.

    Deploying a Script with Relative Instead of Absolute Paths

    3. Follow the tutorial linked below that explains another way to deploy fonts:

    Remotely Install OpenType (.otf) or TrueType (.ttf) Fonts

    Please report back and let us know what you try and what works for you.

    Thanks,

    Doug

    #10401
    deepfriedbutter
    Participant

    1. I’ve tried this and it does not help – the script doesn’t seem to run at all. no fonts are copied.

    2. Will try.

    3. The problem with this method is I have 100 servers and 88 fonts. I started with this method but it doesn’t scale well.

    Thanks so much for your help!

    #10402
    deepfriedbutter
    Participant

    2. worked!

    I did a file copy of the whole folder with the fonts then changed the path to the local path with the ps1 script inside the fonts folder. I believe this is a better method of installing fonts rather than creating a manual entry for each one.

    consider me a happy camper!

    thank you!!

    #10403
    doug
    Moderator

    Excellent. Thanks for following up. I’m glad that 2 worked. I also understand that 3 does not scale well. I’ll ask the team to re-work the script so that it can be used for any number of fonts without having to fill in so much code.

    -Doug

    #13364
    deepfriedbutter
    Participant

    Hi Doug,

    Do we have any updates here?

    Thanks!

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.