NetXMS Support Forum

English Support => General Support => Topic started by: dersonik on April 20, 2016, 11:26:40 AM

Title: Deleting files script
Post by: dersonik on April 20, 2016, 11:26:40 AM
Is that possible to run the script from netxms to delete downloads folder (files inside downloads) in windows server 2012 ?
Title: Re: Deleting files script
Post by: Victor Kirhenshtein on April 21, 2016, 04:28:56 PM
Hi,

yes, you can define action in agent (using Action or ActionShellExec entries in nxagentd.conf) and then define object tool to run it manually or server side action of type "execute action on remote agent" to run it automatically from event processing policy.

Best regards,
Victor
Title: Re: Deleting files script
Post by: dersonik on April 22, 2016, 10:46:04 AM
Ok i'm using powershell with command:

ActionShellExec=cleandownloads:powershell -command "& ls ~\Downloads\ | remove-item -force -recurse"
and this command not working from netxms but working in powershell

i have too
ActionShellExec=cleantemp:powershell -command "& ls C:\Windows\TEMP\ | remove-item -force -recurse"
and this commands works fine form powershell and from agent


any ideas?
Title: Re: Deleting files script
Post by: Victor Kirhenshtein on April 22, 2016, 11:19:37 AM
Hi,

I'm suppose ~ in ~\Downloads\ refers to home directory of the user - but if you run agent as a service it by default runs under local system account, so ~ points to completely different place.

Best regards,
Victor