Sumeet
Sumeet

Reputation: 925

Creating Shortcut using .Net

I would like to create a shortcut on the desktop using VBScript code. I have a virtual Drive in my computer. (Virtual Drive is like G drive) I want this shortcut to explore that Drive directly. For this I find out that Shortcut with following string as a TargetPath would work for me:

C:\WINDOWS\explorer.exe /n,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}::{89214D20-CAC1-4A33-8DF4-BD9D18A996B9}

While creating shortcut using vb script I need to enclose above string in " ", which don't work for me. I need to delete " " from the Target of the created Shortcut only then it works. Is there any way so that I can create shortcut programmatically, that can explore the virtual drive (available in my system). I need to get it in Vista OS.

Regards Sumeet Nandan Garg

Upvotes: 2

Views: 3383

Answers (2)

Sumeet
Sumeet

Reputation: 925

I am generting .lnk file programmatically now using Win32 method i.e. (IWshShortcut)shell.CreateShortcut() to create the Shortcut file. And it works like charm. Thanks.!!

Upvotes: 1

abatishchev
abatishchev

Reputation: 100268

Google gives a lot of interesting result. For example, this - with P/Invoke calls, seems to be an answer. (this is for your post tag .NET)

Here an example for VBScript:

Set shell = WScript.CreateObject("WScript.Shell")
Set link= shell.CreateShortcut("Explorer.lnk")
link.TargetPath = "c:\windows\explorer.exe"
link.Save

Upvotes: 3

Related Questions