Skip to content

Instantly share code, notes, and snippets.

@kpatnayakuni
Last active January 23, 2019 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kpatnayakuni/395dda9fabcdd5170a1a01aedce5e5b4 to your computer and use it in GitHub Desktop.
Save kpatnayakuni/395dda9fabcdd5170a1a01aedce5e5b4 to your computer and use it in GitHub Desktop.
# Enter your ps script name including path
# And launch application to the script file at the end of the code
# Start-Process -FilePath <yourapplication.exe>
$ScriptFile = 'yourpsfileincludingpath.ps1'
$ShortcutFile = "$Home\Desktop\" + (Get-ChildItem -Path $ScriptFile).BaseName + '.lnk'
$PowerShellPath = "$env:SystemRoot\system32\WindowsPowerShell\v1.0\powershell.exe"
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $PowerShellPath
$Shortcut.Arguments = "-File $ScriptFile"
$Shortcut.Save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment