Client Management Suite

 View Only
  • 1.  Script to delete file from logged on user profile

    Posted Apr 03, 2013 12:03 PM

    I'm trying to create a task which will delete an exe file from the logged on users desktop so far I have not been able to do this on a windows 7 machine from within Altiris 7.1 sp2 to a machine. I have tested the script directly on the machine from a CMD window and it works fine  but it won't work from the quick run option from the Task Status window. The script I have is as follows: Del "%homepath%\Desktop\Elior Signature-v2.9.exe"

    If I put a pause line in it states: Could Not Find C:\Windows\system\Signature-v2.9.exe

    Am I using the wrong variable for the logged on user? I can't find an answer to this although I'm sure it'll be simple in the end any help is greatly appreciated as always. thanks



  • 2.  RE: Script to delete file from logged on user profile

    Posted Apr 03, 2013 12:39 PM

    You need to run the script in the context of the logged on user, by default it will run in the context the Agent runs in, the Local System account.



  • 3.  RE: Script to delete file from logged on user profile

    Posted Apr 04, 2013 04:19 AM

    Thanks for the response I hadn't thought about that, is there a way of running this script from a task which will reference the logged on user account?

     



  • 4.  RE: Script to delete file from logged on user profile
    Best Answer

    Posted Apr 04, 2013 05:54 AM

    First of all you may try something like %systemdrive%%homepath% instead of %homepath% only, because %homepath% will return \Users\UserLogin without letter drive.

    And for your task you must set Run As parameter to 'Current logged-on user' (under 'Advanced...' button at Run Script task edit page). It will look like this:

    asusertask.PNG



  • 5.  RE: Script to delete file from logged on user profile

    Posted Apr 04, 2013 06:55 AM

    Just to clarify, i have managed to get this to work now using: Del "%homepath%\Desktop\Elior Signature-v2.9.exe"
     and using the advanced option to Run As Current logged-on User as above

    Thanks guys for steering me in the right direction.



  • 6.  RE: Script to delete file from logged on user profile

    Posted Apr 04, 2013 06:57 AM

    resolved by using:Del "%homepath%\Desktop\Elior Signature-v2.9.exe"
     

    Then choosing the Run as option logged on user in advanced setting of the task.