Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTA to Map Variable Path 1

Status
Not open for further replies.

kurio71

Technical User
Oct 1, 2009
172
MX
Greetings, I've doctored a script to map drives which works except I can't map folders with variable paths. The script is to be run from non-domain computers to map student folders on the network. I can't seem to get the students' Home folder mapped which path has a directory variable of graduation year & name. The syntax used to map is - MapDrive "H:","\\192.168.4.33\Homes\" & lisYear.value & "\" & txtName to map a folder with the path of e.g \\192.168.4.33\Homes\Grad2017\tuser. Would like assistance with syntax, thanks.

<html>
<head>
<title>Drive Mapper</title>
<HTA:APPLICATION
APPLICATIONNAME="Drive Mapper"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
<STYLE>
body {
padding-top:20px;
text-align:center;
}
td,input {
font-family:Verdana;
font-size:12pt;
}
a {
font-size:9pt;
font-family:Verdana;
}
</STYLE>
<SCRIPT LANGUAGE=VBScript>
Set objNetwork = CreateObject("Wscript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Sub Window_OnLoad
Dim X, Y, strComputer, objWMIService, colItems, objItem, intHorizontal, strYear
X=500
Y=300
window.resizeTo X,Y
' resize the HTA
strComputer = "."
Set objWMIService = GetObject("Winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next
window.moveTo (intHorizontal - X) / 2, (intVertical - Y) / 2
' centre it
txtName.value=objNetwork.UserName
txtName.focus
End Sub

Sub btnConfigure_OnClick
If txtName.value="" Then
MsgBox "Please enter your name",16,"ERROR"
txtName.focus
Exit Sub
End If
If txtPassword.value="" Then
MsgBox "Please enter your password",16,"ERROR"
txtPassword.focus
Exit Sub
End If

MapDrive "O:","\\192.168.4.33\Hand Outs"
MapDrive "I:","\\192.168.4.33\Hand Ins"
MapDrive "L:","\\192.168.4.33\LC Resources"
MapDrive "H:","\\192.168.4.33\Homes\" & lisYear.value & "\" & txtName
MsgBox "Network resources have been mapped",64,"DONE"
End Sub

Sub MapDrive(DriveLetter,DrivePath)
If objFSO.DriveExists(DriveLetter) Then
objNetwork.RemoveNetworkDrive DriveLetter,true
End If
objNetwork.MapNetworkDrive DriveLetter, DrivePath, false, txtName.value, txtPassword.value
End Sub
</SCRIPT>
</head>
<body>
<table>
<tr>
<td>What is your graduation year?</td>
<td><select size="1" name="lisYear" id="lisYear">
<option value="Grad2020">2020</option>
<option value="Grad2019">2019</option>
<option value="Grad2018">2018</option>
<option value="Grad2017">2017</option>
<option value="Grad2016">2016</option>
<option value="Grad2015">2015</option>
<option value="Grad2014">2014</option>
<option value="Grad2013">2013</option>
</select></td>
</tr>

<tr>
<td>What is your school domain username?<br/><a>(example: igs\jsmith)</a></td>
<td><input type="text" name="txtName" /></td>
</tr>

<tr>
<td>What is your school domain password?</td>
<td><input type="password" name="txtPassword" /></td>
</tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td><input type="submit" value="Map resources" id="btnConfigure" /></td></tr>
</table>
</body>
</html>

Level 1 Support Technician
 
Hi [peace]
I think you mess something like this:
Code:
MapDrive "H:","\\192.168.4.33\Homes\" & lisYear.value & "\" & [b][s]txtName[/s][/b]
Try this :
Code:
MapDrive "H:","\\192.168.4.33\Homes\" & lisYear.value & "\" & txtName.value
 
Big thanks, that worked.

Level 1 Support Technician
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top