PowerShell Scripts to remake Links · KcsDev1982/sunbelt-plb-samples@baf19b2 · GitHub
Skip to content

Commit baf19b2

Browse files
committed
PowerShell Scripts to remake Links
PowerShell scripts to remake the install links
1 parent 07472b9 commit baf19b2

3 files changed

Lines changed: 123 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions

‎install_helper/makeonelink.ps1‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#
2+
# $Product --> "Visual PLB 10.8"
3+
# $ShortcutName --> "Visual PLB"
4+
# $Workingdir --> "c:\Sunbelt\plbwin.108\code"
5+
# $Target --> "c:\Sunbelt\plbwin.108\code\plbwin.exe"
6+
# $Plcarg --> " -h c:\Sunbelt\plbwin.108\code\watch.plc"
7+
# $Showlog --> "on" optional
8+
#
9+
# .\makeonelink.ps1 "Visual PLB 10.8" "Visual PLB" "c:\Sunbelt\plbwinX.108\code" "c:\Sunbelt\plbwin.108\code\plbwin.exe"
10+
# .\makeonelink.ps1 "Visual PLB 10.8" "Visual PLB" "c:\Sunbelt\plbwinX.108\code" "c:\Sunbelt\plbwin.108\code\plbwin.exe" " -h c:\Sunbelt\plbwin.108\code\watch.plc"
11+
#
12+
# Test Command line Sample:
13+
#
14+
# $Product --> "Visual PLB 10.8"
15+
# $ShortcutName --> "Test_Notepad"
16+
# $Workingdir --> "C:\Windows\System32"
17+
# $Target --> "notepad.exe"
18+
# $Plcarg --> empty/not used
19+
# $Showlog --> "on" optional
20+
#
21+
# .\makeonelink.ps1 "Visual PLB 10.8" "Test_Notepad" "C:\Windows\System32" "notepad.exe"
22+
#
23+
param ( $Product, $ShortcutName, $Workingdir, $Target, $Plcarg, $Showlog )
24+
25+
# Create WScript.Shell COM object
26+
$WshShell = New-Object -ComObject WScript.Shell
27+
28+
#
29+
# Show Input parameters
30+
#
31+
if ( $Showlog -eq "on" ) {
32+
Write-Host "*****************************"
33+
Write-Host "Product: '$Product'"
34+
Write-Host "ShortcutName: '$ShortcutName'"
35+
Write-Host "Workingdir: '$Workingdir'"
36+
Write-Host "Target: '$Target'"
37+
Write-Host "Plcarg: '$Plcarg'"
38+
Write-Host "Showlog: '$Showlog'"
39+
}
40+
41+
# Make Desktop Directory
42+
#
43+
$Path = "$env:USERPROFILE\Desktop\$Product"
44+
if ( Test-Path $Path -PathType Container ) {
45+
if ( $Showlog -eq "on" ) {
46+
Write-Host "Directory exist: '$Path'!"
47+
}
48+
} else {
49+
mkdir $Path
50+
if ( $Showlog -eq "on" ) {
51+
Write-Host "Created Directory '$Path'!"
52+
}
53+
}
54+
55+
# Define the shortcut path
56+
$ShortcutPath = "$env:USERPROFILE\Desktop\$Product\$ShortcutName.lnk"
57+
58+
# Create the shortcut object
59+
$Shortcut = $WshShell.CreateShortcut($ShortcutPath)
60+
61+
# Set the target path (the program or file to run)
62+
$Shortcut.TargetPath = "$Target"
63+
$Shortcut.Arguments = "$Plcarg"
64+
65+
# (Optional) Set other shortcut properties
66+
$Shortcut.WorkingDirectory = "$Workingdir"
67+
$Shortcut.WindowStyle = 1 # 1 = Normal, 3 = Maximized, 7 = Minimized
68+
$Shortcut.Description = "Launch '$ShortcutName'"
69+
$Shortcut.IconLocation = "$Target,0"
70+
71+
# Save the shortcut to the desktop
72+
$Shortcut.Save()
73+
#
74+
# End
75+
#
Lines changed: 47 additions & 0 deletions

0 commit comments

Comments
 (0)