Forum Discussion
deploying tricky exe's
- Jan 31, 2022
Perhaps this you're overengineering 😉 What you could do is create a folder on your hard-drive c:\install. Copy all the files and directories like in your screenshot in it (Gaomon, GaomonTablet and the install.ps1.) Create another directory in c:\install, Shortcut for example, and copy shortcuts for your application in it that do work (Just create them on a system on which the applications already are installed) Adjust your install.ps1 script like this
#Copy files New-Item -Path "c:\" -Name "Gaomon" -ItemType "directory" -force Copy-Item -Path "Gaomon\*" -Destination "C:\Gaomon" -Recurse -force New-Item -Path "c:\" -Name "GaomonTablet" -ItemType "directory" -force Copy-Item -Path "GaomonTablet\*" -Destination "C:\GaomonTablet" -Recurse -force $Copy Shortcuts [system.string]$Desktop = [Environment]::GetFolderPath("Desktop") Copy-Item -path "Shortcut\Gaomon.lnk" -Destination "$($Desktop)\Gamon.lnk" Copy-Item -path "Shortcut\Gaomon.lnk" -Destination $($env:APPDATA)\Microsoft\Windows\Start Menu\Programs" Copy-Item -path "Shortcut\Gaomon Tablet.lnk" -Destination "$($Desktop)\Gamon.lnk" Copy-Item -path "Shortcut\Gaomon Tablet.lnk" -Destination $($env:APPDATA)\Microsoft\Windows\Start Menu\Programs"
Uninstall.ps1 would be something like this perhaps:
#Remove files remove-item c:\Gaomon -recurse -force remove-item c:\GaomonTablet -recurse -force [system.string]$Desktop = [Environment]::GetFolderPath("Desktop") remove-item "$($desktop\gaomon.lnk" -force remove-item "$($desktop\gaomon tablet. lnk" -force remove-item "$($env:APPDATA)\Microsoft\Windows\Start Menu\Programs\gamon.lnk" -force remove-item "$($env:APPDATA)\Microsoft\Windows\Start Menu\Programs\gamon tablet.lnk" -force
Not sure if you need shortcuts for Gaomon and Gaomon on all locations 🙂 Create a .intunewin package from your c:\install location
param (
[system.string]$ShortcutName = "GaomonTablet",
[system.string]$ShortcutUrl = "C:\GaomonTablet\GaomonTablet.exe",
[system.string]$IconURL = ".\GaomonTablet\GaomonTablet.ico",
[system.string]$Desktop = [Environment]::GetFolderPath("Desktop"),
[system.string]$IntuneProgramDir = "$env:APPDATA\Intune",
[System.String]$TempIcon = "$IntuneProgramDir\GaomonTablet.url",
[bool]$ShortcutOnDesktop = $True,
[bool]$ShortcutInStartMenu = $True
)
#Test if icon is currently present, if so delete it so we can update it
$IconPresent = Get-ChildItem -Path $Desktop | Where-Object {$_.Name -eq "$ShortcutName.lnk"}
If ($null -ne $IconPresent)
{
Remove-Item $IconPresent.VersionInfo.FileName -Force -Confirm:$False
}
$WScriptShell = New-Object -ComObject WScript.Shell
If ((Test-Path -Path $IntuneProgramDir) -eq $False)
{
New-Item -ItemType Directory $IntuneProgramDir -Force -Confirm:$False
}
#Start download of the icon in blob storage
Start-BitsTransfer -Source $IconURL -Destination $TempIcon
if ($ShortcutOnDesktop)
{
$Shortcut = $WScriptShell.CreateShortcut("$Desktop\$ShortcutName.lnk")
$Shortcut.TargetPath = $ShortcutUrl
$Shortcut.IconLocation = $TempIcon
$Shortcut.Save()
}
if ($ShortCutInStartMenu)
{
$Shortcut = $WScriptShell.CreateShortcut("$env:APPDATA\Microsoft\Windows\Start Menu\Programs\$ShortcutName.lnk")
$Shortcut.TargetPath = $ShortcutUrl
$Shortcut.IconLocation = $TempIcon
$Shortcut.Save()
}
But ideally id like this with
New-Item -Path "c:\" -Name "Gaomon" -ItemType "directory" -force
Copy-Item -Path "Gaomon\*" -Destination "C:\Gaomon" -Recurse -force
New-Item -Path "c:\" -Name "GaomonTablet" -ItemType "directory" -force
Copy-Item -Path "GaomonTablet\*" -Destination "C:\GaomonTablet" -Recurse -force
It errors out when I have them together. Any ideas on how I can combined these to scripts so it does everything together firstly create the folders then the shortcut
Perhaps this you're overengineering 😉 What you could do is create a folder on your hard-drive c:\install. Copy all the files and directories like in your screenshot in it (Gaomon, GaomonTablet and the install.ps1.) Create another directory in c:\install, Shortcut for example, and copy shortcuts for your application in it that do work (Just create them on a system on which the applications already are installed) Adjust your install.ps1 script like this
#Copy files
New-Item -Path "c:\" -Name "Gaomon" -ItemType "directory" -force
Copy-Item -Path "Gaomon\*" -Destination "C:\Gaomon" -Recurse -force
New-Item -Path "c:\" -Name "GaomonTablet" -ItemType "directory" -force
Copy-Item -Path "GaomonTablet\*" -Destination "C:\GaomonTablet" -Recurse -force
$Copy Shortcuts
[system.string]$Desktop = [Environment]::GetFolderPath("Desktop")
Copy-Item -path "Shortcut\Gaomon.lnk" -Destination "$($Desktop)\Gamon.lnk"
Copy-Item -path "Shortcut\Gaomon.lnk" -Destination $($env:APPDATA)\Microsoft\Windows\Start Menu\Programs"
Copy-Item -path "Shortcut\Gaomon Tablet.lnk" -Destination "$($Desktop)\Gamon.lnk"
Copy-Item -path "Shortcut\Gaomon Tablet.lnk" -Destination $($env:APPDATA)\Microsoft\Windows\Start Menu\Programs"
Uninstall.ps1 would be something like this perhaps:
#Remove files
remove-item c:\Gaomon -recurse -force
remove-item c:\GaomonTablet -recurse -force
[system.string]$Desktop = [Environment]::GetFolderPath("Desktop")
remove-item "$($desktop\gaomon.lnk" -force
remove-item "$($desktop\gaomon tablet. lnk" -force
remove-item "$($env:APPDATA)\Microsoft\Windows\Start Menu\Programs\gamon.lnk" -force
remove-item "$($env:APPDATA)\Microsoft\Windows\Start Menu\Programs\gamon tablet.lnk" -force
Not sure if you need shortcuts for Gaomon and Gaomon on all locations 🙂 Create a .intunewin package from your c:\install location
- Feb 05, 2022Still keeping my fingers crossed 😉
- AB21805Feb 03, 2022Bronze ContributorI have literally only just deployed jt, I will let you know! Fingers crossed aha
- Feb 03, 2022And? Did it work?
- AB21805Feb 01, 2022Bronze ContributorHa I think i am! But thank you I will try this later today and let you know thank you!