Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Creating and deleting shortcuts

Reply
 
Old 03-05-2009   #1 (permalink)
John


 
 

Creating and deleting shortcuts

Hi

How can I via vbscript create a link with a specific icon (world icon from
%SystemRoot%\system32\SHELL32.dll)?

How can I delete an existing link via vbscript?

Many Thanks

Regards



My System SpecsSystem Spec
Old 03-05-2009   #2 (permalink)
FNL


 
 

Re: Creating and deleting shortcuts


"John" <info@xxxxxx> wrote in message
news:ekVLewZnJHA.5048@xxxxxx
Quote:

> Hi
>
> How can I via vbscript create a link with a specific icon (world icon from
> %SystemRoot%\system32\SHELL32.dll)?
>
> How can I delete an existing link via vbscript?
>
> Many Thanks
>
> Regards
>
These examples might help:
- How to create a shortcut:
http://www.microsoft.com/technet/scr...7/hey0607.mspx
- How to change an icon:
http://www.microsoft.com/technet/scr...5/hey0812.mspx

I recommend you download the whole Scripting Guy file - it contains numerous
exteremely useful code examples.


My System SpecsSystem Spec
Old 03-05-2009   #3 (permalink)
John


 
 

Re: Creating and deleting shortcuts

Hi FNL

Many thanks for links and download. It was very useful.

I have one particular problem to which I can't seem to find the answer. I
need to change the icon of all shortcuts on desktop that start with a
particular name such as 'My App v1.0', 'My App v1.1' 'My App v1.2' etc. I
know how to change icon for one shortcut whose name is known but not when
there are a bunch of shortcuts who all start with a particular string and
the exact name is not known in advance.

Any ideas?

Thanks

Regards


"FNL" <news@xxxxxx> wrote in message
news:e0d9w1ZnJHA.3984@xxxxxx
Quote:

>
> "John" <info@xxxxxx> wrote in message
> news:ekVLewZnJHA.5048@xxxxxx
Quote:

>> Hi
>>
>> How can I via vbscript create a link with a specific icon (world icon
>> from %SystemRoot%\system32\SHELL32.dll)?
>>
>> How can I delete an existing link via vbscript?
>>
>> Many Thanks
>>
>> Regards
>>
>
> These examples might help:
> - How to create a shortcut:
> http://www.microsoft.com/technet/scr...7/hey0607.mspx
> - How to change an icon:
> http://www.microsoft.com/technet/scr...5/hey0812.mspx
>
> I recommend you download the whole Scripting Guy file - it contains
> numerous exteremely useful code examples.
>

My System SpecsSystem Spec
Old 03-05-2009   #4 (permalink)
Pegasus


 
 

Re: Creating and deleting shortcuts


"John" <info@xxxxxx> wrote in message
news:u0vpCRanJHA.1184@xxxxxx
Quote:

> Hi FNL
>
> Many thanks for links and download. It was very useful.
>
> I have one particular problem to which I can't seem to find the answer. I
> need to change the icon of all shortcuts on desktop that start with a
> particular name such as 'My App v1.0', 'My App v1.1' 'My App v1.2' etc. I
> know how to change icon for one shortcut whose name is known but not when
> there are a bunch of shortcuts who all start with a particular string and
> the exact name is not known in advance.
>
> Any ideas?
>
> Thanks
>
> Regards
I'm not aware of any wildcard or collection facility within the Desktop
namespace object. If I had to find a solution for this requirement then I
would probably use the FSO object to obtain a collection of shortcut file
names that are located in the current desktop folder, then modify the ones
that fit the wildcard description.


My System SpecsSystem Spec
Old 03-05-2009   #5 (permalink)
John


 
 

Re: Creating and deleting shortcuts

Hi

I have below code that deletes the shortcuts en mass but don't know how to
modify it to not delete but change the icons of shortcuts. Any ideas would
be appreciated.

Thanks

Regards


strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery ("Select * From Win32_ShortcutFile
Where FileName like 'My App*'")

For Each objItem in colItems
If Instr(objItem.Name, "desktop") Then
strPath = objItem.Name
strPath = Replace(strPath, "\", "\\")
Set colFiles = objWMIService.ExecQuery ("Select * From CIM_Datafile
Where Name = '" & strpath & "'")
For Each objFile in colFiles
objFile.Delete
Next
End If
Next

"Pegasus" <news@xxxxxx> wrote in message
news:egH90vbnJHA.1248@xxxxxx
Quote:

>
> "John" <info@xxxxxx> wrote in message
> news:u0vpCRanJHA.1184@xxxxxx
Quote:

>> Hi FNL
>>
>> Many thanks for links and download. It was very useful.
>>
>> I have one particular problem to which I can't seem to find the answer. I
>> need to change the icon of all shortcuts on desktop that start with a
>> particular name such as 'My App v1.0', 'My App v1.1' 'My App v1.2' etc. I
>> know how to change icon for one shortcut whose name is known but not when
>> there are a bunch of shortcuts who all start with a particular string and
>> the exact name is not known in advance.
>>
>> Any ideas?
>>
>> Thanks
>>
>> Regards
>
> I'm not aware of any wildcard or collection facility within the Desktop
> namespace object. If I had to find a solution for this requirement then I
> would probably use the FSO object to obtain a collection of shortcut file
> names that are located in the current desktop folder, then modify the ones
> that fit the wildcard description.
>

My System SpecsSystem Spec
Old 03-05-2009   #6 (permalink)
Pegasus


 
 

Re: Creating and deleting shortcuts


"John" <info@xxxxxx> wrote in message
news:%23iwdhqcnJHA.3876@xxxxxx
Quote:

> Hi
>
> I have below code that deletes the shortcuts en mass but don't know how to
> modify it to not delete but change the icons of shortcuts. Any ideas would
> be appreciated.
>
> Thanks
>
> Regards
>
>
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:\\" & strComputer &
> "\root\cimv2")
>
> Set colItems = objWMIService.ExecQuery ("Select * From Win32_ShortcutFile
> Where FileName like 'My App*'")
>
> For Each objItem in colItems
> If Instr(objItem.Name, "desktop") Then
> strPath = objItem.Name
> strPath = Replace(strPath, "\", "\\")
> Set colFiles = objWMIService.ExecQuery ("Select * From CIM_Datafile
> Where Name = '" & strpath & "'")
> For Each objFile in colFiles
> objFile.Delete
> Next
> End If
> Next
>
I do not think that you would be very happy with the above script. It uses
WMI to search the whole disk and pick the the file names that have the
string "My App" in them. It is equivalent to the command
dir c:\*.lnk /s /b | find /i "My App"
This will take a long time to execute, depending on the number of files on
your disk. Using the File System Object to enumerate only the files in your
Desktop folder would be much, much faster, about the same time as this
command:
dir /b /s "%UserProfile%\desktop\*.lnk" | find /i "My app"

I urge you to try these commands yourself. I also suggest that you state
what the overall objective of this exercise is. Picking up code fragments
from here and there without having a good understanding of what they do is
unlikely to meet your requirements.


My System SpecsSystem Spec
Old 03-11-2009   #7 (permalink)
David Glienna


 
 

Re: Creating and deleting shortcuts

Look up Powershell 2.0. It works well, as long as the framework is
installed. You can script any Net function, and access the registry like
it's a folder of files.

- David

"Pegasus" <news@xxxxxx> wrote in message
news:%23cohi5cnJHA.4912@xxxxxx
Quote:

>
> "John" <info@xxxxxx> wrote in message
> news:%23iwdhqcnJHA.3876@xxxxxx
Quote:

>> Hi
>>
>> I have below code that deletes the shortcuts en mass but don't know how
>> to modify it to not delete but change the icons of shortcuts. Any ideas
>> would be appreciated.
>>
>> Thanks
>>
>> Regards
>>
>>
>> strComputer = "."
>> Set objWMIService = GetObject("winmgmts:\\" & strComputer &
>> "\root\cimv2")
>>
>> Set colItems = objWMIService.ExecQuery ("Select * From
>> Win32_ShortcutFile Where FileName like 'My App*'")
>>
>> For Each objItem in colItems
>> If Instr(objItem.Name, "desktop") Then
>> strPath = objItem.Name
>> strPath = Replace(strPath, "\", "\\")
>> Set colFiles = objWMIService.ExecQuery ("Select * From CIM_Datafile
>> Where Name = '" & strpath & "'")
>> For Each objFile in colFiles
>> objFile.Delete
>> Next
>> End If
>> Next
>>
>
> I do not think that you would be very happy with the above script. It uses
> WMI to search the whole disk and pick the the file names that have the
> string "My App" in them. It is equivalent to the command
> dir c:\*.lnk /s /b | find /i "My App"
> This will take a long time to execute, depending on the number of files on
> your disk. Using the File System Object to enumerate only the files in
> your Desktop folder would be much, much faster, about the same time as
> this command:
> dir /b /s "%UserProfile%\desktop\*.lnk" | find /i "My app"
>
> I urge you to try these commands yourself. I also suggest that you state
> what the overall objective of this exercise is. Picking up code fragments
> from here and there without having a good understanding of what they do is
> unlikely to meet your requirements.
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
creating shortcuts PowerShell
Need help creating shortcuts VB Script
Creating desktop shortcuts Vista General
Creating shortcuts with PowerShell PowerShell
Vista Not Creating Shortcuts Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46