Hi I have been fiddling around with Marks brill script and wondered if any one can help?
I wish to have an input box for the UserName and for it to then place this in the place of the user string. I post my effort below Thanks
'==========================================================================
'
' NAME: LogonScript.vbs
'
' AUTHOR: Mark D. MacLachlan, The Spider's Parlor
' URL : ' DATE : 4/10/2003
'
' COMMENT:
' Maps and disconnects drives
'
'
'==========================================================================
ON ERROR RESUME NEXT
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
'Automatically find the domain name
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
'Grab the user name
UserString ="fisk"
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
'Disconnect ALL mapped drives
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
Next
'Give the PC time to do the disconnect, wait 300 milliseconds
wscript.sleep 300
'Map drives needed by all
'Note the first command uses the user name as a variable to map to a user share.
WSHNetwork.MapNetworkDrive "k:", "\\GANDALF\pupils\" & UserString,True
'MAPS a general share
WSHNetwork.MapNetworkDrive "U:", "\\gandalf\pupils",True
' THIS goes after USERSTRING WSHNetwork.UserName
'Clean Up Memory We Used
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing
'Quit the Script
wscript.quit
I wish to have an input box for the UserName and for it to then place this in the place of the user string. I post my effort below Thanks
'==========================================================================
'
' NAME: LogonScript.vbs
'
' AUTHOR: Mark D. MacLachlan, The Spider's Parlor
' URL : ' DATE : 4/10/2003
'
' COMMENT:
' Maps and disconnects drives
'
'
'==========================================================================
ON ERROR RESUME NEXT
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
'Automatically find the domain name
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
'Grab the user name
UserString ="fisk"
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
'Disconnect ALL mapped drives
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
Next
'Give the PC time to do the disconnect, wait 300 milliseconds
wscript.sleep 300
'Map drives needed by all
'Note the first command uses the user name as a variable to map to a user share.
WSHNetwork.MapNetworkDrive "k:", "\\GANDALF\pupils\" & UserString,True
'MAPS a general share
WSHNetwork.MapNetworkDrive "U:", "\\gandalf\pupils",True
' THIS goes after USERSTRING WSHNetwork.UserName
'Clean Up Memory We Used
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing
'Quit the Script
wscript.quit