Login | |
|
 |
RE: Script to copy a shortcut to all users and overwrit... - 11/18/2005 7:05:31 AM
|
|
 |
|
| |
kracksmith
Posts: 198
Score: 0
Joined: 2/24/2005
From:
Status: offline
|
I have done a script exactly what you need and it works perfectly. I put this script under user instead of computer. i'm sure it'll work both ways. This script will delete the shortcut you don't want on the user's desktop and will create a new shortcut which you want from a certain location in the server to their desktop Option Explicit Dim oFS, oWsh, oNetwork, strUser, Shell Dim DesktopPath, link Dim folder, file, icon1, icon2, icon3, icon4, icon5 Set oWsh = CreateObject("WScript.Shell") set oFS = WScript.CreateObject("Scripting.FileSystemObject") Set oNetwork= CreateObject("Wscript.Network") Set Shell = CreateObject("WScript.Shell") strUser = oNetwork.UserName DesktopPath = Shell.SpecialFolders("Desktop") Set link = Shell.CreateShortcut(DesktopPath & "\Phone List.lnk") 'the new shortcut name link.TargetPath = "\\Prod2\N_Drive\Public\Phone List Update\PHONELIST.XLS" ' the location where you store the file on the server link.Save icon1 = UCase(oWsh.SpecialFolders("Desktop") & "\PHONELIST.XLS.lnk") 'these are the ones i wanted to delete icon2 = UCase(oWsh.SpecialFolders("Desktop") & "\Shortcut to PHONELIST.lnk") 'these are the ones i wanted to delete icon3 = UCase(oWsh.SpecialFolders("Desktop") & "\PHONELIST.lnk") 'these are the ones i wanted to delete icon4 = UCase(oWsh.SpecialFolders("Desktop") & "\BLA PHONE LIST.XLS.lnk") 'these are the ones i wanted to delete icon5 = UCase(oWsh.SpecialFolders("Desktop") & "\PHONELIST.XLS") 'these are the ones i wanted to delete Set folder = oFS.GetFolder(DesktopPath) For Each file In folder.Files Select Case UCase(file) Case icon1 oFS.DeleteFile(file) Case icon2 oFS.DeleteFile(file) Case icon3 oFS.DeleteFile(file) Case icon4 oFS.DeleteFile(file) Case icon5 oFS.DeleteFile(file) Case Else End Select Next WScript.Quit (0)
|
|
| |
|
|
|
 |
RE: Script to copy a shortcut to all users and overwrit... - 11/20/2005 7:15:02 AM
|
|
 |
|
| |
Snipah
Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
|
Woodzter, KrackSmith's example is what you need, only you need to tweak some... Example: ShortcutPath = "C:\Documents and Settings\All Users\" 'delete the old shortcut, you could add a FileExist() just in case a user doesn't have the old shortcut objFSO.DeleteFile(ShortcutPath & "Desktop\Phone List.lnk") objFSO.DeleteFile(ShortcutPath & "Start Menu\Programs\Phone List.lnk") 'store the new shortcut Set ProgramsLink = Shell.CreateShortcut(ShortcutPath & "Start Menu\Programs\Phone List.lnk") ProgramsLink.TargetPath = "\\Prod2\N_Drive\Public\Phone List Update\PHONELIST.XLS" ProgramsLink.Save Set DesktopLink = Shell.CreateShortcut(ShortcutPath & "Desktop\Phone List.lnk") DesktopLink.TargetPath = "\\Prod2\N_Drive\Public\Phone List Update\PHONELIST.XLS" DesktopLink.Save
< Message edited by Snipah -- 11/20/2005 7:16:11 AM >
_____________________________
For more information, please see the "Read me First" topic. http://www.visualbasicscript.com
|
|
| |
|
|
|
 |
RE: Script to copy a shortcut to all users and overwrit... - 11/20/2005 10:28:49 PM
|
|
 |
|
| |
Snipah
Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
|
quote:
objFSO.DeleteFile(ShortcutPath & "Desktop\Phone List.lnk") This line DELETES the current shortcut
_____________________________
For more information, please see the "Read me First" topic. http://www.visualbasicscript.com
|
|
| |
|
|
|
 |
RE: Script to copy a shortcut to all users and overwrit... - 11/21/2005 6:33:40 AM
|
|
 |
|
| |
Snipah
Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
|
Is he saying he wants a shortcut to a shortcut?
_____________________________
For more information, please see the "Read me First" topic. http://www.visualbasicscript.com
|
|
| |
|
|
|
 |
RE: Script to copy a shortcut to all users and overwrit... - 11/23/2005 1:57:08 AM
|
|
 |
|
| |
Country73
Posts: 712
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
|
Something like this should work out for you- If Fso.FileExists("\\" & strComputer & "\c$\Documents and Settings\All Users\Desktop\shortcut.lnk")Then Fso.DeleteFile "\\" & strComputer & "\c$\Documents and Settings\All Users\Desktop\shortcut.lnk" Fso.CopyFile "\\" & strServer & "\Share\Location_of_Shortcut\shortcut.lnk", "\\" & strComputer & "\c$\Documents and Settings\All Users\Desktop\" End If Or you could just use this which will overwrite the shortcut if it is found Fso.CopyFile "\\" & strServer & "\Share\Location_of_Shortcut\shortcut.lnk", "\\" & strComputer & "\c$\Documents and Settings\All Users\Desktop\",True
< Message edited by Country73 -- 11/23/2005 2:11:02 AM >
|
|
| |
|
|
|
|
|