Andrea said:
Ok, it could be an idea. I'm not familiar with vbscript, so I need to study
it.
Anyway, I have done some additional test using GPUPDATE command.
I was thinking that logon script in GP are at all part of the policy and
because of this, when the policy is update, also the logon script should be
re-run.
This is wrong. My test show that when I entered the command gpupdate /Force,
the policy got updated, but the script is not re-run.
My conlcusion is that the logon script (and other GP scritps) aren't like a
policy at all and so are not included in policy update.
Can anybody confirm this?
Hi
That is correct, you will not be able to run any scripts by refreshing
a policy with gpupdate.exe.
But you can run a script that will detect that you connect the cable,
and then let the script run the logon script.
This detection script could be set to start at logon by launching it
from e.g.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
This will kick inn for all network adaptors:
'--------------------8<----------------------
Set colMonitoredEvents = GetObject("winmgmts:root\wmi")._
ExecNotificationQuery("Select * from MSNdis_StatusMediaConnect")
Do
Set strLatestEvent = colMonitoredEvents.NextEvent
WScript.Echo "Connected! Do something here"
' exit after the first event.
Exit Do
Loop
'--------------------8<----------------------
If you want to check a specific adapter, use e.g. a select on the
InstanceName of the adapter:
'--------------------8<----------------------
Set colMonitoredEvents = GetObject("winmgmts:root\wmi")._
ExecNotificationQuery("Select * from MSNdis_StatusMediaConnect" _
& " WHERE InstanceName = '3Com 10/100 Mini PCI Ethernet Adapter'")
Do
Set strLatestEvent = colMonitoredEvents.NextEvent
WScript.Echo "Connected! Do something here"
' exit after the first event.
Exit Do
Loop
'--------------------8<----------------------