Autorun with USB

Discuss RoboTask here
Post Reply
dioxb
Posts: 2
Joined: Thu Jul 11, 2013 12:49 pm

Autorun with USB

Post by dioxb »

Hi!
I need to make a task that start when we put a specific usb drive.
Example: I insert my drive "U" and starts a program with a parameters for this drive, and I insert my drive "V" and starts a program with others parameters for this drive.

Anybody can help me?

Thanks!!
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Autorun with USB

Post by Oleg »

Look at the example below.
You should use "On Device Changed" trigger and pass the device letter to the task.
In the task you should analyze the volume label of device.

You may assign any label to your USB device by using system command label.
For example:
label j: potato

I tested the example with two flash drives with labels POTATO and TOMATO

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|2099193306
Comment=STRINGLIST
ContinueOnError=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task287"
Hide=INTEGER|0
ID=INTEGER|843856841
LogOnAsUser=INTEGER|1
Name=STRING|"Run program for flash drive"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER

[Actions\Action1]
ActionID=STRING|"A_ROBOTASK_ALERT"
Enabled=INTEGER|0
Name=STRING|"Show Notification"
Params=FOLDER

[Actions\Action1\Params]
defh=STRING|"1"
defw=STRING|"1"
duration=STRING|"5"
height=STRING|"76"
icon=STRING|"3"
kind=STRING|"0"
message=STRING|"{device}"
position=STRING|"3"
title=STRING|"arrival"
width=STRING|"330"

[Actions\Action2]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action2\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"0"
value1=STRING|"{VolumeLabel({device}:\)}"
value2=STRING|"potato"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Run ""Potato""  program"""
Params=FOLDER

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"Run ""Potato""  program"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action5]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action5\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"0"
value1=STRING|"{VolumeLabel({device}:\)}"
value2=STRING|"tomato"

[Actions\Action6]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Run ""Tomato""  program"""
Params=FOLDER

[Actions\Action6\Params]
icon=STRING|"1"
msg0=STRING|"Run ""Tomato""  program"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[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"
Params=FOLDER
UnigueID=INTEGER|16445953

[Events\Event1\Params]
assign=STRING|"0"
changekind=STRING|"1"
devicekind=STRING|"1"
parameter=STRING|"device"
useparameter=STRING|"1"
Save the text of the task into a file. Use menu Task->Import in order to import the task into RoboTask.
Do not forget to enable the task after importing
Oleg Yershov
dioxb
Posts: 2
Joined: Thu Jul 11, 2013 12:49 pm

Re: Autorun with USB

Post by dioxb »

It works!!

You're invited to a beer.

A lot of lot of lot of thanks.
Post Reply