Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • Martureo
    Post count: 5
    in reply to: Install Font #2545

    Hi Gang,

    Thought i would recreate this thread as it pertains to both the install and uninstall of multiple font files via Shell ComObject Method.

    CONS : however there has been known issues where using Shell methods like this, fail to work on Remote and Build Agents because SHELL is not accessable when using those agents to execute your powershell script at : Avoid Using SHELL when using Remote or Build Agents

    I hope this code helps – I obtained the majority of this code at : Install Fonts via Command Line

    ## Add or Remove Font Files - only tested with TTF font files thus far
        # ADD or REMOVE MULTIPLE FONT FILES [Using ComObjects]
        # This code will install or uninstall a font using ComObject
        # You Must Modify the following variables in order to work
        # (A) $dirFiles                ==&gt;  This is the source folder path that contains all of your font files
        # (B) $InstallOrUninstall      ==&gt;  $true = Install Font ...  $false = UnInstall Font
            # Define Working Variables
                #$dirFiles = &quot;C:\Temp\Fonts&quot;
                $InstallOrUninstall = $true  # $true = Install  ...or...  $false = UnInstall
                $srcFontFiles = Get-ChildItem &quot;$($dirFiles)\Fonts&quot;
                $Fonts = (New-Object -ComObject Shell.Application).Namespace(0x14)
            # Copy each file into the Font Folder or Delete it - Depends on the $InstallOrUninstall variable setting
                ForEach($srcFontFile in $srcFontFiles) 
                    $srcFontFileName = $
                    $srcFontFileFullPath = $srcFontFile.fullname
                    $targFonts = &quot;C:\Windows\Fonts\$($srcFontFileName)&quot;
                    If ((Test-Path $targFonts -PathType any) -and ($InstallOrUninstall -eq $false)) { Remove-Item $targFonts -Recurse -Force } # UnInstall Font
                    If ((-not(Test-Path $targFonts -PathType container)) -and ($InstallOrUninstall -eq $true)) { $fonts.CopyHere($srcFontFileFullPath, 16) } # Install Font
    • This reply was modified 1 month ago by  Martureo.
  • Martureo
    Post count: 5


    Not sure what the specifics are but here are a few random possibilities …
    1. make sure source EXE is local and test the installation via CMD.EXE (elevated permissions)
    2. The vendors media could be the culprit and does NOT support it
    3. If it works on Windows 10 but NOT 7 then it must be the .Net Framework or the PS version you have installed needs updated on your windows 7 system.
    4. If there is a license involved you may have reached your limit and need to Deactivate from your Win10 machine first

    Hope that helps.

    • This reply was modified 2 months ago by  Martureo.
    • This reply was modified 2 months ago by  Martureo.
    • This reply was modified 2 months ago by  Martureo. Reason: grammar corrections
  • Martureo
    Post count: 5

    yes … i used the following code:

    $p = (get-process -Name setup).Id
    $WTitle = (Get-WindowTitle -GetAllWindowTitles | Where-Object {$_.mainwindowtitle -eq $p}).WindowTitle #.ParentProcessId -eq $p}).WindowTitle  # -GetAllWindowTitles | Where-Object {$_.ParentProcessId -eq $p}).WindowTitle
    Send-Keys -WindowTitle $WTitle -Keys &#039;%n&#039;</code>

    Ineed to change the name of the window so i can wait for the new instance of the next window to occur (all windows seem to use the same parent window and i need to send keys once it is done installing and then prompts for more input. it uses the same original window name for all child windows which is why i need to change the name and wait for the new window to appear

    Im currently using the following code to get the window name and id but not sure how to change the name of the window from here

    <code># Get an Applications Process ID - the Application and its Processes can be found via the task manager
        $AppProcID = (Get-Process &#039;setup&#039;).id
    # Get an Applications Window Process ID - the Application and its Processes can be found via the task manager
        $Window = (get-process | where {$_.mainwindowtitle -match $WindowNames[2]}).id # | format-table id, name, mainwindowtitle -autosize</code>

    RECAP : i am trying to create a powershell script that will sendkeys to uninstall HaverAnalytics_DLX_4.x. The challenge and objective is to get the script to identify each child window of the uninstall, but the challenge is that they are all using the same Window name. To workaround this, i have decided to rename the windows as they appear so i can apply logic to the code to know which window\instance of the procedure requires specific sendkeys during the unisntall.

  • Martureo
    Post count: 5

    it didnt work at : $WTitle = (Get-WindowTitle -GetAllWindowTitles | Where-Object {$_.ParentProcessId -eq $p}).WindowTitle

    keep getting boolean errors

    Write-Log : Cannot process argument transformation on parameter ‘WriteHost’. Cannot convert value “” to type “System.Boolean”. Boolean parameters accept only Boolean values and numbers, such as $True, $False, 1 or 0.
    + Write-Log -Message ‘Function Start’ -Source ${CmdletName} -DebugMessage
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidData: (:) [Write-Log], ParameterBindingArgumentTransformationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Write-Log

  • Martureo
    Post count: 5

    What powershell code can be used to rename any window during and installation ?

    – i have an installer that uses the same window name for each of the 3 prompts that i am sending keys to.

    – Currently i am using the following to sendkeys to the windows that setup.exe prompts me with:

    $p=get-process | where {$ -eq &amp;quot;setup&amp;quot;}
    • This reply was modified 3 months, 4 weeks ago by  Martureo.
Viewing 5 posts - 1 through 5 (of 5 total)