VBScript Shortcut Manipulation
Add your rating:
I've been using this website to learn about deploying and it's been great to me. I put together a list of VBScript commands that I use to move or delete shortcuts after I install programs. It works great with WIWW by adding the script after the silent install.
' This is needed for all file manipulation
Dim filesys
Set filesys = CreateObject("Scripting.FileSystemObject")
' This is needed for accessing special folders
Set WshShell = WScript.CreateObject("WScript.Shell")
----------------
Creating Folders
----------------
dim newfolder
If Not filesys.FolderExists(wshShell.SpecialFolders("AllUsersStartMenu")&"\Programs\Internet\") Then
Set newfolder = filesys.CreateFolder(wshShell.SpecialFolders("AllUsersStartMenu")&"\Programs\Internet\")
End If
----------------
Deleting Folders
----------------
If filesys.FolderExists(wshShell.SpecialFolders("AllUsersStartMenu")&"\Programs\Alcohol") Then
filesys.DeleteFolder(wshShell.SpecialFolders("AllUsersStartMenu")&"\Programs\Alcohol")
End If
--------------
Deleting Files
--------------
If filesys.FileExists("c:\somefile.txt") Then
filesys.DeleteFile("c:\somefile.txt")
End If
------------
Moving Files
------------
If filesys.FileExists("c:\sourcefolder\anyfile.html") Then
filesys.MoveFile("c:\sourcefolder\anyfile.html", "c:\destfolder\")
End If
--------------
Moving Folders
--------------
dim mfolder
If Not filesys.FolderExists(wshShell.SpecialFolders("AllUsersStartMenu")&"\Programs\Entertainment") Then
set mfolder = filesys.GetFolder(wshShell.SpecialFolders("AllUsersStartMenu")&"\Programs\Accessories\Entertainment")
mfolder.Move (wshShell.SpecialFolders("AllUsersStartMenu")&"\Programs\Entertainment")
End If
------------------
Special folders to be used as: wshShell.SpecialFolders("AllUsersStartMenu")
The & character is used to join strings
* AllUsersDesktop
* AllUsersStartMenu
* AllUsersPrograms
* AllUsersStartup
* Desktop
* Favorites
* Fonts
* MyDocuments
* NetHood
* PrintHood
* Programs
* Recent
* SendTo
* StartMenu
* Startup
* Templates
More special folders:
http://www.activexperts.com/activmonitor/windowsmanagement/scripts/desktop/specialfolders/
--------------------
Program files folder
--------------------
' Define object for the "Program Files" folder
Const PROGRAM_FILES = &H26&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(PROGRAM_FILES)
Set objProgramFiles = objFolder.Self
' program files is referenced by: objProgramFiles.Path
---------------
Using with WIWW
---------------
After the silent install
wscript.exe scriptname.vbs //B
//B suppresses errors
0 Comments
[ + ] Show comments
Answers (3)
Please log in to answer
Posted by:
bbrian
17 years ago
Posted by:
jmcfadyen
17 years ago

so that the conversation will remain readable.