Jump to content

drive mapping vbs on windows rt


Recommended Posts

Posted

Script works fine on win7/8/xp but aparantly on rt it fails (not my school and i dont have an rt device to test on)

rterror.jpg

 

(i know its also probably not the best bit of coding ever but i cant see why it would fail on

Set objNetwork = CreateObject("WScript.Network")

)

 

Option Explicit
Dim strUser, strPassword, strDriveLetter, strHomeServer, strProfile, yg, yeargroup
Dim objNetwork, Message, Title, message2, title2, oShellApp
Set objNetwork = CreateObject("WScript.Network")
Set oShellApp = CreateObject("Shell.Application")

on error resume next

'remove old mappings
objNetwork.RemoveNetworkDrive "R:"
objNetwork.RemoveNetworkDrive "u:"
objNetwork.RemoveNetworkDrive "v:"

' Define dialog box variables.
Message = "What is your username"           
Title = "Logon Box"
Message2 = "What is your password"
Title2 = "User input canceled"

'ask for username
struser = InputBox(Message, Title, "", 100, 100)
'ask for password
strPassword = InputBox(Message2, Title2, "", 100, 100)
'strip left most character from username to determine yeargroup
yg= Left(struser,1)
'display left character for testing
'wscript.echo yg

'calculate yeargroup from first character
if (yg ="1")or(yg ="2")or(yg ="3")or(yg ="4")or(yg ="5")or(yg ="6")or(yg ="7")or(yg ="8")or(yg ="9")or(yg ="0") then
'wscript.echo "is a number"
if yg="1"then
	Yeargroup="2011"
elseif yg = "2" then
	Yeargroup="2012"
elseif yg = "3" then
	Yeargroup="2013"
elseif yg = "4" then
	Yeargroup="2014"
elseif yg = "5" then
	Yeargroup="2015"
elseif yg = "6" then
	Yeargroup="2006"
elseif yg = "7" then
	Yeargroup="2007"
elseif yg = "8" then
	Yeargroup="2008"
elseif yg = "9" then
	Yeargroup="2009"
elseif yg = "0" then
	Yeargroup="2010"		
end if
end if
if yg >"9" then
Yeargroup="staff"
end if
'display yeargroup for testing
'wscript.echo Yeargroup

'define drive 1
strDriveLetter = "r:" 
strHomeServer = "\\server1\resources$"
strProfile = "False" ' Mapping (not) stored in user Profile

'map drive 1
objNetwork.MapNetworkDrive strDriveLetter,strHomeServer,strProfile,strUser,strPassword 
'name drive 1
oShellApp.NameSpace(strDriveLetter & "\").Self.Name = "Resources"
'end drive 1

'maps v drive if user is staff
if yeargroup="staff" then

'define drive 2
strDriveLetter = "v:" 
strHomeServer = "\\server1\users$"
strProfile = "False" ' Mapping (not) stored in user Profile

'map drive 2
objNetwork.MapNetworkDrive strDriveLetter,strHomeServer,strProfile,strUser,strPassword 
'name drive 2
oShellApp.NameSpace(strDriveLetter & "\").Self.Name = "Users"
'end drive 2
end if

'define drive 3
'check if staff for redirection$
strDriveLetter = "u:" 

if yeargroup ="staff" then
strHomeServer = "\\server1\redirection$\" & yeargroup & "\" & strUser
end if
'check pupils for users$
if (yg ="1") or (yg ="2") or(yg ="3") or(yg ="4") or(yg ="5") or(yg ="6") or(yg ="7") or(yg ="8") or(yg ="9") or(yg ="0") then
strHomeServer = "\\server1\users$\" & yeargroup & "\" & strUser
end if

wscript.echo strhomeserver
strProfile = "False" ' Mapping (not) stored in user Profile
'wscript.echo strHomeServer
'map drive 3
objNetwork.MapNetworkDrive strDriveLetter,strHomeServer,strProfile,strUser,strPassword 
'name drive 3
oShellApp.NameSpace(strDriveLetter & "\").Self.Name = "My User Area"
'end drive 3


WScript.Quit

Posted
I believe that VBS is heavily restricted in RT unless you choose to run a script as Admin, not sure how you could automate that though. Easiest way to confirm that is the issue is to get the user to right-click the script and choose "Run as admin..." - if it works, you need to figure out a way of getting the script to run as admin by default. Unfortunately, I don't have an RT device to try it on
Posted
I believe that VBS is heavily restricted in RT unless you choose to run a script as Admin, not sure how you could automate that though. Easiest way to confirm that is the issue is to get the user to right-click the script and choose "Run as admin..." - if it works, you need to figure out a way of getting the script to run as admin by default. Unfortunately, I don't have an RT device to try it on

 

thats my issue wonder if there is some way of vming an rt device?

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...