Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: RAS connection Remote Access Connection
;============================cut==================================== ; Start of Winbatch Code if RegExistValue(@REGMACHINE, "System\CurrentControlSet\Services\RemoteAccess[Remote Connection]") binval=RegQueryBin(@REGMACHINE, "System\CurrentControlSet\Services\RemoteAccess[Remote Connection]") If binval=="01 00 00 00" ;if this value is set, there is a RAS connection Remote=@TRUE Display(2,"Connection Status","System is connected by RAS") Else Remote=@FALSE Display(2,"Connection Status","System is connected to local network") EndIf Endif ; End of Winbatch Code
Note: The part of the key "NdisWan4" referred to in this article CAN vary. It can have values from NdisWan to at least NdisWan6 and possibly higher.
HKLM\System\CurrentControlSet\Services\NdisWan4\Parameters\Tcpip[DhcpIPAddress]Here's a user's sample login script:
IF RegExistKey(@REGMACHINE, "System\CurrentControlSet\Services\RemoteAccess" ) ; This key does NOT exist unless DUN is installed ; so if it's NOT there the PC CAN'T be dialing in ndis_ctr="" ; initialize counter -- minor problem -- it starts with just PLAIN NdisWan While ndis_ctr<10 ; there's an indeterminate number of NdisWan# keys -- have seen up to NdisWan6 we will check NdisWan thru NdisWan9 IF RegExistValue(@REGMACHINE,"System\CurrentControlSet\Services\NdisWan%ndis_ctr%\Parameters\Tcpip[DhcpIPAddress]" ) goto warning ; the above key ONLY exists during an active connection to a dial-in server so as soon as we find it we KNOW we've dialed in endif ; so we jump to the warning If ndis_ctr=="" ; minor problem -- it starts with just PLAIN NdisWan this section sets it to 1 ndis_ctr=1 else ; once it's a number rather than "empty" or "" ndis_ctr=ndis_ctr + 1 ; we can increment it endif endwhile ; if we get all the way through this while loop without jumping to warning we must be connected by LAN
aa=GetTickCount() FileCopy("FROMSERVER.TXT","LOCALMACHINE.TXT",0) bb=GetTickCount() cc=bb-aaThen if cc is bigger than some number then you have a slow connection and DONT want to update. The value of cc you use is dependent on file size.
The algorithm can occasionally get fooled by a real bogged down network....but then you probably would not want to update anyway so its ok.
The bigger file you transfer the more accurate the number is....but the more time it takes to figure it out. I suggest 1K to 4K files.
If your script is a logon script then there is almost no chance that DUN is running unless you connected with it. Therefore:
if WinExist("~Connected") || WinExist("~Dial-Up") ;Are we Dial Up DIALUP=@TRUE else DIALUP=@FALSE endifWill work on both 95 and NT. Of course you could always use this test to see if it's worth checking the network speed.
NOTE: Checkras.exe was included in earlier versions of MS Back Office; CheckRas.exe is not included with the Back Office Resource Kit 4.5 or later.
To find it and use it, you may have to scramble around and get it from the earlier version.
Checkras.exe is a command line utility for use in login scripts, etc, and is from the Backoffice Resource kit.
It must only be run on machines which have RAS installed (maybe it bombs otherwise), and I expect it works via errorlevels.
One of our users reported that the following utility, called RASTAT, is much better and is available for download from:
http://sharky.nanko.ru/staff/index.html
Article ID: W13147
Filename: Determine if RAS Connection.txt
File Created: 2001:07:25:13:11:52
Last Updated: 2001:07:25:13:11:52