markg85 Posted August 13, 2005 Share Posted August 13, 2005 Hello,I have made a pritty big unattended windows installation whitch is installing some programs after windows has been installed.. but now the problem is that some programs leve shortcuts on the desktop and i would like to know how to remove those shortcuts automaticly..i have searched here but i couldn`t find it.. Link to comment Share on other sites More sharing options...
tharkhold Posted August 13, 2005 Share Posted August 13, 2005 Something like:DEL "%AllUsersProfile%\Desktop\Mozilla Firefox.lnk"DEL "%systemdrive%\Documents and Settings\Administrator\Desktop\Mozilla Firefox.lnk"DEL "%AllUsersProfile%\Start Menu\Programs\Adobe Reader 7.0.lnk"DEL "%systemdrive%\Documents and Settings\Administrator\Start Menu\Programs\Adobe Reader 7.0.lnk"DEL "%AllUsersProfile%\Desktop\Internet Explorer.lnk"DEL "%systemdrive%\Documents and Settings\Administrator\Desktop\Internet Explorer.lnk"in "cleanup.cmd" should do the trick for icons and shortcuts. Link to comment Share on other sites More sharing options...
markg85 Posted August 13, 2005 Author Share Posted August 13, 2005 (edited) gonna try that out now thanx for the fast replyhmm.. got a quicker command DEL "%AllUsersProfile%\Desktop\*.lnk"DEL "%systemdrive%\Documents and Settings\Administrator\Desktop\*.lnk"i`m not 100% sure if it works.. things like that should work in linux and since windows is just taking things from anywhere those code CAN work i well post it here if it worked or not. Edited August 13, 2005 by markg85 Link to comment Share on other sites More sharing options...
Yzöwl Posted August 13, 2005 Share Posted August 13, 2005 Even better, use this!just run the exe…noshtcut.zip Link to comment Share on other sites More sharing options...
markg85 Posted August 13, 2005 Author Share Posted August 13, 2005 that`s nice to one problem... i don`t thrust files that can be even less than 1 KB but are 100+ KB ;)your file is a bit to big for my taste lol (to big for what it needs to do)but thanx anyway Link to comment Share on other sites More sharing options...
Yzöwl Posted August 13, 2005 Share Posted August 13, 2005 (edited) What a shame then…The batch file was actually 153 bytes before I compiled it too!and tidied up, fully working, it weighs in at 97 bytesYour example, wouldn't work for a large proportion of the readers here and is still 109 bytes in size. Tidied up, and still not as accurate as mine weighs in at 160 bytesIF EXIST "%AllUsersProfile%\Desktop\*.lnk" DEL /Q "%AllUsersProfile%\Desktop\*.lnk"IF EXIST "%UserProfile%\Desktop\*.lnk" DEL /Q "%UserProfile%\Desktop\*.lnk"<Edit>Remember size doesn't matter, but if a 146Kb executable which will run without a window, and does exactly what you want it to do, doesn't fit on your installation media, you should have been a little clearer in your question.</Edit> Edited August 13, 2005 by Yzöwl Link to comment Share on other sites More sharing options...
markg85 Posted August 13, 2005 Author Share Posted August 13, 2005 (edited) you executable is exactly what i want (if it`s working) but i just have alot of BAD experience with small executable`s whitch contained VIRUS files whitch infected my eentire hdd!! (was a few years ago but i lost everything) that1s why i`m just carefull with the small executables andi tested the executable and it isn`t working.. all shortcuts are still on my desktop.. and that are alot of shortcuts lol edit::..IF EXIST "%AllUsersProfile%\Desktop\*.lnk" DEL /Q "%AllUsersProfile%\Desktop\*.lnk"IF EXIST "%UserProfile%\Desktop\*.lnk" DEL /Q "%UserProfile%\Desktop\*.lnk"that also isn`t working Edited August 13, 2005 by markg85 Link to comment Share on other sites More sharing options...
BoardBabe Posted August 13, 2005 Share Posted August 13, 2005 (edited) What language is your OS in?Try check properties of a shortcut on your desktop and past us the complete path for it please.Running a Norwegian XP, this is what works perfect to remove all shortcuts from desktop (called skrivebord in Norwegian)del /s /q "%UserProfile%\Skrivebord\*.lnk"del /s /q "%AllUsersProfile%\Skrivebord\*.lnk" Edited August 13, 2005 by BoardBabe Link to comment Share on other sites More sharing options...
Yzöwl Posted August 13, 2005 Share Posted August 13, 2005 (edited) Copy & Paste these four commands one at a time in the order given into the Start » Run box and hit Ok after each.cmd /c dir /b/a-d %userprofile%\Desktop>%Temp%\_Dsk.txtcmd /c echo/- - - - - - - - - - - - - - ->>%Temp%\_Dsk.txtcmd /c dir /b/a-d %allusersprofile%\Desktop>>%Temp%\_Dsk.txt%Temp%\_Dsk.txtThen paste the file which opens between code tags into a reply here!<Edit>When you've done it, and after closing your Text Editor application, you can enter this to remove the filedel /q %Temp%\_Dsk.txtNoteAs suggested by BoardBabe, if your OS is not in a language which is compatible with the commands, you will have to change them to suit.</Edit> Edited August 13, 2005 by Yzöwl Link to comment Share on other sites More sharing options...
markg85 Posted August 14, 2005 Author Share Posted August 14, 2005 found the problem a desktop is the english word for Bureaublad whitch is dutch i don`t even have a desktop folder @Yzöwl can you adjust you little program so that you can do that in the run command.. for example: noshtcut.exe /Bureaublad (for the dutch users) and this way tour script will work in any languageanyway.. removing .lnk files is working now Link to comment Share on other sites More sharing options...
Yzöwl Posted August 20, 2005 Share Posted August 20, 2005 (edited) If you were to use wsh and vbs you could probably perform the task regardless of OS language.NoLinx.vbsConst ALL_DESKTOP = &H19&Const CUR_DESKTOP = &H10&Set objShell = CreateObject("Shell.Application")Set objAllDskFldItem = objShell.Namespace(ALL_DESKTOP).SelfSet objCurDskFldItem = objShell.Namespace(CUR_DESKTOP).SelfSet objShell = WScript.CreateObject("WScript.Shell")Set objFileSystem = CreateObject("Scripting.FileSystemObject")strAllDskFld = objAllDskFldItem.PathstrCurDskFld = objCurDskFldItem.PathOn Error Resume NextobjFileSystem.DeleteFile(strAllDskFld & "\*.lnk")objFileSystem.DeleteFile(strCurDskFld & "\*.lnk")<Edit>AddedOn Error Resume Nextprevents failure if either %AllUsersProfile% or %UserProfile% locations do not contain a .lnk file.</Edit> Edited August 20, 2005 by Yzöwl Link to comment Share on other sites More sharing options...
gunsmokingman Posted August 20, 2005 Share Posted August 20, 2005 (edited) Here is a vbs script that uses WMI to search for shortcuts then it deletes them. Save As RemoveSC.VbsNote I made this on Vista and it took out all the shortcuts on that, plus it removed all the shortcuts on the XP that is install on the same Computer. Plus It Removed The Shortcuts I Had In My Ua CD, Use Care With This OneDeletes All Shortcut On Local Computer Dim Act, Fso, UP, StrComputer Set Act = CreateObject("Wscript.shell") Set Fso = CreateObject("Scripting.FileSystemObject") StrComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colFiles = objWMIService.ExecQuery _ ("Select * from CIM_DataFile Where Extension = 'lnk'") If colFiles.Count = 0 Then Act.Popup "No Shortcuts Where Found", 5, "Nothing Found", 0 + 32 WScript.quit End If '''' IF SHORTCUTS ARE FOUND For Each objFile in colFiles TheFile = objFile.Drive & objFile.Path & objFile.FileName & "." & objFile.Extension If Fso.FileExists(TheFile) Then On Error Resume Next Fso.DeleteFile(TheFile) End If NextAct.Popup "Completed The Script", 5, "Finish Script", 0 + 48Removes ShortCuts On Systemdrive In AUP and UP Dim Act, AUP, Fso, UP, StrComputer Set Act = CreateObject("Wscript.shell") Set Fso = CreateObject("Scripting.FileSystemObject") AUP = Act.ExpandEnvironmentStrings("%ALLUSERSPROFILE%\Desktop") UP = Act.ExpandEnvironmentStrings("%UserProfile%\Desktop") StrComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colFiles = objWMIService.ExecQuery _ ("Select * from CIM_DataFile Where Extension = 'lnk'") If colFiles.Count = 0 Then Act.Popup "No Shortcuts Where Found", 5, "Nothing Found", 0 + 32 WScript.quit End If '''' IF SHORTCUTS ARE FOUND For Each objFile in colFiles File = objFile.FileName & "." & objFile.Extension TheFile = objFile.Drive & objFile.Path & objFile.FileName & "." & objFile.Extension If Fso.FileExists(AUP & "\" & File) Then If Fso.FileExists(TheFile) Then Fso.DeleteFile(TheFile) Act.Popup "Deleting This Shortcut" & vbCrLf & TheFile, 3, "Gsm Remove Shortcuts", 0 + 48 End If End If If Fso.FileExists(UP & "\" & File) Then If Fso.FileExists(TheFile) Then Fso.DeleteFile(TheFile) Act.Popup "Deleting This Shortcut" & vbCrLf & TheFile, 3, "Gsm Remove Shortcuts", 0 + 48 End If End If Next Act.Popup "Completed The Script", 5, "Finish Script", 0 + 48Tested and worked 100% on my computer.Hey, Scripting Guy! The Place Where I Go To Learn About VBS ScriptsBasic Error Control Save As DemoErrorControl.vbs ''''Demo 1 Dim Act, Fso, SD Set Act = CreateObject("Wscript.shell") Set Fso = CreateObject("Scripting.FileSystemObject") SD = Act.ExpandEnvironmentStrings("%SystemDrive%") If Fso.FileExists(SD & "\Windows\Explorer.exe") Then msgbox "Explorer.Exe Exists", 0 + 32, "Demo File Exists" Else Act.Popup "Explorer.exe Is Missing", 5, "Missing File", 0 + 64 End If ''''Demo 2 If Not Fso.FileExists(SD & "\Windows\Explorer.ZZY") Then msgbox "Explorer.ZZY Does Not ExistExists", 0 + 32, "DemoNot Exists" Set Ts = Fso.CreateTextFile("MissingTest.txt", 2, True) Ts.WriteLine Space(5) & "The Time Is " & Time() Ts.close Act.Run("MissingTest.txt"),1,true Fso.DeleteFile("MissingTest.txt") Else Act.Popup "The File Exists", 5, "File Is There", 0 + 48 End If Edited August 20, 2005 by gunsmokingman Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now