Finding NT logon server name 
Author Message
 Finding NT logon server name

I need to "load balance" sharing of the same data among my domain controlers
the way, that users would map the share from the controler they logon to. It
seems easy on Windows NT clients (using WScript.ScriptFullName property),
but on Win9x clients this property returns a drive letter. Does anybody know
any other way how to realize this?
    Thanks,
         Zdenek


Sun, 23 Nov 2003 16:34:26 GMT  
 Finding NT logon server name


Quote:
> I need to "load balance" sharing of the same data among my domain
controlers
> the way, that users would map the share from the controler they logon to.
It
> seems easy on Windows NT clients (using WScript.ScriptFullName property),
> but on Win9x clients this property returns a drive letter. Does anybody
know
> any other way how to realize this?
>     Thanks,
>          Zdenek

I am starting to switch our logon scripts to VBScript here.  This is what I
have come up with so far.  It works but I don't know if it is the best way
as I am just starting to use VBScript.

option explicit
dim wshShell, wshNetwork, wshEnv
dim regex,  server_string, server_name, logon_drive
dim drives, i

set wshShell = CreateObject ("WScript.Shell")
set wshNetwork = CreateObject ("WScript.Network")
set wshEnv = wshShell.Environment("PROCESS")
set regex = New RegExp

' Get the name of the running script
' On 9x it will be Z:\logon.vbs but on NT it will be
\\server\netlogon\logon.vbs
' We check to see if it starts with a letter: and if so we determine the
sever share
' THat the drive is mapped to
server_string = WScript.ScriptFullName

regex.pattern = "^([A-Z]:).*"
regex.IgnoreCase = TRUE

if regex.Test(server_string) then  'Will the regex match?
    ' Yes, get the logon drive mapping
    logon_drive = regex.Replace(server_string,"$1")
    set drives = wshNetwork.EnumNetworkDrives
    ' loop through the mapped drives until we find the correct one
    for i = 0 to drives.count - 1 step 2
        if drives(i) = logon_drive then
            ' set the server string to be the network path for the logon
drive
            server_string = drives(i+1)
        end if
    next
end if

' we want to find the server name out of \\server\netlogon.....
regex.pattern = "^\\\\(\w+)\\.*"
server_name = regex.Replace(server_string,"$1")
' server_name is now set to the logon server for the duration of the script.



Tue, 02 Dec 2003 02:37:59 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How can I get logon server name and IP address from logon script using wsh

2. Win98, Logon script & finding logon server

3. Lock CD-drive and find out logon-name

4. NT Logon name

5. wscript cant find .vbs file from NT logon batch

6. wscript cant find .vbs file from NT logon batch

7. Auto NT4 server logon with Logon to Novell server(4.11)

8. how to get the name of the logon server in Win95

9. Find IP address for a given Server Name

10. How can I get the name of an nt server

11. finding the FORM item NAME on server side!

12. Getting the user's logon name and computer name

 

 
Powered by phpBB® Forum Software