Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Create Shortcut (VB, VB.Net, PowerShell)

Posted on December 14, 2013December 10, 2019 By David Kittell
Sub Create_ShortCut(ByVal TargetPath As String, ByVal ShortCutPath As String, ByVal ShortCutname As String, Optional ByVal WorkPath As String = "", Optional ByVal Window_Style As Short = 0, Optional ByVal IconNum As Short = 0)
        Dim VbsObj As Object
        VbsObj = CreateObject("WScript.Shell")
        Dim MyShortcut As Object

        ShortCutPath = ShortCutPath

        MyShortcut = VbsObj.CreateShortcut(ShortCutPath & "" & ShortCutname & ".lnk")

        MyShortcut.TargetPath = TargetPath

        MyShortcut.WorkingDirectory = WorkPath

        MyShortcut.WindowStyle = Window_Style

        MyShortcut.IconLocation = TargetPath & "," & IconNum

        MyShortcut.Save()
    End Sub
Try
                Call Create_ShortCut("c:windowssystem32explorer.exe", System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "", "Windows Explorer", , , )
            Catch ex As Exception
            End Try
# Create a Log Off shortcut
$AppLocation = "C:\Windows\system32\Shutdown.exe"
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$env:Public\Desktop\Log Off.lnk")
$Shortcut.TargetPath = $AppLocation
$Shortcut.Arguments ="-L"
$Shortcut.IconLocation = "%SystemRoot%\System32\shell32.dll,44"
$Shortcut.Description ="Log out of Windows"
$Shortcut.WorkingDirectory ="C:\Windows\System32"
$Shortcut.Save()

# Create PowerShell ISE shortcut
$AppLocation = "%windir%\system32\WindowsPowerShell\v1.0\PowerShell_ISE.exe"
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$env:Public\Desktop\PowerShell ISE.lnk")
$Shortcut.TargetPath = $AppLocation
#$Shortcut.Arguments ="-L"
$Shortcut.IconLocation = "$AppLocation,0"
$Shortcut.Description ="Load PowerShell ISE"
$Shortcut.WorkingDirectory ="%HOMEDRIVE%%HOMEPATH%"
$Shortcut.Save()

# Create TaskScheduler shortcut
$AppLocation = "%windir%\system32\taskschd.msc"
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$env:Public\Desktop\Task Scheduler.lnk")
$Shortcut.TargetPath = $AppLocation
$Shortcut.Arguments ="/s"
$Shortcut.IconLocation = "%windir%\system32\miguiresource.dll,1"
$Shortcut.Description ="Load Task Scheduler"
#$Shortcut.WorkingDirectory ="%HOMEDRIVE%%HOMEPATH%"
$Shortcut.Save()
Originally Posted on December 14, 2013
Last Updated on December 10, 2019
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code PowerShell VB VB.NET Windows

Post navigation

Previous post
Next post

Related Posts

File Name Converter

Posted on July 18, 2013October 26, 2015

<% @LANGUAGE = VBSCRIPT %> <%Option Explicit%> <% ‘ File Name Move and Converter ‘ Written by Cristiano Guglielmetti: guglielmetti@tin.it ‘ Dec.2001 ‘ This script moves and renames files into a webserver from a dir to another dir ‘ especially designed for large numbers of pictures files Response.Write "<html>" &…

Read More

Prevent Browser Cache

Posted on August 21, 2013October 26, 2015

Response.Expires = 0 Response.Expiresabsolute = Now() – 1 Response.AddHeader "pragma","no-cache" Response.AddHeader "cache-control","private" Response.CacheControl = "no-cache" <cfheader name="expires" value="#now()#"> <cfheader name="pragma" value="no-cache"> <cfheader name="cache-control" value="no-cache, no-store, must-revalidate"> <meta http-equiv="expires" content="Mon, 06 Jan 1990 00:00:01 GMT"> <% response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 response.setHeader("Pragma","no-cache"); //HTTP 1.0 response.setDateHeader ("Expires", 0); //prevents caching at the proxy server…

Read More

Directory Listing

Posted on May 20, 2014October 26, 2015

dir *.pdf /O:N /b > filelist.txt Originally Posted on May 20, 2014Last Updated on October 26, 2015 All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes