tedcbe
asked on
Script to check and install shortcuts
I need a script that will check the desktop of %allusersprofile% both on Win XP and Win 7 devices for presence of a set of shortcuts and install these shortcuts if they are not present.
I intend to deploy this script using SCCM + GPO.
Any help in this will be greatly appreciated.
I intend to deploy this script using SCCM + GPO.
Any help in this will be greatly appreciated.
Hi, this VBScript should be able to be run from SCCM.
Specify strSourceFolder as a folder where you have placed the required shortcuts (and nothing else), and the script will copy the missing shortcuts to the all users desktop.
Regards,
Rob.
Specify strSourceFolder as a folder where you have placed the required shortcuts (and nothing else), and the script will copy the missing shortcuts to the all users desktop.
Regards,
Rob.
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strAllUsersDesktop = objShell.ExpandEnvironmentStrings("%ALLUSERSPROFILE%") & "Desktop\"
strSourceFolder = "\\server\share\shortcuts"
For Each objFile In objFSO.GetFolder(strSourceFolder).Files
If objFSO.FileExists(strAllUsersDesktop & objFile.Name) = False Then
objFSO.CopyFile objFile.Path, strAllUsersDesktop, True
End If
Next
ASKER
Thanks a lot Matrixnz and RobSamson for your suggestions and apologies for getting back late.
I ended up using RobSamson's code (with the following changes)
strAllUsersDesktop = objShell.ExpandEnvironment Strings("% ALLUSERSPR OFILE%") & "\Desktop\"
I just added the \ before Desktop
I need 2 more things and i was wondering if any of you guys might be able to help
1. I need to be able to use this script both on Win XP and Win 7 devices and at the moment it does not work on Win 7 devices (in my tests). I was under the impression that %allusersprofile%\desktop should work but it did not. Is there a way of checking if this is Win Xp or Win 7 and if it is Win 7 then to add the shortcuts to "C:\Users\Public\Desktop"
2. I have also been asked to put the shortcut for Outlook and hence I need to be able to check what version of Office is installed and put the relevant Outlook shortcut in the above location
I ended up using RobSamson's code (with the following changes)
strAllUsersDesktop = objShell.ExpandEnvironment
I just added the \ before Desktop
I need 2 more things and i was wondering if any of you guys might be able to help
1. I need to be able to use this script both on Win XP and Win 7 devices and at the moment it does not work on Win 7 devices (in my tests). I was under the impression that %allusersprofile%\desktop should work but it did not. Is there a way of checking if this is Win Xp or Win 7 and if it is Win 7 then to add the shortcuts to "C:\Users\Public\Desktop"
2. I have also been asked to put the shortcut for Outlook and hence I need to be able to check what version of Office is installed and put the relevant Outlook shortcut in the above location
Its one of the reasons I use AutoIT, the code between Win XP and Win 7 is completely different.
i.e. Win 7 is generally C:\Users\Public\Desktop not C:\ProgramData\Desktop.
You could query
HKLM\Software\Microsoft\Wi ndows\Curr entVersion \Explorer\ Shell Folders\Common Desktop
Or use a ShellSpecialFolderConstant s to point to the All Users Desktop, although you may need to verify that it works on Windows XP as well.
i.e. Win 7 is generally C:\Users\Public\Desktop not C:\ProgramData\Desktop.
You could query
HKLM\Software\Microsoft\Wi
Or use a ShellSpecialFolderConstant
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you RobSampson. I will test this script today and let you know how it goes.
ASKER
Thank you RobSamson
Example:
Open in new window