Link to home
Start Free TrialLog in
Avatar of SP3CLt
SP3CLtFlag for United States of America

asked on

VBS or Batch File - Delete Desktop Shortcuts

Hello, I need help with a script - looking to remove certain shortcuts from user profiles. The script will be ran remotley. The script works great when ran locally, not when ran via altiris as the system account.
Option Explicit 
Dim oFS 
Dim oWsh 
Dim oNetwork 
Dim strUser 
Set oWsh = CreateObject("WScript.Shell") 
set oFS = WScript.CreateObject("Scripting.FileSystemObject") 
Set oNetwork= CreateObject("Wscript.Network") 
strUser = oNetwork.username 
Dim icon1 
icon1 = oWsh.SpecialFolders("Desktop") & "\CTI Softphone.lnk" 
Dim icon2 
icon2 = oWsh.SpecialFolders("Desktop") & "\Shortcut CTI Softphone.lnk" 
Dim icon3 
icon3 = oWsh.SpecialFolders("Desktop") & "\Agent Desktop.lnk" 
Dim icon4 
icon4 = oWsh.SpecialFolders("Desktop") & "\Shortcut to Agent Desktop.lnk" 
Dim icon5 
icon5 = oWsh.SpecialFolders("Desktop") & "\CTI Agent Desktop.lnk" 
IF (oFS.FileExists(icon1)) then 
   oFS.deletefile (icon1) 
End if 
IF (oFS.FileExists(icon2)) then 
   oFS.deletefile (icon2) 
End if 
IF (oFS.FileExists(icon3)) then 
   oFS.deletefile (icon3) 
End if 
IF (oFS.FileExists(icon4)) then 
   oFS.deletefile (icon4) 
End if 
IF (oFS.FileExists(icon5)) then 
   oFS.deletefile (icon5) 
End if 
Set oFS = Nothing 
WScript.Quit (0)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Shift-3
Shift-3
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SP3CLt

ASKER

Works perfectly! Thank you so much Shift-3.
I changed pause to exit, to move onto the next script in the update batch.
 
 

@echo off
setlocal
 
set files="CTI Softphone.lnk" "Shortcut CTI Softphone.lnk" "Agent Desktop.lnk" "Shortcut to Agent Desktop.lnk" "CTI Agent Desktop.lnk"
 
for %%G in (%files%) do del /f /s /q "%allusersprofile%\..\%%~G"
 
exit

Open in new window

Avatar of SP3CLt

ASKER

Shift-3 is a genius..