Hi everyone,
I’m trying to create a task in Robotask that runs automatically only when a specific USB drive (identified by its volume label or serial number) is connected to my PC. I want the task to back up some files to that drive, but it shouldn’t start if any other USB device is plugged in.
I’ve tried using the “Device Connected” trigger, but it seems to react to any USB device. Is there a way to filter the trigger by a specific drive label or hardware ID within Robotask, or do I need to add a conditional check in the task itself?
Has anyone successfully set up something like this?
How to trigger a Robotask action only when a specific USB device is connected?
Re: How to trigger a Robotask action only when a specific USB device is connected?
Yes, trigger reacts to any USB drive.I’ve tried using the “Device Connected” trigger, but it seems to react to any USB device.
But you can read volume label in the task. See {VolumeLabel(c:\)} system variable
Then you use If..Then actions to analyze it
also take a look at this example
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|281496679
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task1502"
Hide=INTEGER|0
ID=INTEGER|-658729983
LogOnAsUser=INTEGER|1
Name=STRING|"Write to USB device (on devivce change)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RestrictRESTAPIAccess=INTEGER|0
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""DISK"" with value ""I:"""
Params=FOLDER
[Actions\Action1\Params]
_rt_variables_produced=STRING|"DISK"
expand=STRING|"0"
linecount=STRING|"1"
varkind=STRING|"1"
varname=STRING|"DISK"
varvalue=STRING|"I:"
[Actions\Action2]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER
[Actions\Action2\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"0"
value1=STRING|"{VolumeLabel({disk}\)}"
value2=STRING|"transfer"
[Actions\Action3]
ActionID=STRING|"A_FOLDER_SYNCHRONIZE"
Enabled=INTEGER|-1
Name=STRING|"Synchronize Folders (test)"
Params=FOLDER
[Actions\Action3\Params]
checkfile=STRING|"1"
clearro=STRING|"1"
details=STRING|"1"
detailstovar=STRING|"0"
exact=STRING|"0"
foder1=STRING|"D:\test"
foder2=STRING|"{disk}\test"
hidden=STRING|"0"
howsync=STRING|"0"
includeempty=STRING|"0"
includemask=STRING|"*.*"
maxtimeout=STRING|"15"
subdir=STRING|"1"
system=STRING|"0"
twosecprecision=STRING|"1"
[Actions\Action4]
ActionID=STRING|"A_ROBOTASK_ALERT"
Enabled=INTEGER|-1
Name=STRING|"Show Notification"
Params=FOLDER
[Actions\Action4\Params]
colorscheme=STRING|"0"
defh=STRING|"1"
defw=STRING|"1"
duration=STRING|"5"
height=STRING|"76"
icon=STRING|"3"
kind=STRING|"0"
message=STRING|"Synchronisation comlete!!!"
position=STRING|"3"
title=STRING|"Sync comlete"
width=STRING|"330"
[Actions\Action5]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"
[Actions\Action6]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log message (error) ""Wrong drive!!!"""
Params=FOLDER
[Actions\Action6\Params]
expression=STRING|"3"
message=STRING|"Wrong drive!!!"
mode=STRING|"0"
type=STRING|"2"
[Actions\Action7]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
[Events]
Event1=FOLDER
[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_SYSEVENTS_DEVICECHANGE"
Name=STRING|"On Device Changed"
Params=FOLDER
UniqueID=INTEGER|753778116
[Events\Event1\Params]
assign=STRING|"0"
changekind=STRING|"1"
devicekind=STRING|"1"
useparameter=STRING|"0"
Also you can simply copy task text and paste it into the task list.
Don't forget to enable the task after importing
Oleg Yershov