authentication - VBS- Login script to map drive with multiple NICs -
i trying create script map drive @ logon per ip address or subnet. able find 1 script works on single mic, thre few machines have 2 nics, , not work them.
here modified script.
set objnetwork = createobject("wscript.network") strcomputer = "." set objwmiservice = getobject("winmgmts:\\" & strcomputer & "\root\cimv2") set coladapters = objwmiservice.execquery _ ("select * win32_networkadapterconfiguration ipenabled=true") redim arrsubnets(-1) each objadapter in coladapters each straddress in objadapter.ipaddress arroctets = split(straddress, ".") if arroctets(0) <> "" redim preserve arrsubnets(ubound(arrsubnets)+1) arrsubnets(ubound(arrsubnets)) = arroctets(0) & "." & arroctets(1) & "." _ & arroctets(2) end if next next set colitems = objwmiservice.execquery _ ("select * win32_logicaldisk deviceid = 'g:'") if colitems.count = 0 strsubnet = arrsubnets(ubound(arrsubnets)) select case strsubnet case "10.1.1" objnetwork.mapnetworkdrive "g:", "\\10.1.1.62\zshared",true objnetwork.mapnetworkdrive "f:", "\\10.1.1.62\zshared2",true case "10.1.20" objnetwork.mapnetworkdrive "g:", "\\10.1.20.150\sharedch",true objnetwork.mapnetworkdrive "f:", "\\10.1.20.150\sharedch1",true end select end if
you use arrsubnets
without initializing (or resizing) it. also, you're trying echo arrsubnetips(i)
when should echoing arrsubnets(i)
. change this:
i = 0 each objadapter in coladapters each straddress in objadapter.ipaddress arroctets = split(straddress, ".") if arroctets(0) <> "" arrsubnets(i) = arroctets(0) & "." & arroctets(1) & "." & arroctets(2) = + 1 wscript.echo arrsubnetips(i) end if next next
into this:
redim arrsubnets(-1) each objadapter in coladapters each straddress in objadapter.ipaddress arroctets = split(straddress, ".") if arroctets(0) <> "" redim preserve arrsubnets(ubound(arrsubnets)+1) arrsubnets(ubound(arrsubnets)) = arroctets(0) & "." & arroctets(1) & "." _ & arroctets(2) wscript.echo arrsubnets(ubound(arrsubnets)) end if next next
Comments
Post a Comment