Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run based on Global Group in NT?

Status
Not open for further replies.

vb8304

IS-IT--Management
Mar 22, 2001
55
US
Is it possible to have part of the script run based on what department (Global Group) a person is in? For example, I have many different DOS scripts, one for each department since they each have different printers or Folders copied over. Now I am using a VBscript and would like to use one script for all departments. I guess have a script within a script?

Thanks.
Vincent.
 
Windows 2000 domain or Windows NT? Are you talking a logon script or a manually run script?

Here is a NT script I found on another page:

Code:
' written by jerry lees on 10/03/2000
' contact info: jerry-lees@home.com

' this is for 95/98 machines, they run login scripts before the user is logged on so the username will always return NULL
' Note: there is a technet article on this topic... took me a while to find it, (hope this helps someone)

Dim UserName
Username = ""

While UserName = ""
     on error resume next
     Set WSHNetwork = CreateObject("WScript.Network")
     on error resume next
     UserName = UCASE(WSHNetwork.UserName)
     on error resume next
     Set WSHNetwork = Nothing
WEnd

' end 95/98 wile/wend loop

' replace YOURDOMAIN with your domain name.
Set adsDomainGroups = GetObject("WinNT://YOURDOMAIN")
adsDomainGroups.Filter = Array("Group")

for each adsGroup in adsDomainGroups

 Group = Ucase(adsgroup.name)
 ' add new groups and drives below here
 If group = UCASE("Domain Admins") then CheckGroup adsgroup.name, Username, "J:", "\\server1\sysadmin"
 If group = UCASE("Admins") then CheckGroup adsgroup.name, Username, "J:", "\\server3\sysadmin"
 If group = UCASE("Producers") then CheckGroup adsgroup.name, Username, "R:", "\\server2\ProjectDocs"
 If group = UCASE("Sales") then CheckGroup adsgroup.name, Username, "S:", "\\server3\Sales"
 If group = UCASE("Administrative") then CheckGroup adsgroup.name, Username, "M:", "\\server2\Administrative"
 If group = UCASE("Accounting") then CheckGroup adsgroup.name, Username, "Q:", "\\server3\accntng"
 If group = UCASE("reports") then CheckGroup adsgroup.name, Username, "O:", "\\Server4\reports"
 If group = UCASE("doorway") then CheckGroup adsgroup.name, Username,"W:","\\server5\doorway"

next
set adsuser = Nothing
set adsDomain = nothing

'the line below was here for testing purposes and debugging
'msgbox("DONE!")

sub CheckGroup(GroupName, username, Drive, unc)
'the line below was here for testing purposes and debugging
' MsgBox(groupname & " - " & username)

' replace YOURDOMAIN with your domain name.
 Set AdsGroup = GetObject("WinNT://YOURDOMAIN/" & GroupName)

 Set ADSGROUPMEMBERSHIP = AdsGroup.Members()
 for each adsUser in adsgroupmembership
  If UCase(adsUser.name) = username Then MapDrive Drive, UNC
 next
End Sub

Sub mapdrive (driveletter, UNCString)
' MsgBox("Mapping Drive!")
 Set WSHNetwork = WScript.CreateObject("WScript.Network")
 On Error Resume Next
 WSHNetwork.MapNetworkDrive driveletter, Uncstring
End sub

I did not write the above and have not tested it.

On windows 2000 domain it would be similiar and the script can be extrapolated from the above. If you need any help I can post some sample source for Win2k.

Roger
 
use kix32

This product works great for what you are asking. It lets you use an "IF in Group" command and works great. You can all use "if in subnet"....and many other uses.

Do a search on the net for kix32. I also think it is in the NT res kit....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top