Jump to content

Recommended Posts

Hi,

I did create a remote monitor which uses a batch file.  The batch file resides in the LTShare folder under Transfer\Monitors directory.

Upon execution the batch file uploads to the Windows\LTSvc folder of the remote computer which is fine but the problem is if I modify the file inside the LTShare\Monitors\Transfer directory the remote monitor still execute the file located on his Windows\LTShare folder.

Is there any way I could update the remote file when I make changes in it ?

Thanks in advance.

Share this post


Link to post
Share on other sites

You'd have to have your script see if the file exists, then delete it if so.

I believe that Automate checks if the file exists and doesn't upload it if it's already there. It's probably just checking filename, not contents which would explain your situation.

 

Share this post


Link to post
Share on other sites

The problem is that it is the script itself that need to be deleted

I guess I should make a second script which deletes the previous one.

It`s a dirty solution but I guess it`s the only way to go since Automate doesn`t work the way it should.

 

Edited by Todarivah

Share this post


Link to post
Share on other sites

If it was a script it should detect changes when downloading a file, but there is a "force download" option in scripts, as I recall.  In cases similar to this we just add a line to our "regularly scheduled script" script that would download updates for the file every week or two, whenever that script runs.

Edited by SteveYates

Share this post


Link to post
Share on other sites

This is the kind of monitor I am talking about, if we modify the content of the batch file the remote computer still execute the previous one, it doesn`t get updated.

image.png.b2d8dfc95c3bd6f75f49c36857b3e9af.png

Share this post


Link to post
Share on other sites

Have you tried dating the batch file?  ShadowTest20200911.bat for example?  That may be seen as new if the remote monitor is saved.  Or, have you tried saving the remote monitor again after changing the batch file?  Maybe that "rereads" the batch file?

What I was trying to suggest is to run a different script that downloads the batch file every week or whatever, so changes are pushed out regularly.

Share this post


Link to post
Share on other sites

I typically build a self-destruct into my remote monitor .bat files.

@echo off
SET SCRIPTVERSION=2
SET "EXPECTEDVERSION="
IF NOT "[%~1]"=="[]" SET "EXPECTEDVERSION=%~1"
IF NOT DEFINED EXPECTEDVERSION SET "EXPECTEDVERSION=%SCRIPTVERSION%"

REM Regular batch stuff here

REM Regular batch stuff done.

IF "[%EXPECTEDVERSION%]"=="[%SCRIPTVERSION%]" EXIT /B 0
REM Safety check, only purge if we are running from the %WINDIR%\LTSvc folder.
ECHO Purging %~nx0 version %SCRIPTVERSION% so that version %EXPECTEDVERSION% can be downloaded to %~dp0. | FINDSTR.EXE /I /C:"%WINDIR%\LTSvc" || EXIT /B 0
REM There must be no extra lines after the next statement.
START "Purge Script" /WAIT /B CMD.EXE /c "PING.EXE -n 1 127.0.0.1>NUL&DEL /F "%~f0""&EXIT /B 0

So as I update the .bat, I change the SCRIPTVERSION value. Then I update the remote monitor to pass the version as the first parameter.  If the first parameter is missing or matches the version already on the agent, no problem. But if the version does not match, the script deletes itself as its final step. Then the next time it runs a new copy will be downloaded.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...