+ Post New Thread
Results 1 to 3 of 3
Scripts Thread, drive mapping vbs on windows rt in Coding and Web Development; Script works fine on win7/8/xp but aparantly on rt it fails (not my school and i dont have an rt ...
  1. #1


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,802
    Thank Post
    231
    Thanked 884 Times in 760 Posts
    Rep Power
    301

    drive mapping vbs on windows rt

    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
    Code:
    Set objNetwork = CreateObject("WScript.Network")
    )

    Code:
    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

  2. #2

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,562
    Thank Post
    1,469
    Thanked 1,221 Times in 830 Posts
    Rep Power
    752
    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

  3. #3


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,802
    Thank Post
    231
    Thanked 884 Times in 760 Posts
    Rep Power
    301
    Quote Originally Posted by LosOjos View Post
    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?

SHARE:
+ Post New Thread

Similar Threads

  1. GPP drive mapping issues on Windows 8
    By penfold in forum Windows 8
    Replies: 9
    Last Post: 12th September 2013, 03:37 PM
  2. Older Birchfield titles on Windows 7 / Mapped network drive
    By Norbert in forum Educational Software
    Replies: 2
    Last Post: 22nd July 2013, 11:27 AM
  3. Not getting Mapped network drives on windows 7
    By chekmate1984 in forum Windows Server 2008 R2
    Replies: 8
    Last Post: 11th October 2012, 04:35 PM
  4. Any suggestions - drive mapping fails on PC
    By e_g_r in forum Wireless Networks
    Replies: 3
    Last Post: 29th January 2009, 11:50 AM
  5. Replies: 4
    Last Post: 7th December 2005, 08:09 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •