Skip to main content

 

Hello,

I'm trying to create a worklet to deploy LanguageTool on my Windows x64 fleet. However, in the feedback, it says that the installation went well but ultimately fails. Can you help me fix the code?

Evaluation Code
 

#########################################
# --! Evaluate Compliance !--
if (Get-Win32App | Where-Object { $_.Name -eq $appName }) {
    Write-Output "$appName is already installed. Now exiting."
    exit 0
}

# Si LanguageTool n'est pas détecté, le worklet déclenchera l'installation
else {
    Write-Output "$appName was not detected."
    installLanguageTool -AppName $appName -AppInstallerType $appInstallerType -AppURL $appURL -IsSilent
}


Remediation Code
 

# Set temporary folder path
$tempFolderPath = Join-Path -Path $env:TEMP -ChildPath "automox"
Write-Output "Creating temporary folder at $tempFolderPath"
New-Item -ItemType Directory -Force -Path $tempFolderPath | Out-Null

# Download Language Tool setup executable
$url = "https://languagetool.org/download/windows-app/LanguageTool-latest.exe"
$destinationPath = Join-Path -Path $tempFolderPath -ChildPath "$($url.Split('/')u-1])"
Write-Output "Downloading LanguageTool setup executable from $url to $destinationPath"
Invoke-WebRequest -Uri $url -OutFile $destinationPath

# Install Language Tool using the silent installation switch (/S)
Write-Output "Installing LanguageTool silently"
Start-Process -FilePath $destinationPath -ArgumentList "/S", "-dir", "%APPDATA%\LanguageTool\" -Wait

# Remove the temporary files
Write-Output "Removing temporary files from $tempFolderPath"
Remove-Item -Recurse -Force -Path $tempFolderPath

 

 

Thanks in advance,

 

Doomer

HI! I just ran into the same issue. However, I was able to install it on workstations by changing the start-process to start-processasactiveuser command from the wdk

I used your code, I just changed that one command 

I also changed the temp folder path to C:\windows\temp\automox

 

$tempFolderPath = Join-Path -Path "C:\Windows\Temp" -ChildPath "automox"
Write-Output "Creating temporary folder at $tempFolderPath"
New-Item -ItemType Directory -Force -Path $tempFolderPath | Out-Null

# Download Language Tool setup executable
$url = "https://languagetool.org/download/windows-app/LanguageTool-latest.exe"
$destinationPath = Join-Path -Path $tempFolderPath -ChildPath "$($url.Split('/')'-1])"
Write-Output "Downloading LanguageTool setup executable from $url to $destinationPath"
Invoke-WebRequest -Uri $url -OutFile $destinationPath

# Install Language Tool using the silent installation switch (/S)
Write-Output "Installing LanguageTool silently"
Start-ProcessAsActiveUser -Path $destinationPath -ArgumentList "/S", "-dir", "%APPDATA%\LanguageTool\"

# Remove the temporary files
Write-Output "Removing temporary files from $tempFolderPath"
Remove-Item -Recurse -Force -Path $tempFolderPath

This was the output 

After running the worklet, I could see the program installed on my PC

 


Hello Malvarez,

Good news. 
I’m going to test now.
thank for your reply.

I publish the result just after.

 

 


I think i have a problem with the rights to install.

Error Start-ProcessAsActiveUser command. The error indicates that this command was invoked as a non-SYSTEM user, which can cause issues as certain privileges 


Do you have a screen shot of the error? I just installed it on a test PC with a non admin user and it was successful 


Hello Maalvarez,

I use your code. 

 

 

After some modification of your remediation code : 

 

#REQUIRES -Version 2.0

<#

.SYNOPSIS

This script checks if LanguageTool is installed.

.DESCRIPTION

This script checks for the presence of LanguageTool on the system.

.NOTES

File Name :LanguageTool_Install_Test.ps1

Author :Automox

Prerequisite :PowerShell V2 over Windows 7 and later

#>

# Handle Exit Codes:

trap {
$host.ui.WriteErrorLine($_.Exception);
exit 90
}

function LanguageTool_Install_Test {

<#

.SYNOPSIS

This function checks if LanguageTool is installed on the system.

.DESCRIPTION

This function queries the installed files for LanguageTool and returns a code indicating

whether it's installed or not.

.EXAMPLE

LanguageTool_Install_Test

.NOTES

#>

$languageToolInstalled = Get-ChildItem -Path "C:\Program Files" -Filter "LanguageTool-*" -Recurse | Select-Object -First 1

if ($languageToolInstalled) {
# LanguageTool found, exit with code 0.
exit 0
}
else {
# LanguageTool not found, exit with code 1.
exit 1
}

}

# Call the LanguageTool installation test function.
LanguageTool_Install_Test

and remediation code
 

#REQUIRES -Version 2.0

<#

.SYNOPSIS

This script checks if LanguageTool is installed.

.DESCRIPTION

This script checks for the presence of LanguageTool on the system.

.NOTES

File Name :LanguageTool_Install_Test.ps1

Author :Automox

Prerequisite :PowerShell V2 over Windows 7 and later

#>

# Handle Exit Codes:

trap {
$host.ui.WriteErrorLine($_.Exception);
exit 90
}

function LanguageTool_Install_Test {

<#

.SYNOPSIS

This function checks if LanguageTool is installed on the system.

.DESCRIPTION

This function queries the installed files for LanguageTool and returns a code indicating

whether it's installed or not.

.EXAMPLE

LanguageTool_Install_Test

.NOTES

#>

$languageToolInstalled = Get-ChildItem -Path "C:\Program Files" -Filter "LanguageTool-*" -Recurse | Select-Object -First 1

if ($languageToolInstalled) {
# LanguageTool found, exit with code 0.
exit 0
}
else {
# LanguageTool not found, exit with code 1.
exit 1
}

}

# Call the LanguageTool installation test function.
LanguageTool_Install_Test

I have this 

 

 

After refresh of the agent, language tool is not visible on the software installed on the machine.

Best,

Doomer


I was able to recreate your error message

Is the Automox agent running as system on your target PC? 

 


Hello Maalvarez,
I verify now and i back to you.
Doomer


Hello,
I have the good right, i dont understand why it’s not functional.
Doomer


Reply