Hi guys, is there a way to remove a shortcut of the current logged on users desktop?
Yes, you can.
You could delete any instance of the file from just the alluser desktop, from the current user desktop, or from any user desktop as well as the alluser desktop.
Deleting a single file from a single desktop only requires a single command, but if you want to delete it from all locations, then you must use a createfile command to build a batch file that contains all of the delete commands for all of the instances that exist.
Here is an example that finds all instances of the file desktop.ini
on all desktops.
pathnames of files "desktop.ini" of folders "Desktop" of folders of folders "C:\Users"
This will get the file desktop.ini
on all currently logged in user’s desktops, even if there are multiple:
pathnames of files "desktop.ini" of folders "Desktop" of folders whose(name of it is contained by set of names of (current users; logged on users)) of folders "C:\Users"
This is how you would build the BAT file to delete all of them:
delete __createfile
delete deleteFilesDesktop.bat
createfile until END_OF_FILE
{concatenations "%0d%0a" of ("DEL /F %22" & it & "%22") of pathnames of files "desktop.ini" of folders "Desktop" of folders of folders "C:\Users"}
END_OF_FILE
move __createfile deleteFilesDesktop.bat
waithidden cmd /C deleteFilesDesktop.bat > "{(pathname of folder "__BESData\__Global\Logs" of parent folder of client)}\results_deleteFilesDesktop.bat.log"
I am using the example of desktop.ini
because it should exist on most desktops already, not because you should actually do this without cause.
Related:
Perfect, thats exactly what I needed.
I’m curious, which of the above options was exactly what you needed?
Hi jgstew,
I used the below as relevance to find a shortcut on logged on users desktops:
pathnames of files "desktop.ini" of folders "Desktop" of folders whose(name of it is contained by set of names of (current users; logged on users)) of folders "C:\Users"
I used the below to remove the shortcut from current logged on users desktops:
delete __createfile
delete deleteFilesDesktop.bat
createfile until END_OF_FILE
{concatenations "%0d%0a" of ("DEL /F %22" & it & "%22") of pathnames of files "desktop.ini" of folders "Desktop" of folders of folders "C:\Users"}
END_OF_FILE
move __createfile deleteFilesDesktop.bat
waithidden cmd /C deleteFilesDesktop.bat > "{(pathname of folder "__BESData\__Global\Logs" of parent folder of client)}\results_deleteFilesDesktop.bat.log"
…
So did it work?