(imported topic written by 74JE_chin_oi_chong)
Is there a way to delete a file located in multiple folder.
Delete a desktop shortcut file in all the user profile desktop folder
(imported topic written by 74JE_chin_oi_chong)
Is there a way to delete a file located in multiple folder.
Delete a desktop shortcut file in all the user profile desktop folder
(imported comment written by SergioBenavides)
you need to use a perl script , convert it to an exe and add run it from your task this is the script:
###############################################################################################################################
$APPNAME = “Desktop_Shortcut_Deletion_On_Profiles” ;
$APP = “Desktop_Shortcut_Deletion_On_Profiles”;
$rootdir = $ENV{“systemroot”};
$systemdrive = $ENV{“systemdrive”}; #systemdir C:
$LOGDIR = “$rootdir\Install_logs” ;
if (!-e $LOGDIR)
{
$DIR = `mkdir $LOGDIR`;
}
open (APPNAMELOG, “>>$LOGDIR\$APPNAME.log”);
print APPNAMELOG ("\n\n###############################################################################################################################\n\n");
print APPNAMELOG ("\n\nDate Started: $TDATE\n");
$app_installed = “”;
###############################################################################################################################
#Main script
&find_slids;
&addfiles;
print APPNAMELOG (“End of script \n\n”) ;
###############################################################################################################################
sub find_ids
{
@SLIDS=dir \ /B "$systemdrive\\users"
;
print APPNAMELOG (“Slids found:\n@SLIDS\n\n”) ;
}
###############################################################################################################################
sub addfiles
{
foreach $slid (@SLIDS)
{
chomp $slid;
$appfolder = “$systemdrive\users\$slid\Desktop”;
print APPNAMELOG ("$appfolder \n");
del "$appfolder"
;
}
}
(imported comment written by sinucus)
I posted an example fixlet at
http://bigfix.me/cdb/fixlet/2550
Basically, we’re looking to see if a file exists
q: exists file “file.ext” of folders “Desktop” of folders of folder “C:\Users”
then we want to delete it.
appendfile
{("del " & pathname of it & "%0d%0a") of files "file.ext" of folders "Desktop" of folders of folder "C:\Users\"}
You could also just use the following. It does have an interesting side effect. It will only delete the FIRST file it comes across. It will not iterate, so you’d have to run the fixlet multiple times, so it isn’t ideal as it would report back as failed since the relevance would still be true.
delete
{(pathname of it & "%0d%0a") of files "file.ext" of folders "Desktop" of folders of folder "C:\Users\"}