7 Replies Latest reply on Aug 20, 2008 1:50 PM by keos

    Remove Files on Devices






      Anyone know a quick way to remove a file from devices?  An distributed program is creating a setup icon on the user's desktop.  I need a way to remove this icon.  Some system have this icon on multiple users.



      Thank you



        • 1. Re: Remove Files on Devices
          MarXtar ITSMMVPGroup


          Simplest way I can think to do this would be to create a batch file and set it to run under the current user's context.  That way, you can set it to delete using the %userprofile% variable to point to the right location.  The difficulty comes where you say there are multiple users with this icon on their desktop so either this will need to be applied as a policy to all users so it runs when the the user logs on, or you will need to get fancy with something like a vbscript that can look into all of the desktops on the machine to find it.






          Mark Star - http://www.marxtar.com



          Home of Power State Notifier & Wake-On-WAN for LANDesk



          • 2. Re: Remove Files on Devices


            Thanks for the response, I have been working on a program that will check for the files/icons.  The difficulty is getting it to execute locally, with local environment variables.  This has been the difficult part.  Everytime I display the username or the logged on user's DESKTOP, the program always displays either "All users" or "Default User".  It does not indicate the logged on user.  This is caused by the Core Server launching the program remotely on the client's computer (I believe).  So the environment variables of the CORE Server are being passed with the program.



            Any other suggestions?



            • 3. Re: Remove Files on Devices
              MarXtar ITSMMVPGroup


              Under normal circumstances, anything launched by LANDesk will run on the client as localsystem.  If you set the package properties for a batch file as per the screenshot (8.8 version) you can run it as the logged on user and therefore the environment variables should be available.





              Mark Star - http://www.marxtar.com



              Home of Power State Notifier & Wake-On-WAN for LANDesk



              • 4. Re: Remove Files on Devices
                ahe Expert


                If you use LANDesk 8.7, take a look here: Running Commands as the Logged on User Using StartAsUser.exe







                • 5. Re: Remove Files on Devices


                  I forgot to mention that I'm using LDMS 8.8, not SP1



                  Local account would be ok, but the computers are not logged on.  These machines range from 5 minutes away while some are 50 Minutes drive away.  Logon is not an options as these machines since they are all over the region.  Software distribution, especially this package seems to not want to install if the computer is at the logon screen.  Have any of you encountered this problem?



                  • 6. Re: Remove Files on Devices
                    Jared Barneck SupportEmployee

                    There is one easy way to do this:


                    Delete the file from everywhere. I wrote this batch file below a while back for this purpose.  There is a lot more to deleting a file than you think and this batch file has lots of comments explaining this: 

                    REM Start of batch file
                    REM This batch file is used to demonstrate how an if command can
                    REM be used within a batch file
                    REM Change to C: drive
                    cd c:\
                    REM If a task has file locked kill it.  
                    REM Uncomment and modify the line below.
                    REM taskkill /IM somprocess.exe
                    REM If the file is read only, change its attributes
                    REM Uncomment and modify the line below.
                    REM attrib /S -R somefile.exe somefile1.exe somefile2.exe
                    REM Delete all files with a certain name in any subfolder of C:
                    REM The 2>&1 passes stderror to stdout so it will be logged.
                    del /s /q somefile.exe somefile1.exe somefile2.exe 2>&1
                    REM The “del” command always gives a successful result unless
                    REM the switches are wrong.  So the only way to see if the file was
                    REM deleted is to look on the client in the log file called
                    REM c:\program files\LANDesk ldclient\data\sdclient_task##.log
                    REM End of batch file.


                    If you want to delete the file from only one user's folder in Documents and Settings, that is easy for one single machine but it is going to be difficult to create a script that works on lots of machines and a different user on each machine.  You have to know which user on each computer.  You could use the LANDesk inventory to see who the Primary Owner is and pass the primary owner database value to the batch file.


                    But you said you want the icon gone everywhere, so just delete it everywhere.

                    1 of 1 people found this helpful
                    • 7. Re: Remove Files on Devices


                      Thank you all for your suggestions.



                      I ended up writing an Autoit script/program to search every folder under the Documents and  Settings and remove the link.  Both (original installed program and autoit program) are distribution packages, the install program being the main package, and the script is the final package.  The original program is a SWD and the later is an executable.  Both program ran using localsystem account, this ensure that it will execute even if the computer is at the logon screen.  This method worked...