Posts: 60
Threads: 21
Joined: Aug 2003
I use the following code to send and then run functions or macros on another PC on our LAN.
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)
Posts: 60
Threads: 21
Joined: Aug 2003
Here's the code:
;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
Posts: 12,061
Threads: 140
Joined: Dec 2002
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
Posts: 60
Threads: 21
Joined: Aug 2003
Thanks for the lightning response again Gintaras.
Sounds good. I'll try that.
Al
Posts: 60
Threads: 21
Joined: Aug 2003
Here is the main macro
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
;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
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:
or -
or --
I'm reluctant to make them global because they might affect other functions or macros.
Posts: 12,061
Threads: 140
Joined: Dec 2002
Macro
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
;...
Posts: 60
Threads: 21
Joined: Aug 2003
Thanks for the quick response, but unfortunately I don't understand what you mean.
Posts: 12,061
Threads: 140
Joined: Dec 2002
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))
...
Posts: 60
Threads: 21
Joined: Aug 2003
When I type:
type MYNETVAR (MYNETVAR does not turn orange)
What am I doing wrong?
Posts: 12,061
Threads: 140
Joined: Dec 2002
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.
Posts: 60
Threads: 21
Joined: Aug 2003
Thanks a lot. I got that working with multiple threads.
Al