Create Shortcut With A Batch File

Status
Not open for further replies.

skrape

Beta member
Messages
2
I am trying to make a batch file that creates a shortcut to a folder. I am using Windows XP.

Am I missing something or is there no clear cut way to accomplish this?
 
I don't think you can do this with a bat file, you *might* be able to do it with a vbs file, I really hate vb and I get a headache when looking at that code so you should check out google to see if you can find some examples.

EDIT:
I found this sad piece of text, but its for VB, and not a VBS file, so you would have to do some modifiction if it will even work.

Code:
Dim WSHShell, fs

Set WSHShell = WScript.CreateObject("WScript.Shell")

Set fs = WScript.CreateObject("Scripting.FileSystemObject")

Function MakeDesktopShortcut( name, target )

Dim Shortcut,DesktopPath,StartupPath

DesktopPath = WSHShell.SpecialFolders("Desktop")

Set Shortcut = WSHShell.CreateShortcut(DesktopPath & "\" &

name & ".lnk")

Shortcut.TargetPath = target

StartupPath = fs.GetParentFolderName( target )

If fs.FolderExists( StartupPath ) then

   Shortcut.WorkingDirectory = StartupPath

End If

Shortcut.Save

End Function

MakeDesktopShortcut "Shortcut to Notepad", "C:\Windows\-Notepad.exe"
 
My only problem with using VB to accomplish this is the fact that I would have to run the project through the Package and Deployment Wizard.
After all of the dependencies are included (for people who do not have VB runtime installed), the file would be rather large. This has been my main problem with VB all along.
I am trying to make this batch file available on my website and a complete VB app would suck up too much of my bandwidth. I think if I would do this in anything else, it would be C++.
The problem with that is that most people are not going to want to d/l and run an exe. At least with batch files, you can see exactly whats going on.

Thanks for the input =)
 
YOu could always just put a link to it on in the folder for your desktop found in My Documents if you go through C:\Documents and Settings\Your user name\Desktop
 
Status
Not open for further replies.
Back
Top Bottom