CMD Examples

From ProVide DocWiki
Revision as of 09:10, 19 June 2018 by Lukas Wiberg (talk | contribs)
Jump to: navigation, search

Example 1

The script used for this example will automatically remove a file once it's downloaded from the server, the script below is written in cmd but can be done in other languages if you wish.

@echo off

set FILE=%1

//Remove quotes
for /f "useback tokens=*" %%a in ('%FILE%') do set FILE=%%~a

//remove file

exit 0

To get this script to trigger on the right time, for this example we will use it to trigger when a file is downloaded by a user it will be deleted from the server.

First we need to go on the admin interface for our ProVide server and on the first tab (Server configuration) on the far top left, we need to go to "Events and Messages" in the menu underneth whe we are on the server configuration.

In the window that pops up we can select what event we wish to put this in, for now we will go with "OnDownloadEnd" that triggers when a download is completed.

It should already have some texts in the "Message" window but we can leave that for now as it does not effect the trigger for the script. So to trigger the script from this "Message" field we need to add the following to the "Message" field.


This will make the script specified from the path in the first quotes and in the secound quotes is the full path to the file that was just downloaded.