Reputation: 173
Then saving the link in C:\Users\Public\Desktop for easy access.
How do I go about doing this?
Basically the original PowerShell script will have to create a shortcut link to itself and save it in Public\Desktop folder and has to be executable in PowerShell once clicked (not open in notepad)
Any help is greatly appreciated.
Upvotes: 1
Views: 331
Reputation: 26170
you will have to run it in an elevated console :
"greetings from PS !"
$mypath=$MyInvocation.myCommand.definition
$app="%windir%\system32\WindowsPowerShell\v1.0\powershell.exe"
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("C:\Users\Public\Desktop\autogenerated.lnk")
$Shortcut.TargetPath = $app
$Shortcut.Arguments ="-noexit -file $mypath"
$Shortcut.Description ="autogenerated shortcut from ps"
$Shortcut.Save()
Upvotes: 1