-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpowershell_test.ps1
31 lines (26 loc) · 1.03 KB
/
powershell_test.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Read and parse the JSON file
$jsonFilePath = "C:\\Users\\calvi\\3D Objects\\poweruser_utilities\\powershell_test.json"
$jsonData = Get-Content -Path $jsonFilePath | ConvertFrom-Json
$targetPath = $jsonData.TargetPath
$hotkey = $jsonData.Hotkey
# $description = $jsonData.Description
# $iconLocation = $jsonData.IconLocation
$shortcutName = [System.IO.Path]::GetFileNameWithoutExtension($jsonData.TargetPath) + "_shortcut.lnk"
# Create VBScript code
$vbScript = @"
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "\\$shortcutName")
oShellLink.TargetPath = "$targetPath"
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "$hotkey"
oShellLink.Save
"@
# oShellLink.IconLocation = "$iconLocation"
# oShellLink.Description = "$description"
# oShellLink.WorkingDirectory = strDesktop
# Create temporary VBScript file and run it
$tempVbsPath = "temp.vbs"
Set-Content -Path $tempVbsPath -Value $vbScript
cscript.exe $tempVbsPath
Remove-Item $tempVbsPath