Tech Support Guy banner
Status
Not open for further replies.
1 - 4 of 4 Posts

·
Registered
Joined
·
3 Posts
Discussion Starter · #1 ·
Hi,I tend to do the following alot:
Create multiple folders, give them specific names
open the folders, fill them with shortcuts to programs
change the names of the shortcuts
change the icons of the shortcuts

So I am wandering, is it possible to create a script to do the above?

1.) create several folders, give them different names
2.) fill the folders with shortcuts to programs having the correct names and icons
 

·
Registered
Joined
·
4,916 Posts
Copy the code below into a text file and rename the .txt extension to .vbs

Just change the "Create Folder Path" (line 2) to reflect where you want the destination folder to be created. Also change the Save Path and Link name in line 4 as well as the Target path of your application in line 5. Save the file and then double click to execute. You will need to refresh your desktop or directory by clicking F5 in order to show the newly created folder. In my example below I copied the file MSConfig.exe to the root of my C: drive and then used the script to create a shortcut to it inside the folder "Test" on my desktop. I'm not sure how to change the icons via code so maybe someone else could help out ??

Code:
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateFolder("C:\Documents and Settings\euza116\Desktop\Test")
Set objShell = WScript.CreateObject("WScript.Shell")
Set objShortCut = objShell.CreateShortcut("C:\Documents and Settings\euza116\Desktop\Test\Your_Link_Name.lnk")
objShortCut.TargetPath = "C:\MSConfig.exe"
objShortCut.Description = "Shortcut_to_ MSConfig"
objShortCut.Save
Here is the same code in VBA Just change the path names to reflect the correct application and save paths. You can add this code to a module within MS Word or Excel or other MS Office Application.

Code:
Public Sub CreateDirectory()

Set objShell = CreateObject("WScript.Shell")
MkDir ("C:\Documents and Settings\euza116\Desktop\Test")
Set objLink = objShell.CreateShortcut("C:\Documents and Settings\euza116\Desktop\Test\Your_Link_Name.lnk")
objLink.TargetPath = "C:\MSConfig.exe"
objLink.WindowStyle = 1
objLink.Description = "MSConfig_Shortcut"
objLink.Save

End Sub
Regards,
Rollin
 

·
Registered
Joined
·
3 Posts
Discussion Starter · #3 ·
Thank you very much, Rollin the code worked like a charm on the first run.

For .exe programs the correct icons are there, but I have .bat files I have to change icons on manually so now I will just sitt back and wait for the answer to the icon problem.

I am very satisfied, thanks again.
 
1 - 4 of 4 Posts
Status
Not open for further replies.
Top