Re: VBS script not running when user logs into windows



'**********************************************************************************
' Set Environment Variables
'*********************************************************************************
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set WSHShell = WScript.CreateObject("WScript.Shell")

On Error Resume Next

Domain = WSHNetwork.UserDomain
UserName = ""

While UserName = ""
UserName = WSHNetwork.UserName
MyGroups = GetGroups(Domain, UserName)
Wend

'*********************************************************************************
' Main Process:
'*********************************************************************************
GrpMeb UserName
ShowBox

Wscript.Quit

'*********************************************************************************
'Function: GetGroups
'*********************************************************************************
Function GetGroups(Domain, UserName)
Set objUser = GetObject("WinNT://" & Domain & "/" & UserName)
GetGroups=""
For Each objGroup In objUser.Groups
GetGroups=GetGroups & "[" & UCase(objGroup.Name) & "]"
Next
End Function

'********************************************************************************
'Function: InGroup
'********************************************************************************
Function InGroup(strGroup)
InGroup=False
If InStr(MyGroups,"[" & UCase(strGroup) & "]") Then
InGroup=True
End If
End Function

'*********************************************************************************
' MapDrives Subroutine
'*********************************************************************************
Sub MapDrive(sDrive,sShare)
On Error Resume Next
WSHNetwork.RemoveNetworkDrive sDrive, 1, 1
wscript.sleep 1000
Err.Clear
WSHNetwork.MapNetworkDrive sDrive,sShare
End Sub

'********************************************************************************
'Map Drives:
'********************************************************************************
Sub GrpMeb(UNAME)
If INGROUP ("domain users") Then
MapDrive "H:", "\\FILESERVER01\GENERAL OFFICE DOCUMENTS"
End If

If INGROUP ("Images Existing") Then
MapDrive "I:", "\\FILESERVER01\IMAGES EXISTING"
End If

If INGROUP ("domain users") Then
MapDrive "J:", "\\FILESERVER01\ACAD SUPPORT"
End If

If INGROUP ("domain users") Then
MapDrive "K:", "\\FILESERVER01\PROJECTS"
End If

If INGROUP ("Marketing") Then
MapDrive "M:", "\\FILESERVER01\MARKETING"
End If

If INGROUP ("Marketing") Then
MapDrive "O:", "\\FILESERVER01\POWERPOINTS"
End If

If INGROUP ("domain users") Then
MapDrive "P:", "\\FILESERVER01\EMPLOYEE STUFF\" & username
End If

If INGROUP ("domain users") Then
MapDrive "Q:", "\\FILESERVER01\COMMON"
End If

If INGROUP ("domain users") Then
MapDrive "R:", "\\FILESERVER01\REVIT SUPPORT"
End If

If INGROUP ("domain users") Then
MapDrive "S:", "\\FILESERVER01\PROJECTS2"
End If

If INGROUP ("MIS") Then
MapDrive "U:", "\\FILESERVER01\MIS"
End If

If INGROUP ("domain users") Then
MapDrive "W:", "\\FILESERVER01\ARCHIVES"
End If

If INGROUP ("administrators") Then
MapDrive "X:", "\\DAVINCI\APPS"
End If

Return = WSHShell.Run("\\DAVINCI\netlogon\runas\runprog.exe
\\DAVINCI\netlogon\runas\netsend.bat", 5, true)
Return = WSHShell.Run("regedit /s \\DAVINCI\netlogon\runas\dragdrop.reg", 5,
true)
Return = WSHShell.Run("\\DAVINCI\netlogon\runas\screensavercopy.bat", 5, true)
If INGROUP ("acad laptops") Then
Return = WSHShell.Run("\\DAVINCI\netlogon\runas\ACADLaptop.bat", 5, true)
End If
strCmd = "net.exe time Davinci /set /yes >null"
WshShell.Run strCmd, 0
End Sub
.



Relevant Pages

  • Map Users Personal Drive Help (VBScript, Login, Logon Script)
    ... I am working on converting our old batch login script files into ... as the username) on our server. ... If INGROUP ("domain users") Then ...
    (microsoft.public.scripting.vbscript)
  • Re: VBS script not running when user logs into windows
    ... I cannot see any problems with the script, all looks good, however something ... While UserName = "" ... If INGROUP ("domain users") Then ...
    (microsoft.public.windows.group_policy)
  • Re: locked out of XP - third party utility ?
    ... That sounds weird - username is case sensitive. ... right for logon locally may have been configured to be only domain users ... > on an WinXP laptop used by a sales rep, the system will apparently not let ... > is this done by WinXP or a third party utility? ...
    (microsoft.public.windowsxp.security_admin)
  • Re: VBScripting, need a little help
    ... I'm useing the Share name username$ under a folder called Home dir's simply ... > below is a copy of my current Login script, I map Drives and Printers ... > If INGROUP Then ...
    (microsoft.public.windows.server.scripting)
  • Re: Group Policy for WinXP local administrator rights
    ... give "domain users" admin rights to all workstations, ... will also gain admin rights over the network to other machines. ... > net localgroup administrators %username% /add ...
    (microsoft.public.windows.server.active_directory)

Quantcast