Action "Login to network share / Map network drive" does not connect nor disconnect

Discuss RoboTask here
jan
Posts: 29
Joined: Wed Jan 22, 2025 4:36 pm

Action "Login to network share / Map network drive" does not connect nor disconnect

Post by jan »

Hello,

I would like to check the connection to a network drive (\\xxx.xxx.xxx.xxx\SK01) cyclically.
If the network drive is not accessible, a connection should be established.

Can this be done with Robotask?

Many thanks for your advice and help.
Ján
Last edited by jan on Wed Jan 29, 2025 2:07 pm, edited 2 times in total.
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Check the connection to the network drive

Post by Oleg »

I would like to check the connection to a network drive (\\xxx.xxx.xxx.xxx\SK01) cyclically.
Ping Host action
Also you can try to read some small file from network disk.
a connection should be established.
How? The computer may not work or the network may be unavailable anywhere along the route.
The task can only generate a warning or send email to you
Oleg Yershov
jan
Posts: 29
Joined: Wed Jan 22, 2025 4:36 pm

Re: Check the connection to the network drive

Post by jan »

Thank you Oleg for your prompt reply. I thought that Robotask can also connect network drives?

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|0
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1"
Hide=INTEGER|0
ID=INTEGER|48756757
LogOnAsUser=INTEGER|1
Name=STRING|"Check Network-Fiolder"
OnErrorTaskID=INTEGER|0
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

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""NW"" with value ""-1"""
Params=FOLDER

[Actions\Action1\Params]
_rt_variables_produced=STRING|"NW"
expand=STRING|"0"
linecount=STRING|"1"
varkind=STRING|"1"
varname=STRING|"NW"
varvalue=STRING|"-1"

[Actions\Action2]
ActionID=STRING|"A_INET_PING"
Enabled=INTEGER|-1
Name=STRING|"Ping \\192.168.178.111\SK01"
Params=FOLDER

[Actions\Action2\Params]
_rt_variables_produced=STRING|"{NW}"
default=STRING|"-1"
host=STRING|"\\192.168.178.111\SK01"
timeout=STRING|"5000"
variable=STRING|"{NW}"

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

[Actions\Action3\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"1"
value1=STRING|"{NW}"
value2=STRING|"-1"

[Actions\Action4]
ActionID=STRING|"A_LOGIN_MAP_SHARE"
Enabled=INTEGER|-1
Name=STRING|"Map ""\\192.168.178.111\SK01"" as ""R:"""
Params=FOLDER

[Actions\Action4\Params]
drive=STRING|"R:"
mapdrive=STRING|"1"
mode=STRING|"0"
password=STRING|"xxx"
sharename=STRING|"\\192.168.178.111\SK01"
username=STRING|"jan.bluhm"

[Actions\Action5]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Check the connection to the network drive

Post by Oleg »

You must specify the host name or IP address in Ping action (not UNC share name)
If your server is physically available, Ping will always return a valid value

In your case you need to check reading of some file from R: disk.
Oleg Yershov
jan
Posts: 29
Joined: Wed Jan 22, 2025 4:36 pm

Re: Check the connection to the network drive

Post by jan »

Hello Oleg,

unfortunately I'm not a computer scientist :), so I don't know what you mean.

I want to use Robotask to check whether my computer has mapped \\192.168.178.111\SK01 as R:\.
If a network drive R:\ does not exist, such a network drive should be created. If there is one, but it is not accessible, it should be connected.


Best regards, Ján
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Check the connection to the network drive

Post by Oleg »

Look at the example below

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1566"
Hide=INTEGER|0
ID=INTEGER|48756757
LogOnAsUser=INTEGER|1
Name=STRING|"Check Network-Fiolder"
OnErrorTaskID=INTEGER|0
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

[Actions\Action1]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If (R:\ does not exist) Then "
Params=FOLDER

[Actions\Action1\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"1"
type=STRING|"3"
value1=STRING|"{FolderExists(R:\)}"
value2=STRING|"-1"

[Actions\Action2]
ActionID=STRING|"A_LOGIN_MAP_SHARE"
Enabled=INTEGER|-1
Name=STRING|"Map ""\\192.168.178.111\SK01"" as ""R:"""
Params=FOLDER

[Actions\Action2\Params]
drive=STRING|"R:"
mapdrive=STRING|"1"
mode=STRING|"0"
sharename=STRING|"\\192.168.178.111\SK01"
username=STRING|"jan.bluhm"

[Actions\Action3]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
Oleg Yershov
jan
Posts: 29
Joined: Wed Jan 22, 2025 4:36 pm

Re: Check the connection to the network drive

Post by jan »

Hello Oleg,

Thank you very much for your great help.

I have disconnected the network drive R:\ and started your task. I entered the correct password in the task beforehand. The log shows the following errors:

I 27.01.2025 15:47:35: ****** Starting task: Check Network-Fiolder (imported) ******************
I 27.01.2025 15:47:35: Executing "1.If (R:\ does not exist) Then "
I 27.01.2025 15:47:35: Executing "2.Map "\\192.168.178.111\SK01" as "R:""
E 27.01.2025 15:47:38: System error 1219 occurred.
E 27.01.2025 15:47:38: Multiple connections to a server or a shared resource from the same user using multiple user names are not permitted. Disconnect all previous connections to the server or shared resource and try again.
E 27.01.2025 15:47:38: An error occurred. Step #2 (Map "\\192.168.178.111\SK01" as "R:").
E 27.01.2025 15:47:38: Task execution is aborted
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Check the connection to the network drive

Post by Oleg »

E 27.01.2025 15:47:38: Multiple connections to a server or a shared resource from the same user using multiple user names are not permitted. Disconnect all previous connections to the server or shared resource and try again.
Your computer already connected to remote computer. But network drive is not mapped
To disconnect use the command line

Code: Select all

net use \\192.168.178.111\SK01 /delete
Oleg Yershov
jan
Posts: 29
Joined: Wed Jan 22, 2025 4:36 pm

Re: Check the connection to the network drive

Post by jan »

Guten Morgen Oleg,

Thank you very much for your help and recommendation. If I understand you correctly, the action "Login to network share /Map to network drive" is to be used with the setting "Disconnect"?

I have tried this, but it does not work. What am I doing wrong? Can you help me with this?

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|0
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1566"
Hide=INTEGER|0
ID=INTEGER|-1779018663
LogOnAsUser=INTEGER|1
Name=STRING|"Check Network-Folder  (imported)  (imported)"
OnErrorTaskID=INTEGER|0
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

[Actions\Action1]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If (R:\ does not exist) Then "
Params=FOLDER

[Actions\Action1\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"1"
type=STRING|"3"
value1=STRING|"{FolderExists(R:\)}"
value2=STRING|"-1"

[Actions\Action2]
ActionID=STRING|"A_LOGIN_MAP_SHARE"
Enabled=INTEGER|-1
Name=STRING|"Disconnect from ""\\192.168.178.111\SK01"""
Params=FOLDER

[Actions\Action2\Params]
drive=STRING|"F:"
mapdrive=STRING|"0"
mode=STRING|"1"
sharename=STRING|"\\192.168.178.111\SK01"

[Actions\Action3]
ActionID=STRING|"A_LOGIN_MAP_SHARE"
Enabled=INTEGER|-1
Name=STRING|"Map ""\\192.168.178.111\SK01"" as ""R:"""
Params=FOLDER

[Actions\Action3\Params]
drive=STRING|"R:"
mapdrive=STRING|"1"
mode=STRING|"0"
password=STRING|"bYDilOXbEVon4Kg6BQZfj9jt+VyHWRzv2ylWUvLOyt8OFRAz2MsvF2zqKYohnQef06zcjARI6+B1P0/2TshVHl8taa0/LSD5Iz/8BYrs5GcxaXJK/cNNYJXcE4tyBhf4Dw4JfSZ1zELrxeifm/lPxzBEuQ=="
sharename=STRING|"\\192.168.178.111\SK01"
username=STRING|"jan.bluhm"

[Actions\Action4]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Check the connection to the network drive

Post by Oleg »

I have tried this, but it does not work.
Why? Do you have some some error/warning messages?
Oleg Yershov
Post Reply