TheAdmin Posted February 4, 2008 Posted February 4, 2008 Can someone show me the below converted from VBS to Autoit? On Error Resume Next Set objSysInfo = CreateObject("ADSystemInfo") Set objNetwork = CreateObject("Wscript.Network") strUserPath = "LDAP://" & objSysInfo.UserName Set objUser = GetObject(strUserPath) For Each strGroup in objUser.MemberOf strGroupPath = "LDAP://" & strGroup Set objGroup = GetObject(strGroupPath) strGroupName = objGroup.CN Select Case strGroupName Case "APP-Office" objNetwork.RemoveNetworkDrive "q:" objNetwork.MapNetworkDrive "q:", "\\umk-s01\data" Case "APP-Billing" objNetwork.RemoveNetworkDrive "j:" objNetwork.MapNetworkDrive "j:", "\\umk-n01\on" End Select Next
ame1011 Posted February 4, 2008 Posted February 4, 2008 (edited) $objSysInfo = ObjCreate("ADSystemInfo") $objNetwork = ObjCreate("Wscript.Network") $strUserPath = "LDAP://" & $objSysInfo.Username $objUser = ObjGet($strUserPath) for $strGroup in $objUser.MemberOf $strGroupPath = "LDAP://" & $strGroup $objGroup = ObjGet($strGroupPath) $strGroupName = $objGroup.CN Switch $strGroupName Case "APP-Office" $objNetwork.RemoveNetworkDrive("q:") $objNetwork.MapNetworkDrive("q:", "\\umk-s01\data") Case "APP-Billing" $objNetwork.RemoveNetworkDrive("j:") $objNetwork.MapNetworkDrive("j:", "\\umk-n01\on") EndSwitch Next Edited February 5, 2008 by ame1011 [font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]
TheAdmin Posted February 5, 2008 Author Posted February 5, 2008 $objSysInfo = ObjCreate("ADSystemInfo") $objNetwork = ObjCreate("Wscript.Network") $strUserPath = "LDAP:/?" & $objSysInfo.Username $objUser = ObjGet($strUserPath) for $strGroup in $objUser.MemberOf $strGroupPath = "LDAP://" & $strGroup $objGroup = ObjGet($strGroupPath) $strGroupName = $objGroup.CN Switch $strGroupName Case "APP-Office" $objNetwork.RemoveNetworkDrive("q:") $objNetwork.MapNetworkDrive("q:", "\\umk-s01\data") Case "APP-Billing" $objNetwork.RemoveNetworkDrive("j:") $objNetwork.MapNetworkDrive("j:", "\\umk-n01\on") EndSwitch Next Thank You for the reply I get an Error: for $strGroup in $objUser.MemberOf for $strGroup in $objUser ERROR Variable must be of type "Object".
Squirrely1 Posted February 5, 2008 Posted February 5, 2008 I see a typo on line 3 - the "?" should be a "/" Das Häschen benutzt Radar
TheAdmin Posted February 5, 2008 Author Posted February 5, 2008 I see a typo on line 3 - the "?" should be a "/"Good catch, now it has an error: $objNetwork.RemoveNetworkDrive("q:") ERROR
TheAdmin Posted February 5, 2008 Author Posted February 5, 2008 (edited) $objSysInfo = ObjCreate("ADSystemInfo") $objNetwork = ObjCreate("Wscript.Network") $strUserPath = "LDAP://" & $objSysInfo.UserName $objUser = ObjGet($strUserPath) For $strGroup in $objUser.MemberOf() $strGroupPath = "LDAP://" & $strGroup $objGroup = ObjGet($strGroupPath) $strGroupName = $objGroup.CN Select Case $strGroupName="App-Office" If FileExists("j:") Then $objNetwork.RemoveNetworkDrive ("j:") EndIf $objNetwork.MapNetworkDrive ("j:", "\\files\userdata") Case $strGroupName="APP-Billing" $objNetwork.RemoveNetworkDrive ("h:") $objNetwork.MapNetworkDrive ("h:", "\\files\data") EndSelect NextI am not getting an error from the mapping anymore.What other ways are there to determine if the drive exists? ThanksIf FileExists("j:") Then $objNetwork.RemoveNetworkDrive ("j:") EndIfAlso I get a Line -1Error: Variable must be of type "Object". on other workstations Edited February 5, 2008 by TheAdmin
weaponx Posted February 5, 2008 Posted February 5, 2008 Why aren't you creating the mapping using...DriveMapAddDriveMapDelDriveMapGet
ame1011 Posted February 5, 2008 Posted February 5, 2008 Good catch on the typo, fixed. I quickly did that in a couple minutes hence the typing mistake. [font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]
TheAdmin Posted February 5, 2008 Author Posted February 5, 2008 (edited) $objSysInfo = ObjCreate("ADSystemInfo") $objNetwork = ObjCreate("Wscript.Network") $strUserPath = "LDAP://" & $objSysInfo.UserName $objUser = ObjGet($strUserPath) For $strGroup in $objUser.MemberOf() $strGroupPath = "LDAP://" & $strGroup $objGroup = ObjGet($strGroupPath) $strGroupName = $objGroup.CN Select Case $strGroupName="App-Office" If FileExists("j:") Then $objNetwork.RemoveNetworkDrive ("j:") EndIf $objNetwork.MapNetworkDrive ("j:", "\\files\userdata") Case $strGroupName="APP-Billing" $objNetwork.RemoveNetworkDrive ("h:") $objNetwork.MapNetworkDrive ("h:", "\\files\data") EndSelect Next I get a Line -1 Error: Variable must be of type "Object". on other workstations Edited February 5, 2008 by TheAdmin
Squirrely1 Posted February 5, 2008 Posted February 5, 2008 I don't see any problem with this syntax: If FileExists("j:") Then But we do have the function IsObj: If Not IsObj($squirrely_business) Then The line checks to see if $squirrely_business is a variable containing an object type. Das Häschen benutzt Radar
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now