Last active
May 15, 2025 14:04
-
-
Save procrastinatio/041abb4dd9617ed5b5e72ebd790643a1 to your computer and use it in GitHub Desktop.
Creating Desktop shortlink for installing GOTOP/TopGis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Script to create various shortlinks on User's Desktop to the WalletManager, Topgis Python installer and Environment changer | |
# | |
# Copy this file as a Gist on https://gist.githubusercontent.com/procrastinatio/041abb4dd9617ed5b5e72ebd790643a1/raw/gotop_install.ps1 | |
# It will be dynamically donwlaod and executed by `install_shortcuts_from_gist.ps1` | |
# | |
$username=( ( Get-WMIObject -class Win32_ComputerSystem | Select-Object -ExpandProperty username ) -split '\\' )[1] | |
## Oracle Wallet ### | |
$ShortcutPath = "\\v0t0020a.adr.admin.ch\vdiuser$\$username\config\Desktop\1-ORACLE-Walletmanager.lnk" # Path for the shortcut | |
$ScriptPath = "\\v0t0020a.adr.admin.ch\prod\swisstopoPROG\KOGIS\TOPGIS\app\OracleWalletManager\OracleWalletManager.exe" | |
$ExecutionDir = Split-Path -Parent $ScriptPath | |
$Arguments = "-ExecutionPolicy Bypass -NoExit -Command `"cd '$ExecutionDir'; & '$ScriptPath'`"" | |
$WorkingDirectory = "H:\" | |
# Create the WScript.Shell COM object | |
$WScriptShell = New-Object -ComObject WScript.Shell | |
$Shortcut = $WScriptShell.CreateShortcut($ShortcutPath) | |
# Set shortcut properties | |
$Shortcut.TargetPath = $TargetPath | |
$Shortcut.Arguments = $Arguments | |
$Shortcut.WorkingDirectory = $WorkingDirectory | |
$Shortcut.Save() | |
Write-Output "Shortcut created at: $ShortcutPath" | |
$IconPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" # Set the custom icon file path | |
# Load the WScript Shell COM object | |
$WScriptShell = New-Object -ComObject WScript.Shell | |
$Shortcut = $WScriptShell.CreateShortcut($ShortcutPath) | |
# Change the shortcut icon | |
$Shortcut.IconLocation = $IconPath | |
$Shortcut.Save() | |
Write-Output "Shortcut icon updated!"$ | |
### TOPGIS python #### | |
$ShortcutPath = "\\v0t0020a.adr.admin.ch\vdiuser$\$username\config\Desktop\2-PYTHON-topgis.lnk" # Path for the shortcut | |
$ExistingShortcut = "\\v0t0020a.adr.admin.ch\topgisprod\01_Admin\py\install_topgis_3.9.lnk" # Original shortcut | |
# Create the shortcut | |
$WScriptShell = New-Object -ComObject WScript.Shell | |
$Shortcut = $WScriptShell.CreateShortcut($ShortcutPath) | |
# Set the target to the original shortcut file | |
$Shortcut.TargetPath = $ExistingShortcut | |
$Shortcut.Save() | |
# Change the shortcut icon | |
$Shortcut.IconLocation = $IconPath | |
$Shortcut.Save() | |
Write-Output "New shortcut created at: $ShortcutPath" | |
# Install pip.ini if not alreday existing... | |
# Define the file path | |
$PipConfigPath = "$env:APPDATA\pip\pip.ini" | |
# Define the configuration content | |
$ConfigContent = @" | |
[global] | |
trusted-host = | |
pypi.python.org | |
pypi.org | |
files.pythonhosted.org | |
proxy = proxy-bvcol.admin.ch:8080 | |
"@ | |
# Check if the file exists, and create it if missing | |
if (!(Test-Path $PipConfigPath)) { | |
# Ensure the directory exists | |
New-Item -ItemType Directory -Path "$env:APPDATA\pip" -Force | |
# Write the configuration | |
$ConfigContent | Set-Content -Path $PipConfigPath -Encoding UTF8 | |
Write-Output "Created pip.ini with proxy settings." | |
} else { | |
Write-Output "pip.ini already exists at $PipConfigPath" | |
} | |
### TOGPGIS Environment changer ### | |
$ShortcutPath = "\\v0t0020a.adr.admin.ch\vdiuser$\$username\config\Desktop\3-TOPGIS-EnvironmentChanger.lnk" # Path for the shortcut | |
$TargetPath = "powershell.exe" | |
$Arguments = "-ExecutionPolicy Bypass -Command `"\\v0t0020a.adr.admin.ch\prod\swisstopoPROG\KOGIS\TOPGIS_EnvironmentChanger\Swisstopo.Topgis.EnvironmentChanger.exe - Shortcut VDI.lnk`"" | |
$WorkingDirectory = "H:\" | |
# Create the WScript.Shell COM object | |
$WScriptShell = New-Object -ComObject WScript.Shell | |
$Shortcut = $WScriptShell.CreateShortcut($ShortcutPath) | |
# Set shortcut properties | |
$Shortcut.TargetPath = $TargetPath | |
$Shortcut.Arguments = $Arguments | |
$Shortcut.WorkingDirectory = $WorkingDirectory | |
$Shortcut.Save() | |
Write-Output "Shortcut created at: $ShortcutPath" | |
$IconPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" # Set the custom icon file path | |
# Load the WScript Shell COM object | |
$WScriptShell = New-Object -ComObject WScript.Shell | |
$Shortcut = $WScriptShell.CreateShortcut($ShortcutPath) | |
# Change the shortcut icon | |
$Shortcut.IconLocation = $IconPath | |
$Shortcut.Save() | |
### GOTOP ### | |
$ShortcutPath = "\\v0t0020a.adr.admin.ch\vdiuser$\$username\config\Desktop\4-GOTOP-EnvironmentChanger.lnk" # Path for the shortcut | |
$TargetPath = "powershell.exe" | |
$ScriptPath = "\\v0t0020a.adr.admin.ch\prod\swisstopoPROG\KOGIS\GoTop\PowerShell\EnvironmentChanger\EnvironmentChanger - VDI.ps1" | |
$ExecutionDir = Split-Path -Parent $ScriptPath | |
$Arguments = "-ExecutionPolicy Bypass -Command `"cd '$ExecutionDir'; & '$ScriptPath'`"" | |
$WorkingDirectory = "H:\" | |
# Create the WScript.Shell COM object | |
$WScriptShell = New-Object -ComObject WScript.Shell | |
$Shortcut = $WScriptShell.CreateShortcut($ShortcutPath) | |
# Set shortcut properties | |
$Shortcut.TargetPath = $TargetPath | |
$Shortcut.Arguments = $Arguments | |
$Shortcut.WorkingDirectory = $WorkingDirectory | |
$Shortcut.Save() | |
Write-Output "Shortcut created at: $ShortcutPath" | |
$IconPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" # Set the custom icon file path | |
# Load the WScript Shell COM object | |
$WScriptShell = New-Object -ComObject WScript.Shell | |
$Shortcut = $WScriptShell.CreateShortcut($ShortcutPath) | |
# Change the shortcut icon | |
$Shortcut.IconLocation = $IconPath | |
$Shortcut.Save() | |
Write-Output "Shortcut icon updated!"$ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment