Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to shorten or deactivate timeout delay when using "net"
#1
I use the following code to send and then run functions or macros on another PC on our LAN.

Code:
Copy      Help
Run_function_on_other_PCer
foreach c Valgte_PCer
        r=(NetSendMacro(c Passord Valgt_funksjon))
        if(r) mes "Kan ikke sende function til denne PC" c
        r=(net(c Passord Valgt_funksjon))
        if(r) mes "Kan ikke kjøre function på denne PC" c
goto Slutt

I issue these commands to groups of computers. But if 1 or more of the computers is turned off or disconnected, then there is a 25 second timout delay after the "NetSendMacro" command and then the "net" command, 45 seconds in total. If 7 computers are turned off, I must wait for 5 minutes for the macro to complete.

How can I shorten this timeout period, and how can I deactivate it completely? (assuming that is not a dumb thing to do)
#2
Here's the code:

Code:
Copy      Help
;Run_function_on_other_PCer
foreach c Valgte_PCer
,,r=(NetSendMacro(c Passord Valgt_funksjon))
,,if(r) mes "Kan ikke sende function til denne PC" c
,,r=(net(c Passord Valgt_funksjon))
,,if(r) mes "Kan ikke kjøre function på denne PC" c
goto Slutt
#3
The timeout cannot be changed.

Use multiple threads. Move NetSendMacro and next 3 lines to a separate function, and use mac to launch the function.

foreach c ...
,mac "Function" "" c
#4
Thanks for the lightning response again Gintaras.

Sounds good. I'll try that.

Al
#5
Here is the main macro

Code:
Copy      Help
str Valgt_funksjon
str tid=tid.time("dddd    'kl.'" "h:mm") ;; Dag og tid
str Passord="[**]"
str VNC_Viewer_PC_Config_Fil
str Oppgave
str Valgte_PCer
str Desktop_Path.expandpath("$Desktop$\") ;; Expands the desktop path for any user and places it in variable "Desktop_path"
int r
str c


Code:
Copy      Help
;Run_function_on_other_PCer
foreach c Valgte_PCer
,mac "Send_Function_Til_PC_Run" "" c
,,;r=(NetSendMacro(c Passord Valgt_funksjon))
,,;if(r) mes "Kan ikke sende function til denne PC" c
,,;r=(net(c Passord Valgt_funksjon))
,,;if(r) mes "Kan ikke kjøre function på denne PC" c
goto Slutt

Here is the new function it calls

Code:
Copy      Help
r=(NetSendMacro(c Passord Valgt_funksjon))
if(r) mes "Kan ikke sende function til denne PC" c
r=(net(c Passord Valgt_funksjon))
if(r) mes "Kan ikke kjøre function på denne PC" c

I get unidentified errors on r, c, Passord etc...
I understand that these variables are local and therefor not seen in the new function.
Should I make them global in the primary macro:

Code:
Copy      Help
int+ r
str+ c

or -
or --

I'm reluctant to make them global because they might affect other functions or macros.
#6
Macro
Code:
Copy      Help
type MYNETVAR
,str'Valgt_funksjon
,str'tid
,str'Passord
,str'VNC_Viewer_PC_Config_Fil
,str'Oppgave
,str'Valgte_PCer
,str'Desktop_Path
,int'r
,str'c

MYNETVAR+ g_nxx
g_nxx.tid.time("dddd 'kl.'" "h:mm") ;; Dag og tid
;...
#7
Thanks for the quick response, but unfortunately I don't understand what you mean.
#8
I mean use single global variable instead of many global variables.

Or pass other variables like c.

,mac "Send_Function_Til_PC_Run" "" c tid Passord ...

Function:
function str'c str'tid str'Passord ...
r=(NetSendMacro(c Passord Valgt_funksjon))
...
#9
When I type:

type MYNETVAR (MYNETVAR does not turn orange)

What am I doing wrong?
#10
Nothing wrong. Maybe will become colored later.

But in this case probably is better to pass variables as arguments. If you use global variable, possibly something wrong may happen because the variable will be used by multiple threads simultaneously.
#11
Thanks a lot. I got that working with multiple threads.

Al


Forum Jump:


Users browsing this thread: 1 Guest(s)