WatchDirectory home page
WatchDirectory Startseite (Deutsche Version)
Site WatchDirectory (Français)
  Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
   
  HomeHelpSearchLoginRegister  
 
Page Index Toggle Pages: 1
Multi-step process (Read 5057 times)
David Hostetter
YaBB Newbies
*
Offline



Posts: 8
Multi-step process
Jul 18th, 2014 at 9:52pm
 
Hi, I am trying to create task(s) for the following:

Step 1: Encrypt a file
Step 2: Upload the encrypted file
Step 3: Rename the original file to indicate it has been encrypted and sent.

I am trying to do this in only two tasks = windows services.

First step is easy.  I have a task to detect the new file and run a batch file that encrypts it.  Encryption routine adds an additional extension to the target.

Second step is easy.  I have a task to detect the encrypted file extension and upload it.  The upload task also renames the encrypted file to *.sent.  I do not require to keep the uploaded file, I only rename it as a potential trigger for the next step.  If I could avoid this and simply delete the file after upload I would prefer that.

For the third step I am running into a challenge.

I could have a third task to detect the .sent files and then call a batch to rename the original file and delete the .sent.  And if I cannot find a better solution this is what I might do.

But I would prefer not to have three windows services to accomplish this.  At that point it seems better just to write my own script and run that as a single windows service.

I tried to do this by combining Step 2 and 3 into a sub-task task that triggers off of the encrypted file creation.  The first sub task does the upload, the next sub task ... can't run a batch file?  Huh  Or be based on an existing task that runs a batch file?  Or in some other way rename the original file which is not the current target?

A sub-task can run an executable so maybe I run the command shell as the executable and pass as a parameter the batch file to handle the renaming?  In that case I sure hope I can somehow pass the target file as a parameter.

Thoughts?  Ideas?

Thanks for a really nice system tool.  I am finding it quite useful.
Back to top
 
 
IP Logged
 
David Hostetter
YaBB Newbies
*
Offline



Posts: 8
Re: Multi-step process
Reply #1 - Jul 18th, 2014 at 10:49pm
 
I tried "start any program" as a sub-task and I think I have discovered that you cannot pass arbitrary parameters to the program, only WD's environment variables.  So I cannot call "cmd.exe" and pass "/k c:\my_dir\my_batch.bat" "%WD_File%"

What happens is cmd.exe opens but no command is executed within.  Sad

It was worth a try...
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2232
The Netherlands
Re: Multi-step process
Reply #2 - Jul 20th, 2014 at 8:16am
 
Hello David,

Cant you just use the %WD_FILE% variable inside your script?
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
David Hostetter
YaBB Newbies
*
Offline



Posts: 8
Re: Multi-step process
Reply #3 - Jul 20th, 2014 at 9:48pm
 
Yes, I probably can.  Assuming that when I run cmd.exe as the executable program the environment variables are created in that environment.  But I can't get cmd.exe to start a batch file as a parameter.  That's the problem.

I don't suppose there is some secret way to make a sub-task run a batch file?
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2232
The Netherlands
Re: Multi-step process
Reply #4 - Jul 21st, 2014 at 7:51am
 
I just tried and it works fine for me, see attached. All WD_ variables ( www.watchdirectory.net/wdhelp/plugins/wdopAutoRunBatEnv.html ) are available in your script.

I used the /C switch so the cmd window automatically closes when it is done.

Perhaps the cmd gets confused by your use of "quotes"??
Back to top
 

21-7-2014_7-40-00.png (17 KB | 212 )
21-7-2014_7-40-00.png

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
David Hostetter
YaBB Newbies
*
Offline



Posts: 8
Re: Multi-step process
Reply #5 - Jul 22nd, 2014 at 3:51pm
 
Confirmed working.  Actually it's not the quotes.  My actual batch file has extension .cmd   That doesn't seem to work.  Renamed it to .bat and it works fine.  And you are also correct that the environment variables are available in the command environment - no need for me to pass them as parameters.

Thanks for looking at this.  I'm pleased this works like I hoped.
Back to top
 
 
IP Logged
 
Verne
Junior Member
**
Offline



Posts: 50
Re: Multi-step process
Reply #6 - Jul 28th, 2014 at 9:34pm
 
I have been doing it like Gert described above and we have also successfully tested with pointing it directly to the batch file as well without using cmd.exe.
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1