Click here to Skip to main content
Click here to Skip to main content

ShellLinkCreator

, 12 May 2008
Rate this:
Please Sign up or sign in to vote.
A utility to create multiple shell shortcuts from C#

Introduction

This is a utility that allows you to create multiple shell shortcuts at a time. All you need to do is configure what ever you need in a simple text file and execute the exe.

Background

In our normal day to day work we find many useful tools. But we need to go here and there to execute them. Wouldn't it be nice to have all of them at a single place? This can be accomplished in windows OS, just by right clicking and "send to desktop as a shortcut". Then you can copy/cut paste the shortcut at a place you want. But what if your tools list grows and what if you change your harddisk or system? You have to do all that exercise again. Here is a simple tool that will allow you to do just that work.

This is completely written in C# and uses windows shell RunTime Callable wrapper generated by Visual Studio. The attached code is Visual Studio 2005 solution.

Here is the ScreenShot

screenshot.JPG

Using the Tool

The tool is named - ShellLinkCreator

The shortcuts file name - ShortCuts.txt (please do not rename this, its hardcoded in code)

Editing this shortcuts file is simple.

All lines that start with '#' are comments and the actual lines has the format:

Actual solution or folder path(relative or absolute) , ShortCutName , Description , Working Folder , Folder in which to create the shortcut .

Here is the shortcuts file.

# All the paths can be either relative or absolute
# Lines starting with "#" are comments.
# on each separate line put the file or even folder for which you want to create the shortcut
# each line is one shortcut, options splitted with comma
# Format :: 
# Actual solution or folder path(relative or absolute) , ShortCutName , Description , Working Folder , Folder in which to create the shortcut
# 3rd , 4th and 5th parameters are optional. If the 5th parameter ,  the Folder in which to create the shortcut does not exist ,  it will be created
# If any line has only 1 parameter that will be taken up as a common output path to create the shortcuts.
# so to eliminate any confusion, give the common output folder path as first line.

.\My_Windows_ShortCuts  
%WINDIR%\System32\cmd.exe, cmd.exe, command prompt,.,.\My_Windows_ShortCuts\System32
%VS80COMNTOOLS%\errlook.exe, errorlookup.exe, Native error lokkup,%VS80COMNTOOLS%
%VS80COMNTOOLS%\spyxx.exe, spy++.exe, Windows SPY++, %VS80COMNTOOLS%
%VS80COMNTOOLS%\bin\depends.exe, depends.exe, Native dependency walker, %VS80COMNTOOLS%\bin
%VS80COMNTOOLS%\bin\guidgen.exe, GUIDGen.exe, GUID Generator
         

Actual code to create shortcut

// Here is the C# code

using IWshRuntimeLibrary;   
 
 
WshShell aShell = new WshShellClass(); 
IWshShortcut aShortCut = (IWshShortcut)aShell.CreateShortcut (shortcutPath);
aShortCut.TargetPath = ActualPath; 
aShortCut.Description = Description; // optional 
aShortCut.WorkingDirectory = Working Directory; // optional
aShortCut.Save();  
 

Points of Interest

This tool can be used in Test Automation where it is required to create the shortcuts. Also this can be useful to the developers who has many solutions or files to work with.


History

This is my first submission to code project.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

AnandChavali
Web Developer
India India
Hi,
I am Anand, a senior software developer from Bangalore, India. I have 3+ years of programming experience in C,C++,VC++,eVC++,MFC,ATL,COM,C++/CLI,.NET,C# and a bit VB,ASP and WML. I am mostly interested in VC++,C++/CLI. My hobbies are programming, playing chess.

Comments and Discussions

 
GeneralSome years ago... PinmemberADLER113-May-08 8:32 
GeneralPlease give feedback here.... PinmemberAnandChavali13-May-08 2:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140709.1 | Last Updated 13 May 2008
Article Copyright 2008 by AnandChavali
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid