Deleting a simple shortcut from the desktop

I’m having a helluva time deleting a simple shortcut (.lnk file) from users desktops. What am I doing wrong?

This is the command I’m using: delete “c:\users%username%\desktop\file to be deleted.lnk”

Help, Bigfix family, I need you! Thanks.


Delete is a BigFix actionscript command that does not understand environment variables. Even if it did, %username% is a user environment variable and BigFix runs as system. For this reason it will not work when using BigFix.

Your best bet will be to write a batch or powershell script which iterates through the user profiles and removes the files and then run that batch or powershell script with BigFix.

Here is an example of doing this with Batch:

Try This Action Script:

createfile until EOD
del C:\Users%username%\IBM_ADMIN\Desktop\filename.lnk"
move __createfile shortcut_delete.bat
waithidden shortcut_delete.bat

This has a couple issues - you have unbalanced parenthesis and no slash before username and IBM_ADMIN is probably from another script. To fix the example:

createfile until EOD
del "C:\Users\%username%\Desktop\filename.lnk"

move __createfile shortcut_delete.bat

waithidden shortcut_delete.bat

The challenge with this is that BigFix does not run the action as the user, it runs it as the user account the BESClient runs under – NT Authority\System. When running as NT Authority\System, the %username% environment variable is not the current user and nor is it NT Authority\System, suprisingly, it’s the network name of the computer computername$.

This means that when you run an action with the BigFix agent is going to report as the computer name:

So this will render in the batch script as:
del “C:\Users\ComputerName$\Desktop\filename.lnk”

Which won’t work – so you either need to override the action to run as the current user which will only delete the file after the user has logged in, or you need to recursively search the user’s directories for the file and remove it in an action like in the fixlet I linked in my message above:

1 Like