Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

i think i got this script off this site, but just need a little help...

 



Const Staff 		= "cn=staff"
Const Maths 		= "cn=mathematics"
Const PowerStaff 	= "cn=powerstaff"
Const ITTeach 		= "cn=information technology"
Const ITAdmin 		= "cn=admin"
Const DesignTechnology	= "cn=design technology"
Const H2L		= "cn=special needs"

' admin settings

Const AdminStaff	= "cn=generaladmin"
Const OfficeGroup	= "cn=Office Group"


	Set wshnetwork = CreateObject("WScript.Network")
	Set ADSysInfo = CreateObject("ADSystemInfo")
	Set CurrentUser = GetObject("LDAP://" & ADSysInfo.Username)
	strGroups = LCase(Join(CurrentUser.MemberOf))


' general users

		

If Instr(strGroups,staff) Then
On Error Resume Next
		wshnetwork.RemoveNetworkDrive "p:"
		wshnetwork.RemoveNetworkDrive "s:"
		wshnetwork.RemoveNetworkDrive "v:"
		wshnetwork.RemoveNetworkDrive "q:"			

		wshNetwork.MapNetworkDrive "p:","\\hades\upublic"
		wshNetwork.MapNetworkDrive "s:","\\hades\business"
		wshNetwork.MapNetworkDrive "v:","\\hades\uapps"
		wshnetwork.mapnetworkdrive "q:","\\seth\users\home\administration"


If Instr(strGroups,ITAdmin) Then

 

In the part between ' general users and the first IF statement is there a string that i can add to remove all network drives apart form U: as this is the users userarea. Ive tried

wshnetwor.Removenetworkconnection <> "u:"

but that didnt work. Can any one suggest anything??

 

Thanks

 

T

Posted

Missing the letter 'k' before the first dot.

 

 

but seriously what you have written would test the return value ot the removeConnection method agains the string literal "u:"

 

I seem to remember that WSH or VBS had a drives collection.

 

You could foreach through that and assign each letter to counter variable then remove connections if that variable isn't equal to "u:"

  • 1 month later...
Posted

just use a select case so

 

Dim drv as string

drv = Instr(strGroups,staff)

select case drv

 

Case "u:":

Case Else:

wshnetwork.removenetworkdrive drv

End Select

 

Assuming that drv is the drive letter that you want removing, that way it wont do nothing to the U drive and will remove the rest, but will check it out later on if that does not work

Posted
just use a select case so

 

Dim drv as string

drv = Instr(strGroups,staff)

select case drv

 

Case "u:":

Case Else:

wshnetwork.removenetworkdrive drv

End Select

 

Assuming that drv is the drive letter that you want removing, that way it wont do nothing to the U drive and will remove the rest, but will check it out later on if that does not work

 

The select case would only remove one drive if it's not u: (in which case it deletes nothing).

 

You either have to put the select within a loop or reverse the test and explictly list all the drives you want deleted and then the Case Else will catch anthything that shouldn't be deleted.

Posted

You will need to enumerate all mapped drive something like this

 

Set clPrinters = objNetwork.EnumPrinterConnections  
	On Error Resume Next 
	For i = 0 to clPrinters.Count - 1 Step 2 
	objNetwork.RemovePrinterConnection clPrinters.Item(i+1), true 
	Next 

 

This will delete all mapped drives so you would have to re-map U: after.

Posted
just use a select case so

 

Dim drv as string

drv = Instr(strGroups,staff)

select case drv

 

Case "u:":

Case Else:

wshnetwork.removenetworkdrive drv

End Select

 

Assuming that drv is the drive letter that you want removing, that way it wont do nothing to the U drive and will remove the rest, but will check it out later on if that does not work

 

The select case would only remove one drive if it's not u: (in which case it deletes nothing).

 

You either have to put the select within a loop or reverse the test and explictly list all the drives you want deleted and then the Case Else will catch anthything that shouldn't be deleted.

 

Yeah I wasnt sure that it would work cos it didnt seem right but I had to run off and carry on with work related stuff so didnt really have a chance to do it correctly.

 

Ive just done a mapping network drives script and made a function to do the enumerating of mapped drives and remove them if they are already mapped and then map them etc

 

I can post what I have done and you can just alter it to your needs , if thats of any use ?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...