Need help with logon script 
Author Message
 Need help with logon script

Hi,

When I run the following script from an NT machine I get this error *(null):
The network path was not found* on line: adsPath =  ("WinNT://NTMASTER" &
strUserDomain & "/" & strUserName). But if I remove the domain name
NTMASTER1, it works.On Win9x machines the script works fine.I need this
script to work for both NT and 9x machines.Does anyone know how I could
modify it so that it works on both platforms?

Thanks  -Boris-

Option Explicit

'On Error Resume Next

Dim wshShell
Dim wshNetwork
Dim wshSysEnv
Dim wshFileSystem
Dim strUserDomain
Dim strUserName
Dim strComputerName
Dim conSystemRoot
Dim strTempPath
Dim adsPath
Dim adsObj
Dim LoginBox
Dim strLoginBoxText
Dim intGenericLoop
Dim strGreeting
Dim conQuote
Dim conCrLf
Dim Prop
Dim BeginTimeCount
Dim EndTimeCount
Dim fsoTitleBanner
Dim conLogonServer
Dim MapResources(26)
Dim FSO
Dim oNet
Dim oUser
Dim oSAM

For intGenericLoop = 0 to 26
    MapResources(intGenericLoop) = False
Next

'On Error Resume Next
strUserName = ""
While strUserName = ""
 'On Error Resume Next
 Set oNet = CreateObject("WScript.Network")
 'On Error Resume Next
 strUserName = oNet.UserName
 'On Error Resume Next
 Set oNet = Nothing
Wend

Const ADS_READONLY_SERVER = 4

Set wshShell       =  WScript.CreateObject("WScript.Shell")
Set wshSysEnv      =  wshShell.Environment("PROCESS")
conSystemRoot      =  wshSysEnv("SYSTEMROOT")
If wshSysEnv("OS") = "Windows_NT" Then conSystemRoot = conSystemRoot &
"\system32"
strTempPath        =  wshSysEnv("TEMP")
Set oNet           =  WScript.CreateObject("WScript.Network")
Set wshFileSystem  =  WScript.CreateObject("Scripting.FileSystemObject")
strUserDomain      =  oNet.UserDomain
'strUserName        =  oNet.UserName
strComputerName    =  oNet.ComputerName
adsPath            =  ("WinNT://NTMASTER" & strUserDomain & "/" &
strUserName)
'Set adsObj         =  GetObject(adsPath)
'strPrintServer     = "\\SPOONYG"
conQuote           =  Chr(34)
conCrLf            =  Chr(10)
conLogonServer     =  wshShell.ExpandEnvironmentStrings("%LOGONSERVER%")

If Time() <= #12:00:00 PM# Then strGreeting = "Morning"
If Time() > #12:00:00 PM# And Time() <= #06:00:00 PM# Then strGreeting =
"Afternoon"
If Time() > #06:00:00 PM# Then strGreeting = "Evening"

Call RemoveMappedDrives()

Call CreateLoginScreen()

LoginBox.pbar(30)

Set oNet = CreateObject("WScript.Network")
Set WshShell = CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")

Set oSam = GetObject("WinNT:")
Set oUser = oSAM.OpenDSObject(adsPath,"","", ADS_READONLY_SERVER)
For Each Prop in oUser.Groups
    Select Case Prop.Name
    Case "Network Admin"
    'Case "Domain Admins"
            MapResources(7) = True
            'MapResources(8) = True
    Case "Accounting"
            MapResources(8) = True
    End Select
Next

LoginBox.pbar(40)

LoginBox.pbar(60)
LoginBox.setWaitMessage("Adding resources...")

If MapResources(7) = True Then Call MapDriveO()
If MapResources(8) = True Then Call MapDriveP()

LoginBox.pbar(80)

strLoginBoxText = strLoginBoxText & conCrLf & "Logon Complete."
LoginBox.pbar(100)
LoginBox.setWaitMessage("Exiting...")
BeginTimeCount = Time
EndTimeCount = BeginTimeCount + TimeSerial(0, 0, +5)
While EndTimeCount > Time
Wend
LoginBox.Kill

WScript.Quit

Sub CreateLoginScreen()
  On Error Resume Next
  'If Not wshFileSystem.FileExists(conSystemRoot & "\loginscreen.exe") Then
    'WScript.Echo
    'WScript.Quit
  'End If
  If wshFileSystem.FileExists(strTempPath & "\Easylink.bmp") Then
    'wshFileSystem.DeleteFile(strTempPath & "\Easylink.bmp")
  End If
    If Not wshFileSystem.FileExists(strTempPath & "\Easylink.bmp") Then
    Set fsoTitleBanner = wshFileSystem.GetFile(conLogonServer &
"\NETLOGON\Easylink.bmp")
    fsoTitleBanner.Copy(strTempPath & "\Easylink.bmp")
  End If
  Set LoginBox = WScript.CreateObject("LoginScreen.Main")
  LoginBox.SetTitle("Easylink Login Script")
  LoginBox.SetImage(strTempPath & "\Easylink.bmp")
  LoginBox.setWelcomeMessage("Good " & strGreeting & ", " & strUserName & "
on " & strComputerName)
  LoginBox.setWaitMessage("Initializing...")
  strLoginBoxText = "You have been logged on to the " & strUserDomain & "
domain."
  LoginBox.SetDisplayMessage(strLoginBoxText)
  LoginBox.pbar(20)
  LoginBox.Start
End Sub

Sub MapDriveO()
    oNet.MapNetworkDrive "O:", "\\EGGMAN\Share01"
    strLoginBoxText = strLoginBoxText & conCrLf & "0: has been mapped to
\\EGGMAN\Share01."
    LoginBox.SetDisplayMessage(strLoginBoxText)
End Sub

Sub MapDriveP()
    oNet.MapNetworkDrive "P:", "\\NEWMAN\Share02"
    strLoginBoxText = strLoginBoxText & conCrLf & "P: has been mapped to
\\NEWMAN\SHARE02."
    LoginBox.SetDisplayMessage(strLoginBoxText)
End Sub

Sub RemoveMappedDrives()
    On Error Resume Next
    oNet.RemoveNetworkDrive "O:"
    oNet.RemoveNetworkDrive "P:"

End Sub



Sat, 10 Jan 2004 05:06:30 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Need help with logon script

2. Help: Manual or Reference on Logon Script needed

3. Newbie help needed with a Logon Script

4. Logon Script Problems - help needed

5. logon.exe script.vbs in profile (logon script)

6. logon help needed

7. Need sample WSH logon scripts.

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

9. Win98, Logon script & finding logon server

10. Help Required with VB Logon Script

11. Help with logon script to change screen resolutions

12. WSH in W2Kpro - help about logon script

 

 
Powered by phpBB® Forum Software