Avatar of Gabriel Clifton
Gabriel Clifton
Flag for United States of America asked on

Rename computer HTA Script HELP!!!

I am trying to create a HTA script for renaming computers with multiple drop-down menus. First menu will ask for the campus name, one of 11 buildings. Upon selection of campus the second drop-down will populate with room numbers, which the numbering scheme is different for each campus. I.E. campus one has letters in their room number, the second campus is rooms 1-25, third campus is 100-150, and another campus does not have room "numbers" but the rooms are names. When the room number is selected, the third drop-down box will simply ask if the computer is a desktop or laptop. Next drop-down will ask if the computer is for a student or teacher. Finally, the last drop-down will ask for the computer number, which if it is a teacher computer, there will be no more than 6 computers in a room and if a student computer no more than 45 computers. After all drop-down menus have been selected then a text-box will show the crafted naming scheme which will allow the computer name to be changed for any special computers. So if I am in building 1 in room 3 with the fourth student desktop it will construct B1RM003DS04, rename computer with constructed name and reboot. Most of the computers will be on the domain already, but if not ask to join the domain as well. Also, it would be nice if it could check to see if the computer name generated is already taken before submitting the computer rename.
With what I have so far, when I run Generate Name (which I would like to make it automatically update every time a make a change to the drop down) instead of getting ALRMC01DT01 I get 1RM20111. I just don't know how to translate that. Once that is done, I would like to add a text box that automatically gets and displays current computer name for the rename process but allows you to type in another computer name for remote rename.
I have spent two frustrating days on this and as I just dabble in VBScript and HTA I am just at a loss.
 
I am wanting this because I am tired of our technicians renaming computers that do not fit our naming scheme.

<select id=sel_campus>
</select>
<select id=sel_room>
</select>
<select id=sel_computer>
</select>
<select id=sel_level>
</select>
<select id=sel_number>
</select>

<script language=vbscript>

option explicit

sub add_option (select_id, value, text)
dim opt : set opt = document.createelement("option")
opt.value = value
opt.text = text
select_id.add opt
set opt = nothing
end sub

sub load_combo (select_id, option_array)
dim i: for i = 0 to ubound(option_array)
add_option select_id, i, option_array(i)
next
end sub

sub clear_combo (select_id)
select_id.options.length = 0
end sub

dim campus : campus = array ("Campus", "Alamo", "Apache", "Intermediate", "Middle School", "High School", "Butz", "Food Services", "Central Office", "Maintenance / Bus Barn", "Special Services", "Technology")
load_combo sel_campus, Campus

dim alamo_rooms : alamo_rooms = split ("Room,A01,A02,A03,A04,A05,A06,A07,A08,A09,A10," _
& "B01,B02,B03,B04,B05,B06,B07,B08,B09," _
& "C01,C02,C03,C04,C05,C06,C07,C08,C09,C10,C11," _
& "D01,D02,D03,D04,D05,D06,D07,D08,D09,D10,D11", ",")
dim apache_rooms : apache_rooms = split ("Room,001,002,003,004,005,006,007,008,009,010," _
& "011,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,326,327,328,329,330," _
& "331,332,333,334,335",",")
dim intermediate_rooms : intermediate_rooms = split ("Room,001,002,003,004,005,006,007,008,009,010," _
& "010,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,026,027,028",",")
dim ms_rooms : ms_rooms = split ("Room,101,102,103,104,105,106,107,108,109,110," _
& "111,112,113,114,115,116,117,118,119,120," _
& "121,122,123,124,125,126,127,128,129,130," _
& "131,132,133,134,135,136,137,138,139,140," _
& "141,142,143,144,145,146,147,148,149,150,151",",")
dim hs_rooms : hs_rooms = split ("Room,001,002,003,004,005,006,007,008,009,010," _
& "010,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,026,027,028,029,030," _
& "031,31A,032,033,034,035,036,037,038,039,040," _
& "041,042,043,044,045,046,047,048,049,050,051,052",",")


dim com_num : com_num = split ("Computer Number,01,02,03,04,05,06,07,08,09,10," _
& "10,12,13,14,15,16,17,18,19,20," _
& "21,22,23,24,25,26,27,28,29,30," _
& "31,32,33,34,35,36,37,38,39,40," _
& "41,42,43,44,45,46,47,48,49,50,51,52",",")
Dim com_level : com_level = Split ("User Type,Teacher,Student",",")
Dim com_type : com_type = Split ("Computer Type,Desktop,Laptop",",")

sub sel_campus_onchange
clear_combo sel_room
select case sel_campus.text
Case 0 'Campus
Case 1 'Alamo
load_combo sel_room, alamo_rooms
Case 2 'Apache
load_combo sel_room, apache_rooms
Case 3 'Intermediate
load_combo sel_room, intermediate_rooms
Case 4 'Middle School
load_combo sel_room, ms_rooms
Case 5 'High School
load_combo sel_room, hs_rooms
Case 6 'Butz
load_combo sel_room, alamo_rooms
Case 7 'Food Services
load_combo sel_room, alamo_rooms
Case 8 'Central Office
load_combo sel_room, alamo_rooms
Case 9 'Maintenance / Bus Barn
load_combo sel_room, alamo_rooms

End select
end Sub

sub sel_room_onchange
clear_combo sel_computer
select case sel_room.value
Case 0 'Room Numbers
case 1 'Room 1
load_combo sel_computer, com_type
Case 2 'Room 2
load_combo sel_computer, com_type
Case 3 'Room 3
load_combo sel_computer, com_type
Case 4 'Room 4
load_combo sel_computer, com_type
Case 5 'Room 5
load_combo sel_computer, com_type
Case 6 'Room 6
load_combo sel_computer, com_type
Case 7 'Room 7
load_combo sel_computer, com_type
Case 8 'Room 8
load_combo sel_computer, com_type
Case 9 'Room 9
load_combo sel_computer, com_type
Case 10 'Room 10
load_combo sel_computer, com_type
Case 11 'Room 11
load_combo sel_computer, com_type
Case 12 'Room 12
load_combo sel_computer, com_type
Case 13 'Room 13
load_combo sel_computer, com_type
Case 14 'Room 14
load_combo sel_computer, com_type
Case 15 'Room 15
load_combo sel_computer, com_type
Case 16 'Room 16
load_combo sel_computer, com_type
Case 17 'Room 17
load_combo sel_computer, com_type
Case 18 'Room 18
load_combo sel_computer, com_type
Case 19 'Room 19
load_combo sel_computer, com_type
Case 20 'Room 20
load_combo sel_computer, com_type
Case 21 'Room 21
load_combo sel_computer, com_type
Case 22 'Room 22
load_combo sel_computer, com_type
Case 23 'Room 23
load_combo sel_computer, com_type
Case 24 'Room 24
load_combo sel_computer, com_type
Case 25 'Room 25
load_combo sel_computer, com_type
Case 26 'Room 26
load_combo sel_computer, com_type
Case 27 'Room 27
load_combo sel_computer, com_type
Case 28 'Room 28
load_combo sel_computer, com_type
Case 29 'Room 29
load_combo sel_computer, com_type
Case 30 'Room 30
load_combo sel_computer, com_type
Case 31 'Room 31
load_combo sel_computer, com_type
Case 32 'Room 32
load_combo sel_computer, com_type
Case 33 'Room 33
load_combo sel_computer, com_type
Case 34 'Room 34
load_combo sel_computer, com_type
Case 35 'Room 35
load_combo sel_computer, com_type
Case 36 'Room 36
load_combo sel_computer, com_type
Case 37 'Room 37
load_combo sel_computer, com_type
Case 38 'Room 38
load_combo sel_computer, com_type
Case 39 'Room 39
load_combo sel_computer, com_type
Case 40 'Room 40
load_combo sel_computer, com_type
Case 41 'Room 41
load_combo sel_computer, com_type
Case 42 'Room 42
load_combo sel_computer, com_type
Case 43 'Room 43
load_combo sel_computer, com_type
Case 44 'Room 44
load_combo sel_computer, com_type
Case 45 'Room 45
load_combo sel_computer, com_type
Case 46 'Room 46
load_combo sel_computer, com_type
Case 47 'Room 47
load_combo sel_computer, com_type
Case 48 'Room 48
load_combo sel_computer, com_type
Case 49 'Room 49
load_combo sel_computer, com_type
Case 50 'Room 50
load_combo sel_computer, com_type
Case 51 'Room 51
load_combo sel_computer, com_type
Case 52 'Room 52
load_combo sel_computer, com_type
Case 53 'Room 53
load_combo sel_computer, com_type
Case 54 'Room 54
load_combo sel_computer, com_type
Case 55 'Room 55
load_combo sel_computer, com_type
end select
end Sub

sub sel_computer_onchange
clear_combo sel_level
select case sel_computer.value
Case 0 'Computer Type
case 01 'Desktop
load_combo sel_level, com_level
Case 02 'Laptop
load_combo sel_level, com_level
end select
end Sub

sub sel_level_onchange
clear_combo sel_number
select case sel_level.value
Case 0 'Computer Number
case 1 'Computer 1
load_combo sel_number, com_num
Case 2 'Computer 2
load_combo sel_number, com_num
end select
end Sub

Sub RunScript
  ComputerName.value = sel_campus.value & "RM" & sel_room.value & " " & sel_computer.value & " " & sel_level.value & " " & sel_number.value
End Sub


</script>

<body bgcolor="white">
<p>
    <button onclick="RunScript">Generate Name</button> <br>
<p>Computer Name<BR>
<input type=text id="ComputerName" name=ComputerName size=45></p>

    
    
</body>
</html>

Open in new window

VB ScriptHTMLScripting Languages

Avatar of undefined
Last Comment
Gabriel Clifton

8/22/2022 - Mon
sirbounty

First problem - around line 70:
select case sel_campus.text '<<< should be sel_campus.value

Then replace this entire sub:

Sub RunScript
  Dim DeviceType, PersonType
  If sel_computer.value = 1 then 
    DeviceType = "D"
  Else 
    DeviceType = "L"
  End If
  If sel_level.value = 1 Then
    PersonType = "T"
  Else
    PersonType = "S"
  End If
  ComputerName.value = "B" & sel_campus.value & "RM" & Right("00" & sel_room.value,3) & DeviceType & PersonType & Right("0" & sel_number.value, 2)
End Sub

Open in new window

SOLUTION
sirbounty

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Gabriel Clifton

ASKER
WOW, now I need help on the room numbers, each campus room numbers are different, lines 38 - 59 and other campuses that I have not put in here yet. Then it will be text box that gets computer name or lets the tech input remote computer name and for the finally rename computer.

<select id=sel_campus>
</select>
<select id=sel_room>
</select>
<select id=sel_computer>
</select>
<select id=sel_level>
</select>
<select id=sel_number>
</select>

<script language=vbscript>

option explicit

sub add_option (select_id, value, text)
dim opt : set opt = document.createelement("option")
opt.value = value
opt.text = text
select_id.add opt
set opt = nothing
end sub

sub load_combo (select_id, option_array)
dim i: for i = 0 to ubound(option_array)
add_option select_id, i, option_array(i)
next
end sub

sub clear_combo (select_id)
select_id.options.length = 0
end sub

'Campus Names
dim campus : campus = array ("Campus", "Alamo", "Apache", "Intermediate", "Middle School", "High School", "Butz", "Food Services", "Central Office", "Maintenance / Bus Barn", "Special Services", "Technology")
load_combo sel_campus, Campus

'Campus Room Numbers
dim alamo_rooms : alamo_rooms = split ("Room,A01,A02,A03,A04,A05,A06,A07,A08,A09,A10," _
& "B01,B02,B03,B04,B05,B06,B07,B08,B09," _
& "C01,C02,C03,C04,C05,C06,C07,C08,C09,C10,C11," _
& "D01,D02,D03,D04,D05,D06,D07,D08,D09,D10,D11", ",")
dim apache_rooms : apache_rooms = split ("Room,001,002,003,004,005,006,007,008,009,010," _
& "011,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,326,327,328,329,330," _
& "331,332,333,334,335",",")
dim intermediate_rooms : intermediate_rooms = split ("Room,001,002,003,004,005,006,007,008,009,010," _
& "010,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,026,027,028",",")
dim ms_rooms : ms_rooms = split ("Room,101,102,103,104,105,106,107,108,109,110," _
& "111,112,113,114,115,116,117,118,119,120," _
& "121,122,123,124,125,126,127,128,129,130," _
& "131,132,133,134,135,136,137,138,139,140," _
& "141,142,143,144,145,146,147,148,149,150,151",",")
dim hs_rooms : hs_rooms = split ("Room,001,002,003,004,005,006,007,008,009,010," _
& "010,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,026,027,028,029,030," _
& "031,31A,032,033,034,035,036,037,038,039,040," _
& "041,042,043,044,045,046,047,048,049,050,051,052",",")

'User Type
Dim com_level : com_level = Split ("User Type,Teacher,Student",",")
'Computer Type
Dim com_type : com_type = Split ("Computer Type,Desktop,Laptop",",")

'Computer Numbers
dim com_num : com_num = split ("Computer Number,01,02,03,04,05,06,07,08,09,10," _
& "10,12,13,14,15,16,17,18,19,20," _
& "21,22,23,24,25,26,27,28,29,30," _
& "31,32,33,34,35,36,37,38,39,40," _
& "41,42,43,44,45,46,47,48,49,50,51,52",",")

sub sel_campus_onchange
clear_combo sel_room
select case sel_campus.value
Case 0 'Campus
Case 1 'Alamo
load_combo sel_room, alamo_rooms
Case 2 'Apache
load_combo sel_room, apache_rooms
Case 3 'Intermediate
load_combo sel_room, intermediate_rooms
Case 4 'Middle School
load_combo sel_room, ms_rooms
Case 5 'High School
load_combo sel_room, hs_rooms
Case 6 'Butz
load_combo sel_room, alamo_rooms
Case 7 'Food Services
load_combo sel_room, alamo_rooms
Case 8 'Central Office
load_combo sel_room, alamo_rooms
Case 9 'Bus Barn
load_combo sel_room, alamo_rooms

End select
end Sub

sub sel_room_onchange
  clear_combo sel_computer
  if sel_room.value = 0 Then exit sub
  load_combo sel_computer, com_type
end Sub

sub sel_computer_onchange
clear_combo sel_level
select case sel_computer.value
Case 0 'Computer Type
case 01 'Desktop
load_combo sel_level, com_level
Case 02 'Laptop
load_combo sel_level, com_level
end select
end Sub

sub sel_level_onchange
clear_combo sel_number
select case sel_level.value
Case 0 'Computer Number
case 1 'Computer 1
load_combo sel_number, com_num
Case 2 'Computer 2
load_combo sel_number, com_num
end select
end Sub

Sub RunScript
  Dim CampusName, DeviceType, PersonType
  If sel_campus.value = 1 Then
  	CampusName = "AL"
  ElseIf sel_campus.value = 2 Then
  	CampusName = "AP"
  ElseIf sel_campus.value = 3 Then
  	CampusName = "IN"
  ElseIf sel_campus.value = 4 Then
  	CampusName = "MS"
  ElseIf sel_campus.value = 5 Then
  	CampusName = "HS"
  ElseIf sel_campus.value = 6 Then
  	CampusName = "BU"
  ElseIf sel_campus.value = 7 Then
  	CampusName = "IN"
  ElseIf sel_campus.value = 8 Then
  	CampusName = "CO"
  ElseIf sel_campus.value = 9 Then
  	CampusName = "BB"
  End If
  If sel_computer.value = 1 then 
    DeviceType = "D"
  Else 
    DeviceType = "L"
  End If
  If sel_level.value = 1 Then
    PersonType = "T"
  Else
    PersonType = "S"
  End If
  ComputerName.value = CampusName & "RM" & Right("00" & sel_room.value,3) & DeviceType & PersonType & Right("0" & sel_number.value, 2)
End Sub

</script>

<body bgcolor="white">
<p>
    <button onclick="RunScript">Generate Name</button> <br>
<p>Computer Name<BR>
<input type=text id="ComputerName" name=ComputerName size=45></p>

</body>
</html>

Open in new window

SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
sirbounty

Cross posted - not sure I follow your last statement...
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Gabriel Clifton

ASKER
All of our campuses have different naming schemes, one has letters with numbers, one starts at 001, one starts at 100, another uses names instead of numbers. How can I get the room number for that specific campus.

dim alamo_rooms : alamo_rooms = split ("Room,A01,A02,A03,A04,A05,A06,A07,A08,A09,A10," _
& "B01,B02,B03,B04,B05,B06,B07,B08,B09," _
& "C01,C02,C03,C04,C05,C06,C07,C08,C09,C10,C11," _
& "D01,D02,D03,D04,D05,D06,D07,D08,D09,D10,D11", ",")
dim apache_rooms : apache_rooms = split ("Room,001,002,003,004,005,006,007,008,009,010," _
& "011,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,326,327,328,329,330," _
& "331,332,333,334,335",",")
dim intermediate_rooms : intermediate_rooms = split ("Room,001,002,003,004,005,006,007,008,009,010," _
& "010,012,013,014,015,016,017,018,019,020,021,022,023,024,025,026,027,028",",")
dim ms_rooms : ms_rooms = split ("Room,101,102,103,104,105,106,107,108,109,110," _
& "111,112,113,114,115,116,117,118,119,120," _
& "121,122,123,124,125,126,127,128,129,130," _
& "131,132,133,134,135,136,137,138,139,140," _
& "141,142,143,144,145,146,147,148,149,150,151",",")
dim hs_rooms : hs_rooms = split ("Room,001,002,003,004,005,006,007,008,009,010," _
& "010,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,026,027,028,029,030," _
& "031,31A,032,033,034,035,036,037,038,039,040," _
& "041,042,043,044,045,046,047,048,049,050,051,052",",")
dim com_num : com_num = split ("Computer Number,01,02,03,04,05,06,07,08,09,10," _
& "10,12,13,14,15,16,17,18,19,20," _
& "21,22,23,24,25,26,27,28,29,30," _
& "31,32,33,34,35,36,37,38,39,40," _
& "41,42,43,44,45,46,47,48,49,50,51,52",",")

Open in new window

sirbounty

Well, you can follow the same pattern that you have here, or you can source it from a database/table/text file, etc...
Otherwise, for numerical numbering, you could set up a loop to create the array elements and just pass the start/end parameters to a function that would build the array for you.
Gabriel Clifton

ASKER
OK, could you explain the array a bit more. I do not want a separate file.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Gabriel Clifton

ASKER
I have been playing with carrying on with the format of the other fields. It does work, but with about sixty rooms per campus and ten campuses, that is a ton of if elseif statements and a bunch of extra lines I think that are a waste. Any help on an array would be greatly appreciated.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
sirbounty

Of course, if we set this up a bit differently, then you might be able to build a list for a room like alamo...
You could pass it values 1 - 10 and designate that it needs to be preceded with the letter "A", then append that array to another one that should be preceded with a "B", etc, until you get the full list.
But I'm not sure of an easy way for apache, where you jump from 025 to 326.  That does complicate things.  Coming up with an algorithm that suits all of these rooms will be difficult without an external source, but hopefully the function above helps reduce some of the code bloat.  Good luck!
Gabriel Clifton

ASKER
I think you are right with the way rooms are numbered oddly at some campuses and some using names instead of numbers could really complicate things. I think I might just stick to the bloated code. Also, I noticed on your toggle that when you are selecting the computer number and you are using the arrow keys, every other number the button is greyed out.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
sirbounty

That's by design.  It doesn't become active until the last selection is made.
You could toggle it off again after the button is clicked to disable it, but you'd also want to reset all of the drop downs...
Gabriel Clifton

ASKER
Great!
I don't intend for you to write the whole thing, but there is so much that I cannot figure out. Here is where I am at: I am still expanding on the campus rooms, I need a text box that defaults current computer name but allows you to enter remote computer name, and rename computer button. I would like the generate name button to disappear and have that text box automatically update as selections are made so that there is only one button. Also, when user clicks on rename computer button it gives a popup are you sure you want to rename computer x to y.
I am posting what I have so far so you can see the progress and you have something fresh to look at.

<select id=sel_campus>
</select>
<select id=sel_room>
</select>
<select id=sel_computer>
</select>
<select id=sel_level>
</select>
<select id=sel_number>
</select>

<script language=vbscript>

option explicit

sub add_option (select_id, value, text)
dim opt : set opt = document.createelement("option")
opt.value = value
opt.text = text
select_id.add opt
set opt = nothing
end sub

sub load_combo (select_id, option_array)
dim i: for i = 0 to ubound(option_array)
add_option select_id, i, option_array(i)
next
end sub

sub clear_combo (select_id)
select_id.options.length = 0
end sub

'Campus Names
dim campus : campus = array ("Campus", "Alamo", "Apache", "Intermediate", "Middle School", "High School", "Butz", "Food Services", "Central Office", "Maintenance / Bus Barn", "Special Services", "Technology")
load_combo sel_campus, Campus

'Campus Room Numbers
dim alamo_rooms : alamo_rooms = split ("Room,A01,A02,A03,A04,A05,A06,A07,A08,A09,A10," _
& "B01,B02,B03,B04,B05,B06,B07,B08,B09," _
& "C01,C02,C03,C04,C05,C06,C07,C08,C09,C10,C11," _
& "D01,D02,D03,D04,D05,D06,D07,D08,D09,D10,D11,COU," _
& "FRD,NUR,PRI,SEC,TCL,Music,Library,Gym", ",")
dim apache_rooms : apache_rooms = split ("Room,001,002,003,004,005,006,007,008,009,010," _
& "011,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,326,327,328,329,330," _
& "331,332,333,334,335," _
& "COU,FRD,NUR,PRI,SEC,TCL,Music,Library,Gym",",")
dim intermediate_rooms : intermediate_rooms = split ("Room,001,002,003,004,005,006,007,008,009,010," _
& "010,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,026,027,028," _
& "COU,FRD,NUR,PRI,SEC,TCL,Music,Library,Gym",",")
dim ms_rooms : ms_rooms = split ("Room,101,102,103,104,105,106,107,108,109,110," _
& "111,112,113,114,115,116,117,118,119,120," _
& "121,122,123,124,125,126,127,128,129,130," _
& "131,132,133,134,135,136,137,138,139,140," _
& "141,142,143,144,145,146,147,148,149,150,151," _
& "COU,FRD,NUR,PRI,SEC,TCL,Music,Library,Gym",",")
dim hs_rooms : hs_rooms = split ("Room,001,002,003,004,005,006,007,008,009,010," _
& "010,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,026,027,028,029,030," _
& "031,31A,032,033,034,035,036,037,038,039,040," _
& "041,042,043,044,045,046,047,048,049,050,051,052," _
& "COU,FRD,NUR,PRI,SEC,TCL,Music,Library,Gym",",")

'User Type
Dim com_level : com_level = Split ("User Type,Teacher,Student",",")
'Computer Type
Dim com_type : com_type = Split ("Computer Type,Desktop,Laptop",",")

'Computer Numbers
dim com_num : com_num = split ("Computer Number,01,02,03,04,05,06,07,08,09,10," _
& "10,12,13,14,15,16,17,18,19,20," _
& "21,22,23,24,25,26,27,28,29,30," _
& "31,32,33,34,35,36,37,38,39,40," _
& "41,42,43,44,45,46,47,48,49,50,51,52",",")

'Selection for campus names
sub sel_campus_onchange
clear_combo sel_room
select case sel_campus.value
Case 0 'Campus
Case 1 'Alamo
load_combo sel_room, alamo_rooms
Case 2 'Apache
load_combo sel_room, apache_rooms
Case 3 'Intermediate
load_combo sel_room, intermediate_rooms
Case 4 'Middle School
load_combo sel_room, ms_rooms
Case 5 'High School
load_combo sel_room, hs_rooms
Case 6 'Butz
load_combo sel_room, alamo_rooms
Case 7 'Food Services
load_combo sel_room, alamo_rooms
Case 8 'Central Office
load_combo sel_room, alamo_rooms
Case 9 'Bus Barn
load_combo sel_room, alamo_rooms

End select
end Sub

'Selection for campus rooms
sub sel_room_onchange
  clear_combo sel_computer
  if sel_room.value = 0 Then exit sub
  load_combo sel_computer, com_type
end Sub

'Selection for computer type
sub sel_computer_onchange
clear_combo sel_level
select case sel_computer.value
Case 0 'Computer Type
case 01 'Desktop
load_combo sel_level, com_level
Case 02 'Laptop
load_combo sel_level, com_level
end select
end Sub

'Selection for computer number
sub sel_level_onchange
clear_combo sel_number
select case sel_level.value
Case 0 'Computer Number
case 1 'Computer 1
load_combo sel_number, com_num
Case 2 'Computer 2
load_combo sel_number, com_num
end select
end Sub

sub sel_number_onchange
  toggle
end sub

Sub RunScript
  Dim CampusName, RoomNumber, DeviceType, PersonType
  If sel_campus.value = 1 Then
  	CampusName = "AL"
  ElseIf sel_campus.value = 2 Then
  	CampusName = "AP"
  ElseIf sel_campus.value = 3 Then
  	CampusName = "IN"
  ElseIf sel_campus.value = 4 Then
  	CampusName = "MS"
  ElseIf sel_campus.value = 5 Then
  	CampusName = "HS"
  ElseIf sel_campus.value = 6 Then
  	CampusName = "BU"
  ElseIf sel_campus.value = 7 Then
  	CampusName = "IN"
  ElseIf sel_campus.value = 8 Then
  	CampusName = "CO"
  ElseIf sel_campus.value = 9 Then
  	CampusName = "BB"
  End If
  
  'Alamo Rooms
  If sel_campus.value = 1 And sel_room.value = 1 Then
  	RoomNumber = "A01"
  ElseIf sel_campus.value = 1 And sel_room.value = 2 Then
  	RoomNumber = "A02"
  ElseIf sel_campus.value = 1 And sel_room.value = 3 Then
  	RoomNumber = "A03"
  ElseIf sel_campus.value = 1 And sel_room.value = 4 Then
  	RoomNumber = "A04"
  ElseIf sel_campus.value = 1 And sel_room.value = 5 Then
  	RoomNumber = "A05"
  ElseIf sel_campus.value = 1 And sel_room.value = 6 Then
  	RoomNumber = "A06"
  ElseIf sel_campus.value = 1 And sel_room.value = 7 Then
  	RoomNumber = "A07"
  ElseIf sel_campus.value = 1 And sel_room.value = 8 Then
  	RoomNumber = "A08"
  ElseIf sel_campus.value = 1 And sel_room.value = 9 Then
  	RoomNumber = "A09"
  ElseIf sel_campus.value = 1 And sel_room.value = 10 Then
  	RoomNumber = "A10"
  ElseIf sel_campus.value = 1 And sel_room.value = 11 Then
  	RoomNumber = "B01"
  ElseIf sel_campus.value = 1 And sel_room.value = 12 Then
  	RoomNumber = "B02"
  ElseIf sel_campus.value = 1 And sel_room.value = 13 Then
  	RoomNumber = "B03"
  ElseIf sel_campus.value = 1 And sel_room.value = 14 Then
  	RoomNumber = "B04"
  ElseIf sel_campus.value = 1 And sel_room.value = 15 Then
  	RoomNumber = "B05"
  ElseIf sel_campus.value = 1 And sel_room.value = 16 Then
  	RoomNumber = "B06"
  ElseIf sel_campus.value = 1 And sel_room.value = 17 Then
  	RoomNumber = "B07"
  ElseIf sel_campus.value = 1 And sel_room.value = 18 Then
  	RoomNumber = "B08"
  ElseIf sel_campus.value = 1 And sel_room.value = 19 Then
  	RoomNumber = "B09"
  ElseIf sel_campus.value = 1 And sel_room.value = 20 Then
  	RoomNumber = "C01"
  ElseIf sel_campus.value = 1 And sel_room.value = 21 Then
  	RoomNumber = "C02"
  ElseIf sel_campus.value = 1 And sel_room.value = 22 Then
  	RoomNumber = "C03"
  ElseIf sel_campus.value = 1 And sel_room.value = 23 Then
  	RoomNumber = "C04"
  ElseIf sel_campus.value = 1 And sel_room.value = 24 Then
  	RoomNumber = "C05"
  ElseIf sel_campus.value = 1 And sel_room.value = 25 Then
  	RoomNumber = "C06"
  ElseIf sel_campus.value = 1 And sel_room.value = 26 Then
  	RoomNumber = "C07"
  ElseIf sel_campus.value = 1 And sel_room.value = 27 Then
  	RoomNumber = "C08"
  ElseIf sel_campus.value = 1 And sel_room.value = 28 Then
  	RoomNumber = "C09"
  ElseIf sel_campus.value = 1 And sel_room.value = 29 Then
  	RoomNumber = "C10"
  ElseIf sel_campus.value = 1 And sel_room.value = 30 Then
  	RoomNumber = "C11"
  ElseIf sel_campus.value = 1 And sel_room.value = 31 Then
  	RoomNumber = "D01"
  ElseIf sel_campus.value = 1 And sel_room.value = 32 Then
  	RoomNumber = "D02"
  ElseIf sel_campus.value = 1 And sel_room.value = 33 Then
  	RoomNumber = "D03"
  ElseIf sel_campus.value = 1 And sel_room.value = 34 Then
  	RoomNumber = "D04"
  ElseIf sel_campus.value = 1 And sel_room.value = 35 Then
  	RoomNumber = "D05"
  ElseIf sel_campus.value = 1 And sel_room.value = 36 Then
  	RoomNumber = "D06"
  ElseIf sel_campus.value = 1 And sel_room.value = 37 Then
  	RoomNumber = "D07"
  ElseIf sel_campus.value = 1 And sel_room.value = 38 Then
  	RoomNumber = "D08"
  ElseIf sel_campus.value = 1 And sel_room.value = 39 Then
  	RoomNumber = "D09"
  ElseIf sel_campus.value = 1 And sel_room.value = 40 Then
  	RoomNumber = "D10"
  ElseIf sel_campus.value = 1 And sel_room.value = 41 Then
  	RoomNumber = "D11"
  ElseIf sel_campus.value = 1 And sel_room.value = 42 Then
  	RoomNumber = "COU"
  ElseIf sel_campus.value = 1 And sel_room.value = 43 Then
  	RoomNumber = "FRD"
  ElseIf sel_campus.value = 1 And sel_room.value = 44 Then
  	RoomNumber = "NUR"
  ElseIf sel_campus.value = 1 And sel_room.value = 45 Then
  	RoomNumber = "PRI"
  ElseIf sel_campus.value = 1 And sel_room.value = 46 Then
  	RoomNumber = "SEC"
  ElseIf sel_campus.value = 1 And sel_room.value = 47 Then
  	RoomNumber = "TCL"
  ElseIf sel_campus.value = 1 And sel_room.value = 48 Then
  	RoomNumber = "MSC"
  ElseIf sel_campus.value = 1 And sel_room.value = 49 Then
  	RoomNumber = "LIB"
  ElseIf sel_campus.value = 1 And sel_room.value = 50 Then
  	RoomNumber = "GYM"

	'Apache Rooms
  ElseIf sel_campus.value = 2 And sel_room.value = 1 Then
  	RoomNumber = "001"
  ElseIf sel_campus.value = 2 And sel_room.value = 2 Then
  	RoomNumber = "002"
  ElseIf sel_campus.value = 2 And sel_room.value = 3 Then
  	RoomNumber = "003"
  ElseIf sel_campus.value = 2 And sel_room.value = 4 Then
  	RoomNumber = "004"
  ElseIf sel_campus.value = 2 And sel_room.value = 5 Then
  	RoomNumber = "005"
  ElseIf sel_campus.value = 2 And sel_room.value = 6 Then
  	RoomNumber = "006"
  ElseIf sel_campus.value = 2 And sel_room.value = 7 Then
  	RoomNumber = "007"
  ElseIf sel_campus.value = 2 And sel_room.value = 8 Then
  	RoomNumber = "008"
  ElseIf sel_campus.value = 2 And sel_room.value = 9 Then
  	RoomNumber = "009"
  ElseIf sel_campus.value = 2 And sel_room.value = 10 Then
  	RoomNumber = "010"
  ElseIf sel_campus.value = 2 And sel_room.value = 11 Then
  	RoomNumber = "011"
  ElseIf sel_campus.value = 2 And sel_room.value = 12 Then
  	RoomNumber = "012"
  ElseIf sel_campus.value = 2 And sel_room.value = 13 Then
  	RoomNumber = "013"
  ElseIf sel_campus.value = 2 And sel_room.value = 14 Then
  	RoomNumber = "014"
  ElseIf sel_campus.value = 2 And sel_room.value = 15 Then
  	RoomNumber = "015"
  ElseIf sel_campus.value = 2 And sel_room.value = 16 Then
  	RoomNumber = "015"
  ElseIf sel_campus.value = 2 And sel_room.value = 17 Then
  	RoomNumber = "017"
  ElseIf sel_campus.value = 2 And sel_room.value = 18 Then
  	RoomNumber = "018"
  ElseIf sel_campus.value = 2 And sel_room.value = 19 Then
  	RoomNumber = "019"
  ElseIf sel_campus.value = 2 And sel_room.value = 20 Then
  	RoomNumber = "020"
  ElseIf sel_campus.value = 2 And sel_room.value = 21 Then
  	RoomNumber = "021"
  ElseIf sel_campus.value = 2 And sel_room.value = 22 Then
  	RoomNumber = "022"
  ElseIf sel_campus.value = 2 And sel_room.value = 23 Then
  	RoomNumber = "023"
  ElseIf sel_campus.value = 2 And sel_room.value = 24 Then
  	RoomNumber = "024"
  ElseIf sel_campus.value = 2 And sel_room.value = 25 Then
  	RoomNumber = "025"
  ElseIf sel_campus.value = 2 And sel_room.value = 26 Then
  	RoomNumber = "326"
  ElseIf sel_campus.value = 2 And sel_room.value = 27 Then
  	RoomNumber = "327"
  ElseIf sel_campus.value = 2 And sel_room.value = 28 Then
  	RoomNumber = "328"
  ElseIf sel_campus.value = 2 And sel_room.value = 29 Then
  	RoomNumber = "329"
  ElseIf sel_campus.value = 2 And sel_room.value = 30 Then
  	RoomNumber = "330"
  ElseIf sel_campus.value = 2 And sel_room.value = 31 Then
  	RoomNumber = "331"
  ElseIf sel_campus.value = 2 And sel_room.value = 32 Then
  	RoomNumber = "332"
  ElseIf sel_campus.value = 2 And sel_room.value = 33 Then
  	RoomNumber = "333"
  ElseIf sel_campus.value = 2 And sel_room.value = 34 Then
  	RoomNumber = "334"
  ElseIf sel_campus.value = 2 And sel_room.value = 35 Then
  	RoomNumber = "335"
  ElseIf sel_campus.value = 2 And sel_room.value = 36 Then
  	RoomNumber = "COU"
  ElseIf sel_campus.value = 2 And sel_room.value = 37 Then
  	RoomNumber = "FRD"
  ElseIf sel_campus.value = 2 And sel_room.value = 38 Then
  	RoomNumber = "NUR"
  ElseIf sel_campus.value = 2 And sel_room.value = 39 Then
  	RoomNumber = "PRI"
  ElseIf sel_campus.value = 2 And sel_room.value = 40 Then
  	RoomNumber = "SEC"
  ElseIf sel_campus.value = 2 And sel_room.value = 41 Then
  	RoomNumber = "TCL"
  ElseIf sel_campus.value = 2 And sel_room.value = 42 Then
  	RoomNumber = "MSC"
  ElseIf sel_campus.value = 2 And sel_room.value = 43 Then
  	RoomNumber = "LIB"
  ElseIf sel_campus.value = 2 And sel_room.value = 44 Then
  	RoomNumber = "GYM"

	'Intermediate Rooms
  ElseIf sel_campus.value = 3 And sel_room.value = 1 Then
  	RoomNumber = "001"

  'Middle School Rooms
  ElseIf sel_campus.value = 4 And sel_room.value = 1 Then
  	RoomNumber = "101"

  'High School Rooms
  ElseIf sel_campus.value = 5 And sel_room.value = 1 Then
  	RoomNumber = "001"

  'Butz Rooms
  ElseIf sel_campus.value = 6 And sel_room.value = 1 Then
  	RoomNumber = "DAEP"

  'Food Services Rooms
  ElseIf sel_campus.value = 7 And sel_room.value = 1 Then
  	RoomNumber = "FDSRV"

  'Central Office Rooms
  ElseIf sel_campus.value = 8 And sel_room.value = 1 Then
  	RoomNumber = "ACP"

  'Bus Barn Rooms
  ElseIf sel_campus.value = 9 And sel_room.value = 1 Then
  	RoomNumber = "OFC"
  End If

  If sel_computer.value = 1 then 
    DeviceType = "D"
  Else 
    DeviceType = "L"
  End If
  If sel_level.value = 1 Then
    PersonType = "T"
  Else
    PersonType = "S"
  End If
  ComputerName.value = CampusName & "RM" & RoomNumber & DeviceType & PersonType & Right("0" & sel_number.value, 2)
End Sub

function toggle()
    if document.GetElementByID("GenName").disabled = false then
        document.GetElementByID("GenName").disabled = true
    else
	document.GetElementByID("GenName").disabled = false
    end if
end Function
</script>

<body bgcolor="white" onload="toggle()">
<p>
    <button onclick="RunScript" id="GenName">Generate Name</button> <br>
<p>Computer Name<BR>
<input type=text id="ComputerName" name=ComputerName size=45></p>

</body>
</html>

Open in new window

SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Gabriel Clifton

ASKER
Ok, let me see if I can explain it this way:

[Textbox] with old computer name allowing for remote computer rename.

Dropdowns [campus] [Room] [Computer Type] [User Type] [Computer Number]

[Textbox] with new computer name automatically generated for a one button form. Using a textbox will allow the techs to input a computer name scheme that I have missed. Will eventually be changed to the spanid as I get this fine tuned.

[Rename Computer Button] with popup when pressed "Are you sure you want to rename "oldcomputername" to "newcomputername""

After confirmation, the computer reboots and is renamed on computer and AD. The computer is already joined to domain during imaging. This is primarily for renaming after imaging or if the computer is moved so that the techs are "forced" to rename the computer to our naming scheme. It has been irritating me (and I am sure others in the world) for years that techs will rename a computer to whatever they feel like at the moment and everything that I have put in place to make their life irritating if they don't rename properly is not working as much as I want.

(rant done)
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Gabriel Clifton

ASKER
I here is what I have so far. The last code you sent me, I could never get to work. Now I am working on getting the computer name generator to populate the textbox automatically then the rename. I know netdom would work, but this should be ran on any system and not have to worry about any additional files. I know objComputer.rename would work without any additional files, but can only be ran on current system and not remotely if needed. What are your thoughts.

<select id=sel_campus>
</select>
<select id=sel_room>
</select>
<select id=sel_computer>
</select>
<select id=sel_level>
</select>
<select id=sel_number>
</select>

<script language=vbscript>

option explicit

Sub Window_OnLoad
 Dim objNetwork
 Set objNetwork = CreateObject("wscript.network")
 oldComputerName.value = objNetwork.ComputerName
End Sub

sub add_option (select_id, value, text)
  dim opt : set opt = document.createelement("option")
  opt.value = value
  opt.text = text
  select_id.add opt
  set opt = nothing
end sub

sub load_combo (select_id, option_array)
  dim i: for i = 0 to ubound(option_array)
    add_option select_id, i, option_array(i)
  next
end sub

sub clear_combo (select_id)
  select_id.options.length = 0
end sub

'Campus Names
dim campus : campus = array ("Campus", "Alamo", "Apache", "Intermediate", "Middle School", "High School", "Butz", "Food Services", "Central Office", "Maintenance / Bus Barn", "Special Services", "Technology")
load_combo sel_campus, Campus

'Campus Room Numbers
dim alamo_rooms : alamo_rooms = split ("Room,A01,A02,A03,A04,A05,A06,A07,A08,A09,A10," _
& "B01,B02,B03,B04,B05,B06,B07,B08,B09," _
& "C01,C02,C03,C04,C05,C06,C07,C08,C09,C10,C11," _
& "D01,D02,D03,D04,D05,D06,D07,D08,D09,D10,D11," _
& "COUNSELOR,FRONT DESK,NURSE,PRINCIPAL,SECRETARY,TIME CLOCK,MUSIC,LIBRARY,GYM", ",")
dim apache_rooms : apache_rooms = split ("Room,001,002,003,004,005,006,007,008,009,010," _
& "011,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,326,327,328,329,330," _
& "331,332,333,334,335," _
& "COUNSELOR,FRONT DESK,NURSE,PRINCIPAL,SECRETARY,TIME CLOCK,MUSIC,LIBRARY,GYM",",")
dim intermediate_rooms : intermediate_rooms = split ("Room,001,002,003,004,005,006,007,008,009,010," _
& "010,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,026,027,028," _
& "COUNSELOR,FRONT DESK,NURSE,PRINCIPAL,SECRETARY,TIME CLOCK,MUSIC,LIBRARY,GYM,ISS",",")
dim ms_rooms : ms_rooms = split ("Room,101,102,103,104,105,106,107,108,109,110," _
& "111,112,113,114,115,116,117,118,119,120," _
& "121,122,123,124,125,126,127,128,129,130," _
& "131,132,133,134,135,136,137,138,139,140," _
& "141,142,143,144,145,146,147,148,149,150,151," _
& "COUNSELOR,FRONT DESK,NURSE,PRINCIPAL,ASSISTANT PRINCIPAL,SECRETARY,TIME CLOCK,MUSIC,LIBRARY,GYM,ISS",",")
dim hs_rooms : hs_rooms = split ("Room,001,002,003,004,005,006,007,008,009,010," _
& "010,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,026,027,028,029,030," _
& "031,31A,032,033,034,035,036,037,038,039,040," _
& "041,042,043,044,045,046,047,048,049,050,051,052," _
& "COU,FRD,NUR,PRI,SEC,TCL,Music,Library,Gym,ISS",",")

'User Type
Dim com_level : com_level = Split ("User Type,Teacher,Student",",")
'Computer Type
Dim com_type : com_type = Split ("Computer Type,Desktop,Laptop",",")

'Computer Numbers
dim com_num : com_num = split ("Computer Number,01,02,03,04,05,06,07,08,09,10," _
& "10,12,13,14,15,16,17,18,19,20," _
& "21,22,23,24,25,26,27,28,29,30," _
& "31,32,33,34,35,36,37,38,39,40," _
& "41,42,43,44,45,46,47,48,49,50,51,52",",")

'Selection for campus names
sub sel_campus_onchange
clear_combo sel_room
select case sel_campus.value
Case 0 'Campus
Case 1 'Alamo
load_combo sel_room, alamo_rooms
Case 2 'Apache
load_combo sel_room, apache_rooms
Case 3 'Intermediate
load_combo sel_room, intermediate_rooms
Case 4 'Middle School
load_combo sel_room, ms_rooms
Case 5 'High School
load_combo sel_room, hs_rooms
Case 6 'Butz
load_combo sel_room, alamo_rooms
Case 7 'Food Services
load_combo sel_room, alamo_rooms
Case 8 'Central Office
load_combo sel_room, alamo_rooms
Case 9 'Bus Barn
load_combo sel_room, alamo_rooms

End select
end Sub

'Selection for campus rooms
sub sel_room_onchange
  clear_combo sel_computer
  if sel_room.value = 0 Then exit sub
  load_combo sel_computer, com_type
end Sub

'Selection for computer type
sub sel_computer_onchange
clear_combo sel_level
select case sel_computer.value
Case 0 'Computer Type
case 01 'Desktop
load_combo sel_level, com_level
Case 02 'Laptop
load_combo sel_level, com_level
end select
end Sub

'Selection for computer number
sub sel_level_onchange
clear_combo sel_number
select case sel_level.value
Case 0 'Computer Number
case 1 'Computer 1
load_combo sel_number, com_num
Case 2 'Computer 2
load_combo sel_number, com_num
end select
end Sub

'sub sel_number_onchange
'  toggle
'end sub

Sub RunScript
  Dim CampusName, RoomNumber, DeviceType, PersonType
  If sel_campus.value = 1 Then
  	CampusName = "AL"
  ElseIf sel_campus.value = 2 Then
  	CampusName = "AP"
  ElseIf sel_campus.value = 3 Then
  	CampusName = "IN"
  ElseIf sel_campus.value = 4 Then
  	CampusName = "MS"
  ElseIf sel_campus.value = 5 Then
  	CampusName = "HS"
  ElseIf sel_campus.value = 6 Then
  	CampusName = "BU"
  ElseIf sel_campus.value = 7 Then
  	CampusName = "IN"
  ElseIf sel_campus.value = 8 Then
  	CampusName = "CO"
  ElseIf sel_campus.value = 9 Then
  	CampusName = "BB"
  End If
  
  'Alamo Rooms
  If sel_campus.value = 1 And sel_room.value = 1 Then
  	RoomNumber = "A01"

	'Apache Rooms
  ElseIf sel_campus.value = 2 And sel_room.value = 1 Then
  	RoomNumber = "001"

	'Intermediate Rooms
  ElseIf sel_campus.value = 3 And sel_room.value = 1 Then
  	RoomNumber = "001"

  'Middle School Rooms
  ElseIf sel_campus.value = 4 And sel_room.value = 1 Then
  	RoomNumber = "101"

  'High School Rooms
  ElseIf sel_campus.value = 5 And sel_room.value = 1 Then
  	RoomNumber = "001"

  'Butz Rooms
  ElseIf sel_campus.value = 6 And sel_room.value = 1 Then
  	RoomNumber = "DAEP"

  'Food Services Rooms
  ElseIf sel_campus.value = 7 And sel_room.value = 1 Then
  	RoomNumber = "FDSRV"

  'Central Office Rooms
  ElseIf sel_campus.value = 8 And sel_room.value = 1 Then
  	RoomNumber = "ACP"

  'Bus Barn Rooms
  ElseIf sel_campus.value = 9 And sel_room.value = 1 Then
  	RoomNumber = "OFC"
  End If

  If sel_computer.value = 1 then 
    DeviceType = "D"
  Else 
    DeviceType = "L"
  End If
  If sel_level.value = 1 Then
    PersonType = "T"
  Else
    PersonType = "S"
  End If
  ComputerName.value = CampusName & "RM" & RoomNumber & DeviceType & PersonType & Right("0" & sel_number.value, 2)
End Sub

'function toggle()
'    if document.GetElementByID("GenName").disabled = false then
'        document.GetElementByID("GenName").disabled = true
'    else
'	document.GetElementByID("GenName").disabled = false
'    end if
'end Function
</script>

<body bgcolor="white">
<!-- <body bgcolor="white" onload="toggle()"> -->
<p>
    <button onclick="RunScript" id="GenName">Generate Name</button> <br>
<p>New Computer Name<BR>
<input type=text id="ComputerName" name=ComputerName size=45></p>
<p>Current Computer Name<br />
<input type=text id="OldComputerName" name=OldComputerName size=45></p>
</body>
</html>

Open in new window

SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Gabriel Clifton

ASKER
OK, here is what I am getting right now. the room number is only a 0 when I go from room number to computer type and I get line 176 column 16 the remote server machine does not exist or is unavailable: getObject. Tried it on a local computer and get the same results.
sirbounty

I don't see that.
I get APRM008 when I select the room number.
As for the error - could be anything.  Like I said there's loads you'll need to account for to make this bullet proof.  
At first glance, I'd suspect uac is the culprit...running the tool as an admin?  If uac is enabled, which it should be, then the only way to launch the tool from an elevated/admin environment is to run mshta.exe, or to launch it from an elevated cmd prompt.  You won't have that option for just the hta file...
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Gabriel Clifton

ASKER
We do not have UAC enabled in out test network. We have part of it in our main network, did a run as admin command prompt and still says computer does not exist. When I choose room number, it does show correctly for Apache, APRM001, but as soon as I select computer type it jumps to APRM0D. Also when I do any other campus like Alamo I get ALRM001 when it should be ALRMA01 so it is getting the sel_room but not the alamo_rooms combo. Ok, just figured out why the numbers were getting cut short but not the rest.
Gabriel Clifton

ASKER
I have found and tested a VBScript that works on local as well as remote, but I cannot figure out how to tie it in to the HTA.

strComputer = "OLDCOMPUTER" ' e.g. joe-xp 
strNewComputer = "NEWCOMPUTER" ' e.g. joe-pc 
strDomainUser = "administrator@company.com" ' e.g. administrator@company.com 
strDomainPasswd = "XXXXXXXXXX" 
strLocalUser = strComputer & "\administrator" ' e.g. joe-xp\administrator 
strLocalPasswd = "xxxxxxx" 
' ------ END CONFIGURATION --------- 

'########################### 
' Connect to Computer 
'########################### 
set objWMILocator = CreateObject("WbemScripting.SWbemLocator") 
objWMILocator.Security_.AuthenticationLevel = 6 
set objWMIComputer = objWMILocator.ConnectServer(strComputer, "root\cimv2", strLocalUser, strLocalPasswd) 
set objWMIComputerSystem = objWMIComputer.Get( "Win32_ComputerSystem.Name='" & strComputer & "'") 
'########################### 
' Rename Computer 
'########################### 
rc = objWMIComputerSystem.Rename(strNewComputer, strDomainPasswd, strDomainUser) 
if rc <> 0 then 
WScript.Echo "Rename failed with error: " & rc 
else 
WScript.Echo "Successfully renamed " & strComputer & " to " & strNewComputer 
end if 

WScript.Echo "Rebooting..." 
set objWSHShell = WScript.CreateObject("WScript.Shell") 

objWSHShell.Run "shutdown.exe /m \\" & strComputer & " /r" 

Open in new window

SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Gabriel Clifton

ASKER
ARRRRRGH, so close, yet so far away. Right now I have error uName required.

Sub RenamePC
  Dim strComputer, strNewComputer, strDomainUser, strDomainPasswd, strLocalUser, strLocalPasswd, NewComputerName, uName, uPassword
  Dim iResponse : iResponse = Msgbox("Rename " & oldComputerName.value & " to " & Computername.value & "?", _
        vbYesNo, "Proceed with rename?")
  If iResponse = vbNo Then
    Msgbox "No changes will be made."
    exit sub
  End If
strComputer=OldComputerName.value
strNewComputer = ComputerName.value
strDomainUser = uName.value
strDomainPasswd = uPassword.value 
strLocalUser = strComputer & "\administrator"
strLocalPasswd = "pwd"
' ------ END CONFIGURATION --------- 

'########################### 
' Connect to Computer 
'########################### 
Set objWMILocator = CreateObject("WbemScripting.SWbemLocator") 
objWMILocator.Security_.AuthenticationLevel = 6 
Set objWMIComputer = objWMILocator.ConnectServer(strComputer, "root\cimv2", strLocalUser, strLocalPasswd) 
Set objWMIComputerSystem = objWMIComputer.Get( "Win32_ComputerSystem.Name='" & strComputer & "'") 
'########################### 
' Rename Computer 
'########################### 
rc = objWMIComputerSystem.Rename(strNewComputer, strDomainPasswd, strDomainUser) 
if rc <> 0 then 
WScript.Echo "Rename failed with error: " & rc 
else 
WScript.Echo "Successfully renamed " & strComputer & " to " & strNewComputer 
end if 

WScript.Echo "Rebooting..." 
set objWSHShell = WScript.CreateObject("WScript.Shell") 

objWSHShell.Run "shutdown.exe /m \\" & strComputer & "/r" 
'  Next
end sub

sub disableButton()
  document.GetElementByID("Rename").disabled = true
end sub
</script>

<body bgcolor="white" onload="disableButton()">
<p>
<p>Current Computer Name:&nbsp;&nbsp;<input type=text id="OldComputerName" name=OldComputerName size=45></p>
<p>New Computer Name:&nbsp;&nbsp;<input type=text id="ComputerName" name=ComputerName size=45></p>
<p>User Name:&nbsp;&nbsp;<input type=text id="uName" name=uName size=45><br>
User Password:&nbsp;&nbsp;<input type=password id="uPassword" name=uPassword size=45></p>
<button onclick="RenamePC" id="Rename">Rename Computer</button> <br>
</body>
</html>

Open in new window

Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Gabriel Clifton

ASKER
I have the text boxes below the computer name boxes.
Gabriel Clifton

ASKER
Here it is with the textboxes in a table.

Sub RenamePC
  Dim strComputer, strNewComputer, strDomainUser, strDomainPasswd, strLocalUser, strLocalPasswd, NewComputerName, uName, uPassword
  Dim iResponse : iResponse = Msgbox("Rename " & oldComputerName.value & " to " & Computername.value & "?", _
        vbYesNo, "Proceed with rename?")
  If iResponse = vbNo Then
    Msgbox "No changes will be made."
    exit sub
  End If
strComputer=OldComputerName.value
strNewComputer = ComputerName.value
strDomainUser = uName.value & "@fsisd.local"
strDomainPasswd = uPassword.value 
strLocalUser = strComputer & "\administrator"
strLocalPasswd = "pwd"
' ------ END CONFIGURATION --------- 

'########################### 
' Connect to Computer 
'###########################
Dim objWMILocator, objWMIComputer, objWMIComputerSystem, rc
Set objWMILocator = CreateObject("WbemScripting.SWbemLocator") 
objWMILocator.Security_.AuthenticationLevel = 6 
Set objWMIComputer = objWMILocator.ConnectServer(strComputer, "root\cimv2", strLocalUser, strLocalPasswd) 
Set objWMIComputerSystem = objWMIComputer.Get( "Win32_ComputerSystem.Name='" & strComputer & "'") 
'########################### 
' Rename Computer 
'########################### 
rc = objWMIComputerSystem.Rename(strNewComputer, strDomainPasswd, strDomainUser) 
if rc <> 0 then 
Msgbox "Rename failed with error: " & rc 
else 
Msgbox "Successfully renamed " & strComputer & " to " & strNewComputer 
Msgbox "Rebooting..." 
set objWSHShell = WScript.CreateObject("WScript.Shell") 
objWSHShell.Run "shutdown.exe /m \\" & strComputer & " /r" 

End if 

'  Next
end sub

sub disableButton()
  document.GetElementByID("Rename").disabled = true
end sub
</script>

<body bgcolor="white" onload="disableButton()">
<p>
<table>
&#9;<tr>
&#9;&#9;<td>
&#9;&#9;&#9;Current Computer Name:
&#9;&#9;</td>
&#9;&#9;<td>
&#9;&#9;&#9;<input type=text id="OldComputerName" name=OldComputerName size=45>
&#9;&#9;</td>
&#9;</tr>
&#9;<tr>
&#9;&#9;<td>
&#9;&#9;&#9;New Computer Name:
&#9;&#9;</td>
&#9;&#9;<td>
&#9;&#9;&#9;<input type=text id="ComputerName" name=ComputerName size=45>
&#9;&#9;<td>
&#9;</tr>
&#9;<tr>
&#9;&#9;<td>
&#9;&#9;&#9;User Name:
&#9;&#9;</td>
&#9;&#9;<td>
&#9;&#9;&#9;<input type=text name=uName size=45>
&#9;&#9;</td>
&#9;</tr>
&#9;<tr>
&#9;&#9;<td>
&#9;&#9;&#9;User Password:
&#9;&#9;</td>
&#9;&#9;<td>
&#9;&#9;&#9;<input type=password name=uPassword size=45>
&#9;&#9;</td>
&#9;</tr>
</table>
 <br>
<button onclick="RenamePC" id="Rename">Rename Computer</button>
</body>
</html>

Open in new window

SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Gabriel Clifton

ASKER
WOW, that was strange, and it worked! The only thing not working now is the reboot.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Gabriel Clifton

ASKER
Took care of the reboot problem.

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Shutdown)}!\\" & _
        strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    objOperatingSystem.Reboot()
Next

Open in new window

sirbounty

More than one way to pull that off too...try a wmi reboot method - you should be able to use the same credentials.
sirbounty

Well, there ya go - great minds think alike. ;^)
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Gabriel Clifton

ASKER
Working on finishing up and dressing up. Adding all rooms and campuses that were missing while testing. Check line five.

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="description" content="Created by Gabriel Clifton and sirbounty">
<meta name="description" content="Last Update: 05/09/2014">

<title>Computer Rename Application</title>
<style>
.divbody{
padding:0px 15px 0px 15px;
}

body
{
font-family: calibri, verdana, arial;
	color: 000000;
	background-color: #53769E;
	text-align: left;
}
.pretty-table
{
  padding: 0;
  margin: 0;
  border-collapse: collapse;
  border: 1px solid #333;
  font-size: 0.9em;
  color: #000;
  background: black;
}

.pretty-table caption
{
  caption-side: bottom;
  font-size: 0.9em;
  font-style: italic;
  text-align: right;
  padding: 0.5em 0;
}
.pretty-table td
{
  background-color:white;
  padding: 0.5em;
}
.pretty-table th, 
{
  padding: 0.5em;
  text-align: left;
  color: white;

}
.pretty-table th[scope=col]
{
  color: #000;
  background-color: #8fadcc;
  text-transform: uppercase;
  font-size: 0.9em;
  border-bottom: 2px solid #333;
  border-right: 2px solid #333;
}
.pretty-table th+th[scope=col]
{
  color: #fff;
  background-color: #7d98b3;
  border-right: 1px dotted #666;
}
.pretty-table th[scope=row]
{
  background-color: #b8cfe5;
  border-right: 2px solid #333;
}
.pretty-table tr.alt th, .pretty-table tr.alt td
{
  color: #2a4763;
}
.pretty-table tr:hover th[scope=row], .pretty-table tr:hover td
{
  background-color: #632a2a;
  color: #fff;
}
#status_bar {
  box-shadow:rgb(136, 136, 136) 0px 5px 5px;
  background-color:#F7F7F7;
  border:1px solid #A5A5A5;
  font-color: #A5A5A5;
  font-size: 70%;
  border-bottom:0px;
  bottom:0px;
  height:25px;
  margin:auto;
  padding:5px 5px 5px 5px;
  position:absolute;
  width:100%;
  z-index:500;
}

..tabs {
border-collapse: collapse;
color: black;
cursor: pointer;
cursor: hand;
font-family: arial;
font-size: 9pt;
font-weight: bold;
margin-top: 4px;
padding: 2px 4px 0px 4px;
position: relative;
text-align: center;
text-decoration: none;
z-index: 1;
}
..tabs0 {
background-color: LightGrey;
border: solid 1px black;
}
..tabs1 {
background-color: Gainsboro;
border-color: black;
border-style: solid solid hidden solid;
border-width: 1px; }
..nav {
border-collapse: collapse;
align: center;
padding: 0;
spacing: 0;
width: 100%; }

</style>
<HTA:APPLICATION
	ICON="\\server\share\panther.ICO"
	APPLICATIONNAME="ComputerRename"
	BORDER="dialog"
	SCROLL="no" 
	MAXIMIZEBUTTON="no"
	SINGLEINSTANCE="no"
	CONTEXTMENU="no"
	WINDOWSTATE="normal"/> 	

</head>
<table border="0" width="100%"  cellspacing="0" cellpadding="0">
    <tr>
        <td width="33%" valign="top"><img src="\\server\share\logo.png" alt="logo" width="110" height="110"></td>
        <td width="34%" valign="top">
        <font size="8" color="white"><b><center>Fort Stockton<br>
            Independent School District</b></center></font>
        </td>
        <td width="33%" align="right" valign="top"><img src="\\server\share\logo.png" alt="logo" width="110" height="110"></td>
  </tr>
  <tr>
  <td></td>
  <td></td>
  			<td style="text-align:right;font-size:0.9em;font-weight:bold;font-style:oblique;color:#888888;">
				Created by Gabriel Clifton
			</td>
</tr>
</table>

<select id=sel_campus>
</select>
<select id=sel_room>
</select>
<select id=sel_computer>
</select>
<select id=sel_level>
</select>
<select id=sel_number>
</select>

<script language=vbscript>

'option explicit

Sub Window_onLoad
	width = "950"
	height = "720"
	' This moves the window to the middle of the screen
	Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") 
	Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor WHERE DeviceID='DesktopMonitor1'") 
	For Each objItem in ColItems 
	intHorizontal = objItem.ScreenWidth 
	intVertical = objItem.ScreenHeight 
	Next 
	intLeft = (intHorizontal - width)/2 
	intTop = (intVertical - height)/2 
	window.resizeTo width,height 
	
 Dim objNetwork : Set objNetwork = CreateObject("wscript.network")
 oldComputerName.value = objNetwork.ComputerName
End Sub

sub add_option (select_id, value, text)
  dim opt : set opt = document.createelement("option")
  opt.value = value
  opt.text = text
  select_id.add opt
  set opt = nothing
end sub

sub load_combo (select_id, option_array)
  dim i: for i = 0 to ubound(option_array)
    add_option select_id, i, option_array(i)
  next
end sub

sub clear_combo (select_id)
  select_id.options.length = 0
end sub

'Campus Names
load_combo sel_campus, array ("CAMPUS","ALAMO","APACHE","INTERMEDIATE","MIDDLE SCHOOL","HIGH SCHOOL","BUTZ","FOOD SERVICES","CENTRAL OFFICE","BUS BARN","SPECIAL SERVICES","TECHNOLOGY,MAINTENANCE")

'Campus Room Numbers
dim alamo_rooms : alamo_rooms = split ("ROOM,A01,A02,A03,A04,A05,A06,A07,A08,A09,A10," _
& "B01,B02,B03,B04,B05,B06,B07,B08,B09," _
& "C01,C02,C03,C04,C05,C06,C07,C08,C09,C10,C11," _
& "D01,D02,D03,D04,D05,D06,D07,D08,D09,D10,D11," _
& "COUNSELOR,FRONT DESK,NURSE,PRINCIPAL,SECRETARY,TIME CLOCK,MUSIC,LIBRARY,GYM,CAFETERIA", ",")

dim apache_rooms : apache_rooms = split ("ROOM,001,002,003,004,005,006,007,008,009,010," _
& "011,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,326,327,328,329,330," _
& "331,332,333,334,335," _
& "COUNSELOR,FRONT DESK,NURSE,PRINCIPAL,SECRETARY,TIME CLOCK,MUSIC,LIBRARY,GYM,CAFETERIA",",")

dim intermediate_rooms : intermediate_rooms = split ("ROOM,001,002,003,004,005,006,007,008,009,010," _
& "010,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,026,027,028," _
& "COUNSELOR,FRONT DESK,NURSE,PRINCIPAL,SECRETARY,TIME CLOCK,MUSIC,LIBRARY,GYM,ISS,CAFETERIA",",")

dim ms_rooms : ms_rooms = split ("ROOM,101,102,103,104,105,106,107,108,109,110," _
& "111,112,113,114,115,116,117,118,119,120," _
& "121,122,123,124,125,126,127,128,129,130," _
& "131,132,133,134,135,136,137,138,139,140," _
& "141,142,143,144,145,146,147,148,149,150,151," _
& "COUNSELOR,FRONT DESK,NURSE,PRINCIPAL,ASSISTANT PRINCIPAL,SECRETARY,TIME CLOCK,MUSIC,LIBRARY,GYM,ISS,CAFETERIA",",")

dim hs_rooms : hs_rooms = split ("ROOM,001,002,003,004,005,006,007,008,009,010," _
& "010,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,026,027,028,029,030," _
& "031,31A,032,033,034,035,036,037,038,039,040," _
& "041,042,043,044,045,046,047,048,049,050,051,052," _
& "COUNSELOR,FRONT DESK,NURSE,PRINCIPAL,ASSISTANT PRINCIPAL,SECRETARY,TIME CLOCK,BAND,CHOIR,LIBRARY,GYM,ISS,GCS,CAFETERIA",",")

Dim butz_rooms : butz_rooms = Split ("ROOM,BILINGUAL DIRECTOR,BILINGUAL SECRETARY,PRINCIPAL,TIME CLOCK," _
& "CURRICULUM,DAEP,DAYCARE DIRECTOR,TEACHSCAPE,DAYCARE TEACHER,DISTRICT PEIMS COORDINATOR,MIGRANT RECRUITER" _
& ",MIGRANT RECRUITER AIDE,NURSE DIRECTOR,CAFETERIA",",")

Dim fs_rooms : fs_rooms = split ("ROOM,ADMINISTRATION",",")

Dim co_rooms : co_rooms = Split ("ROOM,ACCOUNTS PAYABLE COORDINATOR,ASSISTANT SUPERINTENDENT," _
& "ASSISTANT SUPERINTENDENT SECRETARY,BUSINESS MANAGER,GUEST COMPUTER,PAYROLL COORDINATOR,SUPERINTENDENT,SUPERINTENDENT SECRETARY",",")

Dim bb_rooms : bb_rooms = Split ("ROOM,BUS BARN,AUTO TECH",",")

Dim ss_rooms : ss_rooms = Split ("ROOM,031,032,033,034,035,036,037,038",",")

Dim tech_rooms : tech_rooms = Split ("ROOM,NETWORK ADMINISTRATOR,RECEPTIONIST,SYSTEMS ADMINISTRATOR," _
& "TECH DIRECTOR,WEB MASTER,INVENTORY COMPUTER,TECH 1,TECH 2,TRAINING LAB EAST,TRAINING LAB WEST",",")

Dim mai_rooms : mai_rooms = Split ("ROOM,MAINTENANCE",",")

'User Type
Dim com_level : com_level = Split ("User Type,Teacher,Student,nComputing",",")

'Computer Type
Dim com_type : com_type = Split ("Computer Type,Desktop,Laptop,nComputing",",")

'Computer Numbers
dim com_num : com_num = split ("Computer Number,01,02,03,04,05,06,07,08,09,10," _
& "11,12,13,14,15,16,17,18,19,20," _
& "21,22,23,24,25,26,27,28,29,30," _
& "31,32,33,34,35,36,37,38,39,40," _
& "41,42,43,44,45,46,47,48,49,50,51,52",",")

'Selection for campus names
sub sel_campus_onchange
  Dim CampusName
  clear_combo sel_room
  select case sel_campus.value
    Case 0 'Campus
    Case 1 'Alamo
      CampusName = "AL"
      load_combo sel_room, alamo_rooms
    Case 2 'Apache
      CampusName = "AP"
      load_combo sel_room, apache_rooms
    Case 3 'Intermediate
      CampusName = "IN"
      load_combo sel_room, intermediate_rooms
    Case 4 'Middle School
      CampusName = "MS"
      load_combo sel_room, ms_rooms
    Case 5 'High School
      CampusName="HS"
      load_combo sel_room, hs_rooms
    Case 6 'Butz
      CampusName="BU"
      load_combo sel_room, butz_rooms
    Case 7 'Food Services
      CampusName="IN"
      load_combo sel_room, fs_rooms
    Case 8 'Central Office
      CampusName="CO"
      load_combo sel_room, co_rooms
    Case 9 'Bus Barn
      CampusName="BB"
      load_combo sel_room, bb_rooms
    Case 10 'Special Services
      CampusName="SS"
      load_combo sel_room, ss_rooms
    Case 11 'Technology
      CampusName="TC"
      load_combo sel_room, tech_rooms
    Case 12 'Maintenance
      CampusName="HS"
      load_combo sel_room, mai_rooms
  End select

  'You may be able to remove each CampusName='xx' section with some logic here
  'but we seem to be missing some elements (for Food Services, Special Services, Technology?)

  ComputerName.value = CampusName
end Sub

'Selection for campus rooms
Dim RoomNumber
sub sel_room_onchange
  clear_combo sel_computer
  if sel_room.value = 0 Then exit sub
  load_combo sel_computer, com_type
  
    If sel_campus.value = 1 And sel_room.value = 1 Then
  	RoomNumber = "A01"
  ElseIf sel_campus.value = 1 And sel_room.value = 2 Then
  	RoomNumber = "A02"
  ElseIf sel_campus.value = 1 And sel_room.value = 3 Then
  	RoomNumber = "A03"
  ElseIf sel_campus.value = 1 And sel_room.value = 4 Then
  	RoomNumber = "A04"
  ElseIf sel_campus.value = 1 And sel_room.value = 5 Then
  	RoomNumber = "A05"
  ElseIf sel_campus.value = 1 And sel_room.value = 6 Then
  	RoomNumber = "A06"
  ElseIf sel_campus.value = 1 And sel_room.value = 7 Then
  	RoomNumber = "A07"
  ElseIf sel_campus.value = 1 And sel_room.value = 8 Then
  	RoomNumber = "A08"
  ElseIf sel_campus.value = 1 And sel_room.value = 9 Then
  	RoomNumber = "A09"
  ElseIf sel_campus.value = 1 And sel_room.value = 10 Then
  	RoomNumber = "A10"
  ElseIf sel_campus.value = 1 And sel_room.value = 11 Then
  	RoomNumber = "B01"
  ElseIf sel_campus.value = 1 And sel_room.value = 12 Then
  	RoomNumber = "B02"
  ElseIf sel_campus.value = 1 And sel_room.value = 13 Then
  	RoomNumber = "B03"
  ElseIf sel_campus.value = 1 And sel_room.value = 14 Then
  	RoomNumber = "B04"
  ElseIf sel_campus.value = 1 And sel_room.value = 15 Then
  	RoomNumber = "B05"
  ElseIf sel_campus.value = 1 And sel_room.value = 16 Then
  	RoomNumber = "B06"
  ElseIf sel_campus.value = 1 And sel_room.value = 17 Then
  	RoomNumber = "B07"
  ElseIf sel_campus.value = 1 And sel_room.value = 18 Then
  	RoomNumber = "B08"
  ElseIf sel_campus.value = 1 And sel_room.value = 19 Then
  	RoomNumber = "B09"
  ElseIf sel_campus.value = 1 And sel_room.value = 20 Then
  	RoomNumber = "C01"
  ElseIf sel_campus.value = 1 And sel_room.value = 21 Then
  	RoomNumber = "C02"
  ElseIf sel_campus.value = 1 And sel_room.value = 22 Then
  	RoomNumber = "C03"
  ElseIf sel_campus.value = 1 And sel_room.value = 23 Then
  	RoomNumber = "C04"
  ElseIf sel_campus.value = 1 And sel_room.value = 24 Then
  	RoomNumber = "C05"
  ElseIf sel_campus.value = 1 And sel_room.value = 25 Then
  	RoomNumber = "C06"
  ElseIf sel_campus.value = 1 And sel_room.value = 26 Then
  	RoomNumber = "C07"
  ElseIf sel_campus.value = 1 And sel_room.value = 27 Then
  	RoomNumber = "C08"
  ElseIf sel_campus.value = 1 And sel_room.value = 28 Then
  	RoomNumber = "C09"
  ElseIf sel_campus.value = 1 And sel_room.value = 29 Then
  	RoomNumber = "C10"
  ElseIf sel_campus.value = 1 And sel_room.value = 30 Then
  	RoomNumber = "C11"
  ElseIf sel_campus.value = 1 And sel_room.value = 31 Then
  	RoomNumber = "D01"
  ElseIf sel_campus.value = 1 And sel_room.value = 32 Then
  	RoomNumber = "D02"
  ElseIf sel_campus.value = 1 And sel_room.value = 33 Then
  	RoomNumber = "D03"
  ElseIf sel_campus.value = 1 And sel_room.value = 34 Then
  	RoomNumber = "D04"
  ElseIf sel_campus.value = 1 And sel_room.value = 35 Then
  	RoomNumber = "D05"
  ElseIf sel_campus.value = 1 And sel_room.value = 36 Then
  	RoomNumber = "D06"
  ElseIf sel_campus.value = 1 And sel_room.value = 37 Then
  	RoomNumber = "D07"
  ElseIf sel_campus.value = 1 And sel_room.value = 38 Then
  	RoomNumber = "D08"
  ElseIf sel_campus.value = 1 And sel_room.value = 39 Then
  	RoomNumber = "D09"
  ElseIf sel_campus.value = 1 And sel_room.value = 40 Then
  	RoomNumber = "D10"
  ElseIf sel_campus.value = 1 And sel_room.value = 41 Then
  	RoomNumber = "D11"
  ElseIf sel_campus.value = 1 And sel_room.value = 42 Then
  	RoomNumber = "COU"
  ElseIf sel_campus.value = 1 And sel_room.value = 43 Then
  	RoomNumber = "FRD"
  ElseIf sel_campus.value = 1 And sel_room.value = 44 Then
  	RoomNumber = "NUR"
  ElseIf sel_campus.value = 1 And sel_room.value = 45 Then
  	RoomNumber = "PRI"
  ElseIf sel_campus.value = 1 And sel_room.value = 46 Then
  	RoomNumber = "SEC"
  ElseIf sel_campus.value = 1 And sel_room.value = 47 Then
  	RoomNumber = "TCL"
  ElseIf sel_campus.value = 1 And sel_room.value = 48 Then
  	RoomNumber = "MSC"
  ElseIf sel_campus.value = 1 And sel_room.value = 49 Then
  	RoomNumber = "LIB"
  ElseIf sel_campus.value = 1 And sel_room.value = 50 Then
  	RoomNumber = "GYM"
  ElseIf sel_campus.value = 1 And sel_room.value = 51 Then
  	RoomNumber = "CAF"

	'Apache Rooms
  ElseIf sel_campus.value = 2 And sel_room.value = 1 Then
  	RoomNumber = "001"
  ElseIf sel_campus.value = 2 And sel_room.value = 2 Then
  	RoomNumber = "002"
  ElseIf sel_campus.value = 2 And sel_room.value = 3 Then
  	RoomNumber = "003"
  ElseIf sel_campus.value = 2 And sel_room.value = 4 Then
  	RoomNumber = "004"
  ElseIf sel_campus.value = 2 And sel_room.value = 5 Then
  	RoomNumber = "005"
  ElseIf sel_campus.value = 2 And sel_room.value = 6 Then
  	RoomNumber = "006"
  ElseIf sel_campus.value = 2 And sel_room.value = 7 Then
  	RoomNumber = "007"
  ElseIf sel_campus.value = 2 And sel_room.value = 8 Then
  	RoomNumber = "008"
  ElseIf sel_campus.value = 2 And sel_room.value = 9 Then
  	RoomNumber = "009"
  ElseIf sel_campus.value = 2 And sel_room.value = 10 Then
  	RoomNumber = "010"
  ElseIf sel_campus.value = 2 And sel_room.value = 11 Then
  	RoomNumber = "011"
  ElseIf sel_campus.value = 2 And sel_room.value = 12 Then
  	RoomNumber = "012"
  ElseIf sel_campus.value = 2 And sel_room.value = 13 Then
  	RoomNumber = "013"
  ElseIf sel_campus.value = 2 And sel_room.value = 14 Then
  	RoomNumber = "014"
  ElseIf sel_campus.value = 2 And sel_room.value = 15 Then
  	RoomNumber = "015"
  ElseIf sel_campus.value = 2 And sel_room.value = 16 Then
  	RoomNumber = "016"
  ElseIf sel_campus.value = 2 And sel_room.value = 17 Then
  	RoomNumber = "017"
  ElseIf sel_campus.value = 2 And sel_room.value = 18 Then
  	RoomNumber = "018"
  ElseIf sel_campus.value = 2 And sel_room.value = 19 Then
  	RoomNumber = "019"
  ElseIf sel_campus.value = 2 And sel_room.value = 20 Then
  	RoomNumber = "020"
  ElseIf sel_campus.value = 2 And sel_room.value = 21 Then
  	RoomNumber = "021"
  ElseIf sel_campus.value = 2 And sel_room.value = 22 Then
  	RoomNumber = "022"
  ElseIf sel_campus.value = 2 And sel_room.value = 23 Then
  	RoomNumber = "023"
  ElseIf sel_campus.value = 2 And sel_room.value = 24 Then
  	RoomNumber = "024"
  ElseIf sel_campus.value = 2 And sel_room.value = 25 Then
  	RoomNumber = "025"
  ElseIf sel_campus.value = 2 And sel_room.value = 26 Then
  	RoomNumber = "326"
  ElseIf sel_campus.value = 2 And sel_room.value = 27 Then
  	RoomNumber = "327"
  ElseIf sel_campus.value = 2 And sel_room.value = 28 Then
  	RoomNumber = "328"
  ElseIf sel_campus.value = 2 And sel_room.value = 29 Then
  	RoomNumber = "329"
  ElseIf sel_campus.value = 2 And sel_room.value = 30 Then
  	RoomNumber = "330"
  ElseIf sel_campus.value = 2 And sel_room.value = 31 Then
  	RoomNumber = "331"
  ElseIf sel_campus.value = 2 And sel_room.value = 32 Then
  	RoomNumber = "332"
  ElseIf sel_campus.value = 2 And sel_room.value = 33 Then
  	RoomNumber = "333"
  ElseIf sel_campus.value = 2 And sel_room.value = 34 Then
  	RoomNumber = "334"
  ElseIf sel_campus.value = 2 And sel_room.value = 35 Then
  	RoomNumber = "335"
  ElseIf sel_campus.value = 2 And sel_room.value = 36 Then
  	RoomNumber = "COU"
  ElseIf sel_campus.value = 2 And sel_room.value = 37 Then
  	RoomNumber = "FRD"
  ElseIf sel_campus.value = 2 And sel_room.value = 38 Then
  	RoomNumber = "NUR"
  ElseIf sel_campus.value = 2 And sel_room.value = 39 Then
  	RoomNumber = "PRI"
  ElseIf sel_campus.value = 2 And sel_room.value = 40 Then
  	RoomNumber = "SEC"
  ElseIf sel_campus.value = 2 And sel_room.value = 41 Then
  	RoomNumber = "TCL"
  ElseIf sel_campus.value = 2 And sel_room.value = 42 Then
  	RoomNumber = "MSC"
  ElseIf sel_campus.value = 2 And sel_room.value = 43 Then
  	RoomNumber = "LIB"
  ElseIf sel_campus.value = 2 And sel_room.value = 44 Then
  	RoomNumber = "GYM"
  ElseIf sel_campus.value = 2 And sel_room.value = 45 Then
  	RoomNumber = "CAF"

	'Intermediate Rooms
  ElseIf sel_campus.value = 3 And sel_room.value = 1 Then
  	RoomNumber = "DARE"
  ElseIf sel_campus.value = 3 And sel_room.value = 2 Then
  	RoomNumber = "002"
  ElseIf sel_campus.value = 3 And sel_room.value = 3 Then
  	RoomNumber = "003"
  ElseIf sel_campus.value = 3 And sel_room.value = 4 Then
  	RoomNumber = "004"
  ElseIf sel_campus.value = 3 And sel_room.value = 5 Then
  	RoomNumber = "005"
  ElseIf sel_campus.value = 3 And sel_room.value = 6 Then
  	RoomNumber = "006"
  ElseIf sel_campus.value = 3 And sel_room.value = 7 Then
  	RoomNumber = "007"
  ElseIf sel_campus.value = 3 And sel_room.value = 8 Then
  	RoomNumber = "008"
  ElseIf sel_campus.value = 3 And sel_room.value = 9 Then
  	RoomNumber = "009"
  ElseIf sel_campus.value = 3 And sel_room.value = 10 Then
  	RoomNumber = "010"
  ElseIf sel_campus.value = 3 And sel_room.value = 11 Then
  	RoomNumber = "011"
  ElseIf sel_campus.value = 3 And sel_room.value = 12 Then
  	RoomNumber = "012"
  ElseIf sel_campus.value = 3 And sel_room.value = 13 Then
  	RoomNumber = "013"
  ElseIf sel_campus.value = 3 And sel_room.value = 14 Then
  	RoomNumber = "014"
  ElseIf sel_campus.value = 3 And sel_room.value = 15 Then
  	RoomNumber = "015"
  ElseIf sel_campus.value = 3 And sel_room.value = 16 Then
  	RoomNumber = "016"
  ElseIf sel_campus.value = 3 And sel_room.value = 17 Then
  	RoomNumber = "017"
  ElseIf sel_campus.value = 3 And sel_room.value = 18 Then
  	RoomNumber = "018"
  ElseIf sel_campus.value = 3 And sel_room.value = 19 Then
  	RoomNumber = "019"
  ElseIf sel_campus.value = 3 And sel_room.value = 20 Then
  	RoomNumber = "020"
  ElseIf sel_campus.value = 3 And sel_room.value = 21 Then
  	RoomNumber = "021"
  ElseIf sel_campus.value = 3 And sel_room.value = 22 Then
  	RoomNumber = "022"
  ElseIf sel_campus.value = 3 And sel_room.value = 23 Then
  	RoomNumber = "023"
  ElseIf sel_campus.value = 3 And sel_room.value = 24 Then
  	RoomNumber = "024"
  ElseIf sel_campus.value = 3 And sel_room.value = 25 Then
  	RoomNumber = "025"
  ElseIf sel_campus.value = 3 And sel_room.value = 26 Then
  	RoomNumber = "026"
  ElseIf sel_campus.value = 3 And sel_room.value = 27 Then
  	RoomNumber = "027"
  ElseIf sel_campus.value = 3 And sel_room.value = 28 Then
  	RoomNumber = "028"
  ElseIf sel_campus.value = 3 And sel_room.value = 29 Then
  	RoomNumber = "COU"
  ElseIf sel_campus.value = 3 And sel_room.value = 30 Then
  	RoomNumber = "FRD"
  ElseIf sel_campus.value = 3 And sel_room.value = 31 Then
  	RoomNumber = "NUR"
  ElseIf sel_campus.value = 3 And sel_room.value = 32 Then
  	RoomNumber = "PRI"
  ElseIf sel_campus.value = 3 And sel_room.value = 33 Then
  	RoomNumber = "SEC"
  ElseIf sel_campus.value = 3 And sel_room.value = 34 Then
  	RoomNumber = "TCL"
  ElseIf sel_campus.value = 3 And sel_room.value = 35 Then
  	RoomNumber = "MSC"
  ElseIf sel_campus.value = 3 And sel_room.value = 36 Then
  	RoomNumber = "LIB"
  ElseIf sel_campus.value = 3 And sel_room.value = 37 Then
  	RoomNumber = "GYM"
  ElseIf sel_campus.value = 3 And sel_room.value = 38 Then
  	RoomNumber = "ISS"
  ElseIf sel_campus.value = 3 And sel_room.value = 39 Then
  	RoomNumber = "CAF"

  'Middle School Rooms
  ElseIf sel_campus.value = 4 And sel_room.value = 1 Then
  	RoomNumber = "101"
  ElseIf sel_campus.value = 4 And sel_room.value = 2 Then
  	RoomNumber = "102"
  ElseIf sel_campus.value = 4 And sel_room.value = 3 Then
  	RoomNumber = "103"
  ElseIf sel_campus.value = 4 And sel_room.value = 4 Then
  	RoomNumber = "104"
  ElseIf sel_campus.value = 4 And sel_room.value = 5 Then
  	RoomNumber = "105"
  ElseIf sel_campus.value = 4 And sel_room.value = 6 Then
  	RoomNumber = "106"
  ElseIf sel_campus.value = 4 And sel_room.value = 7 Then
  	RoomNumber = "107"
  ElseIf sel_campus.value = 4 And sel_room.value = 8 Then
  	RoomNumber = "108"
  ElseIf sel_campus.value = 4 And sel_room.value = 9 Then
  	RoomNumber = "109"
  ElseIf sel_campus.value = 4 And sel_room.value = 10 Then
  	RoomNumber = "110"
  ElseIf sel_campus.value = 4 And sel_room.value = 11 Then
  	RoomNumber = "111"
  ElseIf sel_campus.value = 4 And sel_room.value = 12 Then
  	RoomNumber = "112"
  ElseIf sel_campus.value = 4 And sel_room.value = 13 Then
  	RoomNumber = "113"
  ElseIf sel_campus.value = 4 And sel_room.value = 14 Then
  	RoomNumber = "114"
  ElseIf sel_campus.value = 4 And sel_room.value = 15 Then
  	RoomNumber = "115"
  ElseIf sel_campus.value = 4 And sel_room.value = 16 Then
  	RoomNumber = "115"
  ElseIf sel_campus.value = 4 And sel_room.value = 17 Then
  	RoomNumber = "117"
  ElseIf sel_campus.value = 4 And sel_room.value = 18 Then
  	RoomNumber = "118"
  ElseIf sel_campus.value = 4 And sel_room.value = 19 Then
  	RoomNumber = "119"
  ElseIf sel_campus.value = 4 And sel_room.value = 20 Then
  	RoomNumber = "120"
  ElseIf sel_campus.value = 4 And sel_room.value = 21 Then
  	RoomNumber = "121"
  ElseIf sel_campus.value = 4 And sel_room.value = 22 Then
  	RoomNumber = "122"
  ElseIf sel_campus.value = 4 And sel_room.value = 23 Then
  	RoomNumber = "123"
  ElseIf sel_campus.value = 4 And sel_room.value = 24 Then
  	RoomNumber = "124"
  ElseIf sel_campus.value = 4 And sel_room.value = 25 Then
  	RoomNumber = "125"
  ElseIf sel_campus.value = 4 And sel_room.value = 26 Then
  	RoomNumber = "126"
  ElseIf sel_campus.value = 4 And sel_room.value = 27 Then
  	RoomNumber = "127"
  ElseIf sel_campus.value = 4 And sel_room.value = 28 Then
  	RoomNumber = "128"
  ElseIf sel_campus.value = 4 And sel_room.value = 29 Then
  	RoomNumber = "129"
  ElseIf sel_campus.value = 4 And sel_room.value = 30 Then
  	RoomNumber = "130"
  ElseIf sel_campus.value = 4 And sel_room.value = 31 Then
  	RoomNumber = "131"
  ElseIf sel_campus.value = 4 And sel_room.value = 32 Then
  	RoomNumber = "132"
  ElseIf sel_campus.value = 4 And sel_room.value = 33 Then
  	RoomNumber = "133"
  ElseIf sel_campus.value = 4 And sel_room.value = 34 Then
  	RoomNumber = "134"
  ElseIf sel_campus.value = 4 And sel_room.value = 35 Then
  	RoomNumber = "135"
  ElseIf sel_campus.value = 4 And sel_room.value = 36 Then
  	RoomNumber = "136"
  ElseIf sel_campus.value = 4 And sel_room.value = 37 Then
  	RoomNumber = "137"
  ElseIf sel_campus.value = 4 And sel_room.value = 38 Then
  	RoomNumber = "138"
  ElseIf sel_campus.value = 4 And sel_room.value = 39 Then
  	RoomNumber = "139"
  ElseIf sel_campus.value = 4 And sel_room.value = 40 Then
  	RoomNumber = "140"
  ElseIf sel_campus.value = 4 And sel_room.value = 41 Then
  	RoomNumber = "141"
  ElseIf sel_campus.value = 4 And sel_room.value = 42 Then
  	RoomNumber = "142"
  ElseIf sel_campus.value = 4 And sel_room.value = 43 Then
  	RoomNumber = "143"
  ElseIf sel_campus.value = 4 And sel_room.value = 44 Then
  	RoomNumber = "144"
  ElseIf sel_campus.value = 4 And sel_room.value = 45 Then
  	RoomNumber = "145"
  ElseIf sel_campus.value = 4 And sel_room.value = 46 Then
  	RoomNumber = "146"
  ElseIf sel_campus.value = 4 And sel_room.value = 47 Then
  	RoomNumber = "147"
  ElseIf sel_campus.value = 4 And sel_room.value = 48 Then
  	RoomNumber = "148"
  ElseIf sel_campus.value = 4 And sel_room.value = 49 Then
  	RoomNumber = "149"
  ElseIf sel_campus.value = 4 And sel_room.value = 50 Then
  	RoomNumber = "150"
  ElseIf sel_campus.value = 4 And sel_room.value = 51 Then
  	RoomNumber = "151"
  ElseIf sel_campus.value = 4 And sel_room.value = 52 Then
  	RoomNumber = "COU"
  ElseIf sel_campus.value = 4 And sel_room.value = 53 Then
  	RoomNumber = "FRD"
  ElseIf sel_campus.value = 4 And sel_room.value = 54 Then
  	RoomNumber = "NUR"
  ElseIf sel_campus.value = 4 And sel_room.value = 55 Then
  	RoomNumber = "PRI"
  ElseIf sel_campus.value = 4 And sel_room.value = 56 Then
  	RoomNumber = "APRI"
  ElseIf sel_campus.value = 4 And sel_room.value = 57 Then
  	RoomNumber = "SEC"
  ElseIf sel_campus.value = 4 And sel_room.value = 58 Then
  	RoomNumber = "TCL"
  ElseIf sel_campus.value = 4 And sel_room.value = 59 Then
  	RoomNumber = "MSC"
  ElseIf sel_campus.value = 4 And sel_room.value = 60 Then
  	RoomNumber = "LIB"
  ElseIf sel_campus.value = 4 And sel_room.value = 61 Then
  	RoomNumber = "GYM"
  ElseIf sel_campus.value = 4 And sel_room.value = 62 Then
  	RoomNumber = "ISS"
  ElseIf sel_campus.value = 4 And sel_room.value = 63 Then
  	RoomNumber = "CAF"

  'High School Rooms
  ElseIf sel_campus.value = 5 And sel_room.value = 1 Then
  	RoomNumber = "001"
  ElseIf sel_campus.value = 5 And sel_room.value = 2 Then
  	RoomNumber = "002"
  ElseIf sel_campus.value = 5 And sel_room.value = 3 Then
  	RoomNumber = "003"
  ElseIf sel_campus.value = 5 And sel_room.value = 4 Then
  	RoomNumber = "004"
  ElseIf sel_campus.value = 5 And sel_room.value = 5 Then
  	RoomNumber = "005"
  ElseIf sel_campus.value = 5 And sel_room.value = 6 Then
  	RoomNumber = "006"
  ElseIf sel_campus.value = 5 And sel_room.value = 7 Then
  	RoomNumber = "007"
  ElseIf sel_campus.value = 5 And sel_room.value = 8 Then
  	RoomNumber = "008"
  ElseIf sel_campus.value = 5 And sel_room.value = 9 Then
  	RoomNumber = "009"
  ElseIf sel_campus.value = 5 And sel_room.value = 10 Then
  	RoomNumber = "010"
  ElseIf sel_campus.value = 5 And sel_room.value = 11 Then
  	RoomNumber = "011"
  ElseIf sel_campus.value = 5 And sel_room.value = 12 Then
  	RoomNumber = "012"
  ElseIf sel_campus.value = 5 And sel_room.value = 13 Then
  	RoomNumber = "013"
  ElseIf sel_campus.value = 5 And sel_room.value = 14 Then
  	RoomNumber = "014"
  ElseIf sel_campus.value = 5 And sel_room.value = 15 Then
  	RoomNumber = "015"
  ElseIf sel_campus.value = 5 And sel_room.value = 16 Then
  	RoomNumber = "015"
  ElseIf sel_campus.value = 5 And sel_room.value = 17 Then
  	RoomNumber = "017"
  ElseIf sel_campus.value = 5 And sel_room.value = 18 Then
  	RoomNumber = "018"
  ElseIf sel_campus.value = 5 And sel_room.value = 19 Then
  	RoomNumber = "019"
  ElseIf sel_campus.value = 5 And sel_room.value = 20 Then
  	RoomNumber = "020"
  ElseIf sel_campus.value = 5 And sel_room.value = 21 Then
  	RoomNumber = "021"
  ElseIf sel_campus.value = 5 And sel_room.value = 22 Then
  	RoomNumber = "022"
  ElseIf sel_campus.value = 5 And sel_room.value = 23 Then
  	RoomNumber = "023"
  ElseIf sel_campus.value = 5 And sel_room.value = 24 Then
  	RoomNumber = "024"
  ElseIf sel_campus.value = 5 And sel_room.value = 25 Then
  	RoomNumber = "025"
  ElseIf sel_campus.value = 5 And sel_room.value = 26 Then
  	RoomNumber = "026"
  ElseIf sel_campus.value = 5 And sel_room.value = 27 Then
  	RoomNumber = "027"
  ElseIf sel_campus.value = 5 And sel_room.value = 28 Then
  	RoomNumber = "028"
  ElseIf sel_campus.value = 5 And sel_room.value = 29 Then
  	RoomNumber = "029"
  ElseIf sel_campus.value = 5 And sel_room.value = 30 Then
  	RoomNumber = "030"
  ElseIf sel_campus.value = 5 And sel_room.value = 31 Then
  	RoomNumber = "031"
  ElseIf sel_campus.value = 5 And sel_room.value = 32 Then
  	RoomNumber = "A31"
  ElseIf sel_campus.value = 5 And sel_room.value = 33 Then
  	RoomNumber = "032"
  ElseIf sel_campus.value = 5 And sel_room.value = 34 Then
  	RoomNumber = "033"
  ElseIf sel_campus.value = 5 And sel_room.value = 35 Then
  	RoomNumber = "034"
  ElseIf sel_campus.value = 5 And sel_room.value = 36 Then
  	RoomNumber = "035"
  ElseIf sel_campus.value = 5 And sel_room.value = 37 Then
  	RoomNumber = "036"
  ElseIf sel_campus.value = 5 And sel_room.value = 38 Then
  	RoomNumber = "037"
  ElseIf sel_campus.value = 5 And sel_room.value = 39 Then
  	RoomNumber = "038"
  ElseIf sel_campus.value = 5 And sel_room.value = 40 Then
  	RoomNumber = "039"
  ElseIf sel_campus.value = 5 And sel_room.value = 41 Then
  	RoomNumber = "040"
  ElseIf sel_campus.value = 5 And sel_room.value = 42 Then
  	RoomNumber = "041"
  ElseIf sel_campus.value = 5 And sel_room.value = 43 Then
  	RoomNumber = "042"
  ElseIf sel_campus.value = 5 And sel_room.value = 44 Then
  	RoomNumber = "043"
  ElseIf sel_campus.value = 5 And sel_room.value = 45 Then
  	RoomNumber = "044"
  ElseIf sel_campus.value = 5 And sel_room.value = 46 Then
  	RoomNumber = "045"
  ElseIf sel_campus.value = 5 And sel_room.value = 47 Then
  	RoomNumber = "046"
  ElseIf sel_campus.value = 5 And sel_room.value = 48 Then
  	RoomNumber = "047"
  ElseIf sel_campus.value = 5 And sel_room.value = 49 Then
  	RoomNumber = "048"
  ElseIf sel_campus.value = 5 And sel_room.value = 50 Then
  	RoomNumber = "049"
  ElseIf sel_campus.value = 5 And sel_room.value = 51 Then
  	RoomNumber = "050"
  ElseIf sel_campus.value = 5 And sel_room.value = 52 Then
  	RoomNumber = "051"
  ElseIf sel_campus.value = 5 And sel_room.value = 53 Then
  	RoomNumber = "052"
  ElseIf sel_campus.value = 5 And sel_room.value = 54 Then
  	RoomNumber = "COU"
  ElseIf sel_campus.value = 5 And sel_room.value = 55 Then
  	RoomNumber = "FRD"
  ElseIf sel_campus.value = 5 And sel_room.value = 56 Then
  	RoomNumber = "NUR"
  ElseIf sel_campus.value = 5 And sel_room.value = 57 Then
  	RoomNumber = "PRI"
  ElseIf sel_campus.value = 5 And sel_room.value = 58 Then
  	RoomNumber = "APRI"
  ElseIf sel_campus.value = 5 And sel_room.value = 59 Then
  	RoomNumber = "SEC"
  ElseIf sel_campus.value = 5 And sel_room.value = 60 Then
  	RoomNumber = "TCL"
  ElseIf sel_campus.value = 5 And sel_room.value = 61 Then
  	RoomNumber = "BND"
  ElseIf sel_campus.value = 5 And sel_room.value = 62 Then
  	RoomNumber = "CHR"
  ElseIf sel_campus.value = 5 And sel_room.value = 63 Then
  	RoomNumber = "LIB"
  ElseIf sel_campus.value = 5 And sel_room.value = 64 Then
  	RoomNumber = "GYM"
  ElseIf sel_campus.value = 5 And sel_room.value = 65 Then
  	RoomNumber = "ISS"
  ElseIf sel_campus.value = 5 And sel_room.value = 66 Then
  	RoomNumber = "GCS"
  ElseIf sel_campus.value = 5 And sel_room.value = 67 Then
  	RoomNumber = "CAF"

  'Butz Rooms
  ElseIf sel_campus.value = 6 And sel_room.value = 1 Then
  	RoomNumber = "BLD"
  ElseIf sel_campus.value = 6 And sel_room.value = 2 Then
  	RoomNumber = "BLS"
  ElseIf sel_campus.value = 6 And sel_room.value = 3 Then
  	RoomNumber = "PRI"
  ElseIf sel_campus.value = 6 And sel_room.value = 4 Then
  	RoomNumber = "TCL"
  ElseIf sel_campus.value = 6 And sel_room.value = 5 Then
  	RoomNumber = "CUR"
  ElseIf sel_campus.value = 6 And sel_room.value = 6 Then
  	RoomNumber = "DAE"
  ElseIf sel_campus.value = 6 And sel_room.value = 7 Then
  	RoomNumber = "DCD"
  ElseIf sel_campus.value = 6 And sel_room.value = 8 Then
  	RoomNumber = "TSC"
  ElseIf sel_campus.value = 6 And sel_room.value = 9 Then
  	RoomNumber = "DCT"
  ElseIf sel_campus.value = 6 And sel_room.value = 10 Then
  	RoomNumber = "DPC"
  ElseIf sel_campus.value = 6 And sel_room.value = 11 Then
  	RoomNumber = "MIR"
  ElseIf sel_campus.value = 6 And sel_room.value = 12 Then
  	RoomNumber = "MRA"
  ElseIf sel_campus.value = 6 And sel_room.value = 13 Then
  	RoomNumber = "NUR"
  ElseIf sel_campus.value = 6 And sel_room.value = 14 Then
  	RoomNumber = "CAF"

  'Food Services Rooms
  ElseIf sel_campus.value = 7 And sel_room.value = 1 Then
  	RoomNumber = "FDS"

  'Central Office Rooms
  ElseIf sel_campus.value = 8 And sel_room.value = 1 Then
  	RoomNumber = "APC"
  ElseIf sel_campus.value = 8 And sel_room.value = 2 Then
  	RoomNumber = "ASU"
  ElseIf sel_campus.value = 8 And sel_room.value = 3 Then
  	RoomNumber = "ASC"
  ElseIf sel_campus.value = 8 And sel_room.value = 4 Then
  	RoomNumber = "BMA"
  ElseIf sel_campus.value = 8 And sel_room.value = 5 Then
  	RoomNumber = "GUE"
  ElseIf sel_campus.value = 8 And sel_room.value = 6 Then
  	RoomNumber = "PRC"
  ElseIf sel_campus.value = 8 And sel_room.value = 7 Then
  	RoomNumber = "SUP"
  ElseIf sel_campus.value = 8 And sel_room.value = 8 Then
  	RoomNumber = "ASU"

  'Bus Barn Rooms
  ElseIf sel_campus.value = 9 And sel_room.value = 1 Then
  	RoomNumber = "OFC"
  ElseIf sel_campus.value = 9 And sel_room.value = 2 Then
  	RoomNumber = "ATT"

  'Special Services Rooms
  ElseIf sel_campus.value = 10 And sel_room.value = 1 Then
  	RoomNumber = "031"
  ElseIf sel_campus.value = 10 And sel_room.value = 2 Then
  	RoomNumber = "032"
  ElseIf sel_campus.value = 10 And sel_room.value = 3 Then
  	RoomNumber = "033"
  ElseIf sel_campus.value = 10 And sel_room.value = 4 Then
  	RoomNumber = "034"
  ElseIf sel_campus.value = 10 And sel_room.value = 5 Then
  	RoomNumber = "035"
  ElseIf sel_campus.value = 10 And sel_room.value = 6 Then
  	RoomNumber = "036"
  ElseIf sel_campus.value = 10 And sel_room.value = 7 Then
  	RoomNumber = "037"
  ElseIf sel_campus.value = 10 And sel_room.value = 8 Then
  	RoomNumber = "038"

  'Technology Rooms
  ElseIf sel_campus.value = 11 And sel_room.value = 1 Then
  	RoomNumber = "NET"
  ElseIf sel_campus.value = 11 And sel_room.value = 2 Then
  	RoomNumber = "FRT"
  ElseIf sel_campus.value = 11 And sel_room.value = 3 Then
  	RoomNumber = "SYS"
  ElseIf sel_campus.value = 11 And sel_room.value = 4 Then
  	RoomNumber = "TED"
  ElseIf sel_campus.value = 11 And sel_room.value = 5 Then
  	RoomNumber = "WEB"
  ElseIf sel_campus.value = 11 And sel_room.value = 6 Then
  	RoomNumber = "WIC"
  ElseIf sel_campus.value = 11 And sel_room.value = 7 Then
  	RoomNumber = "TC1"
  ElseIf sel_campus.value = 11 And sel_room.value = 8 Then
  	RoomNumber = "TC2"
  ElseIf sel_campus.value = 11 And sel_room.value = 9 Then
  	RoomNumber = "TLE"
  ElseIf sel_campus.value = 11 And sel_room.value = 10 Then
  	RoomNumber = "TLW"
  
  'Maintenance
  ElseIf sel_campus.value= 12 And sel_room.value = 1 Then
  	RoomNumber = "MAI"

  End If
  
  ComputerName.value = Left(ComputerName.value,2) & "RM" & RoomNumber
end Sub

'Selection for computer type
  dim DeviceType
Sub sel_computer_onchange
  clear_combo sel_level
  if sel_computer.value=0 then exit sub
  load_combo sel_level, com_level
    If sel_computer.value = 1 Then
    DeviceType = "D"
  ElseIf sel_computer.value = 2 Then
    DeviceType = "L"
  Else
  	DeviceType = "N"
  End If
  ComputerName.value = Left(ComputerName.value,7) & DeviceType
end Sub

'Selection for level number
sub sel_level_onchange
  dim PersonType
  clear_combo sel_number
  if sel_level.value=0 then exit sub
  load_combo sel_number, com_num
    If sel_level.value = 1 Then
    PersonType = "T"
  ElseIf sel_level.value = 2 Then
    PersonType = "S"
  Else
  	PersonType = "C"
  End If
  ComputerName.value = Left(Computername.value,8) & PersonType
end Sub

'Select for number
sub sel_number_onchange
  ComputerName.value = Left(ComputerName.value,9) & Right("0" & sel_number.value, 2)
  If Right(ComputerName.value,2) > 9 Then
  	ComputerName.value = Left(ComputerName.value,9) & Right(sel_number.value, 2)
  End If
  document.GetElementByID("Rename").disabled = false
end sub

Sub RenamePC
  Dim strComputer, strNewComputer, strDomainUser, strDomainPasswd, strLocalUser, strLocalPasswd, NewComputerName, uName, uPassword
  Dim iResponse : iResponse = Msgbox("Rename " & oldComputerName.value & " to " & Computername.value & "?", _
        vbYesNo, "Proceed with rename?")
  If iResponse = vbNo Then
    Msgbox "No changes will be made."
    exit sub
  End If
strComputer=OldComputerName.value
strNewComputer = ComputerName.value
strDomainUser = document.getElementById("uName").value & "@fsisd.local"
strDomainPasswd = document.getElementById("uPassword").value
strLocalUser = strComputer & "\administrator"
strLocalPasswd = "XXXXXXXX" 
' ------ END CONFIGURATION --------- 

'########################### 
' Connect to Computer 
'###########################
Dim objWMILocator, objWMIComputer, objWMIComputerSystem, rc, WScript, objWMIService, colOperatingSystems, objOperatingSystem
Set objWMILocator = CreateObject("WbemScripting.SWbemLocator") 
objWMILocator.Security_.AuthenticationLevel = 6 
Set objWMIComputer = objWMILocator.ConnectServer(strComputer, "root\cimv2", strLocalUser, strLocalPasswd) 
Set objWMIComputerSystem = objWMIComputer.Get( "Win32_ComputerSystem.Name='" & strComputer & "'") 
'########################### 
' Rename Computer 
'########################### 
rc = objWMIComputerSystem.Rename(strNewComputer, strDomainPasswd, strDomainUser) 
if rc <> 0 then 
Msgbox "Rename failed with error: " & rc 
else 
Msgbox "Successfully renamed " & strComputer & " to " & strNewComputer 
Msgbox "Rebooting..." 
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Shutdown)}!\\" & _
        strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    objOperatingSystem.Reboot()
Next

End if 

'  Next
end sub

sub disableButton()
  document.GetElementByID("Rename").disabled = true
end sub
</script>

<body bgcolor="white" onload="disableButton()">
<p>
<table>
	<tr>
		<td>
			<font color="white" size="5"><b>Old Computer Name:</b></font>
		</td>
		<td>
			<input type=text id="OldComputerName" name=OldComputerName size=45>
		</td>
	</tr>
	<tr>
		<td>
			<font color="white" size="5"><b>New Computer Name:</b></font>
		</td>
		<td>
			<input type=text id="ComputerName" name=ComputerName size=45>
		<td>
	</tr>
	<tr>
		<td>
			<font color="white" size="5"><b>User Name:</b></font>
		</td>
		<td>
			<input type=text name=uName size=45>
		</td>
	</tr>
	<tr>
		<td>
			<font color="white" size="5"><b>User Password:</b></font>
		</td>
		<td>
			<input type=password name=uPassword size=45>
		</td>
	</tr>
</table>
 <br>
<font color="white" size="7"><b>WARNING! WILL REBOOT COMPUTER!</b></font><BR>
<button onclick="RenamePC" id="Rename">Rename Computer</button>
</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Gabriel Clifton

ASKER
I really hate bugging on this, but this is a request from my boss. My boss would like to add two pieces of functionality to the script, one that would check if the computer account already exists. I was thinking along the lines of:
Option Explicit

Dim objNetwork, strComputer, strDomain
Dim objTrans, strComputerDN

Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1

' Prompt for NetBIOS name of computer.
strComputer = InputBox("Enter computer name")

' Retrieve NetBIOS name of the domain.
Set objNetwork = CreateObject("Wscript.Network")
strDomain = objNetwork.UserDomain

' Use NameTranslate to convert NT name into DN.
Set objTrans = CreateObject("NameTranslate")
' Initialize by locating GC.
objTrans.Init ADS_NAME_INITTYPE_GC, ""

' Use Set method to specify NT format of name.
' Be sure to append the "$" to the NetBIOS name of the computer.
' Trap error if object does not exist.
On Error Resume Next
objTrans.Set ADS_NAME_TYPE_NT4, strDomain & "\" & strComputer & "$"
If (Err.Number = 0) Then
  On Error GoTo 0
  ' Computer exists.
  ' Use Get method to retrieve DN.
  strComputerDN = objTrans.Get(ADS_NAME_TYPE_1779)
  Wscript.Echo "Computer found: " & strComputerDN
Else
  On Error GoTo 0
  Wscript.Echo "Computer " & strComputer & " not found"
End If

Open in new window

And if computer account is found it will not allow you to name the computer what you have selected with innerhtml that states computer name is already taken, find out why and try again later.

And the other that would limit computer numbers for each computer type and room so that if room A is only supposed to have one teacher computer then they can only select one and if there are six teacher computers in the room it will allow you to select one through six.
Gabriel Clifton

ASKER
Changed these lines to check if the computer exists before allowing computer rename, but cannot change font of span id

'Select for number
sub sel_number_onchange
  ComputerName.value = Left(ComputerName.value,9) & Right("0" & sel_number.value, 2)
  If Right(ComputerName.value,2) > 9 Then
  	ComputerName.value = Left(ComputerName.value,9) & Right(sel_number.value, 2)
  End If
  
  ''''''''''''''''''''
Dim objNetwork, strNewComputer, strDomain
Dim objTrans, strComputerDN

Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1

' Prompt for NetBIOS name of computer.
strNewComputer = ComputerName.value

' Retrieve NetBIOS name of the domain.
Set objNetwork = CreateObject("Wscript.Network")
strDomain = objNetwork.UserDomain

' Use NameTranslate to convert NT name into DN.
Set objTrans = CreateObject("NameTranslate")
' Initialize by locating GC.
objTrans.Init ADS_NAME_INITTYPE_GC, ""

' Use Set method to specify NT format of name.
' Be sure to append the "$" to the NetBIOS name of the computer.
' Trap error if object does not exist.
On Error Resume Next
objTrans.Set ADS_NAME_TYPE_NT4, strDomain & "\" & strNewComputer & "$"
If (Err.Number = 0) Then
  On Error GoTo 0
  ' Computer exists.
  ' Use Get method to retrieve DN.
  strComputerDN = objTrans.Get(ADS_NAME_TYPE_1779)
  DataArea.InnerHTML = "Computer name already exists in Active Directory!"
    document.GetElementByID("Rename").disabled = true
Else
  On Error GoTo 0
    document.GetElementByID("Rename").disabled = false
End If
''''''''''''''''''''''
'  document.GetElementByID("Rename").disabled = false
end sub

Open in new window

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Gabriel Clifton

ASKER
I really need help on the final part of this HTA script. I would like, as requested by my boss, is to limit how many computer numbers are listed based on the campus / room number selected and whether it is a student computer or teacher computer. IE if room 1 in campus A should only have one student desktop, then the computer number dropdown should only display 1. But if room 2 in campus A should have forty student computers, the the dropdown should allow selection of 1 through 40. I have added lines that will check if the computer exists in AD after selection and displays warning, but I cannot get it to change if a computer name is typed in manually so if that is possible I would like assistance with that as well. This has been coming out nicely so far.

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="description" content="Created by Gabriel Clifton and sirbounty">
<meta name="description" content="Last Update: 05/09/2014">

<title>Computer Rename Application</title>
<style>
.divbody{
padding:0px 15px 0px 15px;
}

body
{
font-family: calibri, verdana, arial;
	color: 000000;
	background-color: #53769E;
	text-align: left;
}
.pretty-table
{
  padding: 0;
  margin: 0;
  border-collapse: collapse;
  border: 1px solid #333;
  font-size: 0.9em;
  color: #000;
  background: black;
}

.pretty-table caption
{
  caption-side: bottom;
  font-size: 0.9em;
  font-style: italic;
  text-align: right;
  padding: 0.5em 0;
}
.pretty-table td
{
  background-color:white;
  padding: 0.5em;
}
.pretty-table th, 
{
  padding: 0.5em;
  text-align: left;
  color: white;

}
.pretty-table th[scope=col]
{
  color: #000;
  background-color: #8fadcc;
  text-transform: uppercase;
  font-size: 0.9em;
  border-bottom: 2px solid #333;
  border-right: 2px solid #333;
}
.pretty-table th+th[scope=col]
{
  color: #fff;
  background-color: #7d98b3;
  border-right: 1px dotted #666;
}
.pretty-table th[scope=row]
{
  background-color: #b8cfe5;
  border-right: 2px solid #333;
}
.pretty-table tr.alt th, .pretty-table tr.alt td
{
  color: #2a4763;
}
.pretty-table tr:hover th[scope=row], .pretty-table tr:hover td
{
  background-color: #632a2a;
  color: #fff;
}
#status_bar {
  box-shadow:rgb(136, 136, 136) 0px 5px 5px;
  background-color:#F7F7F7;
  border:1px solid #A5A5A5;
  font-color: #A5A5A5;
  font-size: 70%;
  border-bottom:0px;
  bottom:0px;
  height:25px;
  margin:auto;
  padding:5px 5px 5px 5px;
  position:absolute;
  width:100%;
  z-index:500;
}

..tabs {
border-collapse: collapse;
color: black;
cursor: pointer;
cursor: hand;
font-family: arial;
font-size: 9pt;
font-weight: bold;
margin-top: 4px;
padding: 2px 4px 0px 4px;
position: relative;
text-align: center;
text-decoration: none;
z-index: 1;
}
..tabs0 {
background-color: LightGrey;
border: solid 1px black;
}
..tabs1 {
background-color: Gainsboro;
border-color: black;
border-style: solid solid hidden solid;
border-width: 1px; }
..nav {
border-collapse: collapse;
align: center;
padding: 0;
spacing: 0;
width: 100%; }

</style>
<HTA:APPLICATION
	ICON="\\Server\share\panther.ICO"
	APPLICATIONNAME="ComputerRename"
	BORDER="dialog"
	SCROLL="no" 
	MAXIMIZEBUTTON="no"
	SINGLEINSTANCE="no"
	CONTEXTMENU="no"
	WINDOWSTATE="normal"/> 	

</head>
<table border="0" width="100%"  cellspacing="0" cellpadding="0">
    <tr>
        <td width="33%" valign="top"><img src="\\Server\share\FtStocktonLogo_Large.png" alt="Panther" width="110" height="110"></td>
        <td width="34%" valign="top">
        <font size="8" color="white"><b><center>Fort Stockton<br>
            Independent School District</b></center></font>
        </td>
        <td width="33%" align="right" valign="top"><img src="\\Server\share\FtStocktonLogo_Large.png" alt="Panther" width="110" height="110"></td>
  </tr>
  <tr>
  <td></td>
  <td></td>
  			<td style="text-align:right;font-size:0.9em;font-weight:bold;font-style:oblique;color:#888888;">
				Created by Gabriel Clifton
			</td>
</tr>
</table>

<select id=sel_campus>
</select>
<select id=sel_room>
</select>
<select id=sel_computer>
</select>
<select id=sel_level>
</select>
<select id=sel_number>
</select>

<script language=vbscript>

'option explicit

Sub Window_onLoad
	width = "950"
	height = "720"
	' This moves the window to the middle of the screen
	Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") 
	Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor WHERE DeviceID='DesktopMonitor1'") 
	For Each objItem in ColItems 
	intHorizontal = objItem.ScreenWidth 
	intVertical = objItem.ScreenHeight 
	Next 
	intLeft = (intHorizontal - width)/2 
	intTop = (intVertical - height)/2 
	window.resizeTo width,height 
	
 Dim objNetwork : Set objNetwork = CreateObject("wscript.network")
 oldComputerName.value = objNetwork.ComputerName
End Sub

sub add_option (select_id, value, text)
  dim opt : set opt = document.createelement("option")
  opt.value = value
  opt.text = text
  select_id.add opt
  set opt = nothing
end sub

sub load_combo (select_id, option_array)
  dim i: for i = 0 to ubound(option_array)
    add_option select_id, i, option_array(i)
  next
end sub

sub clear_combo (select_id)
  select_id.options.length = 0
end sub

'Campus Names
load_combo sel_campus, array ("CAMPUS","ALAMO","APACHE","INTERMEDIATE","MIDDLE SCHOOL","HIGH SCHOOL","BUTZ","FOOD SERVICES","CENTRAL OFFICE","BUS BARN","SPECIAL SERVICES","TECHNOLOGY","MAINTENANCE")

'Campus Room Numbers
dim alamo_rooms : alamo_rooms = split ("ROOM,A01,A02,A03,A04,A05,A06,A07,A08,A09,A10," _
& "B01,B02,B03,B04,B05,B06,B07,B08,B09," _
& "C01,C02,C03,C04,C05,C06,C07,C08,C09,C10,C11," _
& "D01,D02,D03,D04,D05,D06,D07,D08,D09,D10,D11," _
& "COUNSELOR,FRONT DESK,NURSE,PRINCIPAL,SECRETARY,TIME CLOCK,MUSIC,LIBRARY,GYM,CAFETERIA,MOBILE LAB 1", ",")

dim apache_rooms : apache_rooms = split ("ROOM,001,002,003,004,005,006,007,008,009,010," _
& "011,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,326,327,328,329,330," _
& "331,332,333,334,335," _
& "COUNSELOR,FRONT DESK,NURSE,PRINCIPAL,SECRETARY,TIME CLOCK,MUSIC,LIBRARY,GYM,CAFETERIA,MOBILE LAB 1,MOBILE LAB 2",",")

dim intermediate_rooms : intermediate_rooms = split ("ROOM,DARE,002,003,004,005,006,007,008,009,010," _
& "010,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,026,027,028," _
& "COUNSELOR,FRONT DESK,NURSE,PRINCIPAL,SECRETARY,TIME CLOCK,MUSIC,LIBRARY,GYM,ISS,CAFETERIA,MOBILE LAB 1",",")

dim ms_rooms : ms_rooms = split ("ROOM,101,102,103,104,105,106,107,108,109,110," _
& "111,112,113,114,115,116,117,118,119,120," _
& "121,122,123,124,125,126,127,128,129,130," _
& "131,132,133,134,135,136,137,138,139,140," _
& "141,142,143,144,145,146,147,148,149,150,151," _
& "COUNSELOR,FRONT DESK,NURSE,PRINCIPAL,ASSISTANT PRINCIPAL,SECRETARY,TIME CLOCK,BAND,CHORI,LIBRARY,GYM,ISS,CAFETERIA,MOBILE LAB 1",",")

dim hs_rooms : hs_rooms = split ("ROOM,001,002,003,004,005,006,007,008,009,010," _
& "010,012,013,014,015,016,017,018,019,020," _
& "021,022,023,024,025,026,027,028,029,030," _
& "031,032,033,034,035,036,037,038,039,040," _
& "041,042,043,044,045,046,047,048,049,050,051,052," _
& "COUNSELOR,FRONT DESK,NURSE,PRINCIPAL,ASSISTANT PRINCIPAL,SECRETARY,TIME CLOCK,BAND,CHOIR,LIBRARY,GYM,ISS,GCS,CAFETERIA," _
& "LAB V01,LAB V02,LAB V03,LAB V04,LAB V05,LAB V06,LAB V07,LAB V08," _
& "LIBRARY MOBILE LAB,CATE MOBILE LAB,ENGLISH / SS MOBILE LAB,MATH / SCIENCE MOBILE LAB",",")

Dim butz_rooms : butz_rooms = Split ("ROOM,BILINGUAL DIRECTOR,BILINGUAL SECRETARY,PRINCIPAL,TIME CLOCK," _
& "CURRICULUM,DAEP,DAYCARE DIRECTOR,TEACHSCAPE,DAYCARE TEACHER,DISTRICT PEIMS COORDINATOR,MIGRANT RECRUITER" _
& ",MIGRANT RECRUITER AIDE,NURSE DIRECTOR,CAFETERIA",",")

Dim fs_rooms : fs_rooms = split ("ROOM,ADMINISTRATION",",")

Dim co_rooms : co_rooms = Split ("ROOM,ACCOUNTS PAYABLE COORDINATOR,ASSISTANT SUPERINTENDENT," _
& "ASSISTANT SUPERINTENDENT SECRETARY,BUSINESS MANAGER,GUEST COMPUTER,PAYROLL COORDINATOR,SUPERINTENDENT,SUPERINTENDENT SECRETARY",",")

Dim bb_rooms : bb_rooms = Split ("ROOM,BUS BARN,AUTO TECH",",")

Dim ss_rooms : ss_rooms = Split ("ROOM,031,032,033,034,035,036,037,038",",")

Dim tech_rooms : tech_rooms = Split ("ROOM,NETWORK ADMINISTRATOR,RECEPTIONIST,SYSTEMS ADMINISTRATOR," _
& "TECH DIRECTOR,WEB MASTER,INVENTORY COMPUTER,TECH 1,TECH 2,TRAINING LAB EAST,TRAINING LAB WEST",",")

Dim mai_rooms : mai_rooms = Split ("ROOM,MAINTENANCE",",")

'User Type
Dim com_level : com_level = Split ("USER TYPE,TEACHER,STUDENT,NCOMPUTING 1",",")

'Computer Type
Dim com_type : com_type = Split ("COMPUTER TYPE,DESKTOP,LAPTOP,NCOMPUTING 2",",")

'Computer Numbers
dim com_num : com_num = split ("COMPUTER NUMBER,01,02,03,04,05,06,07,08,09,10," _
& "11,12,13,14,15,16,17,18,19,20," _
& "21,22,23,24,25,26,27,28,29,30," _
& "31,32,33,34,35,36,37,38,39,40," _
& "41,42,43,44,45,46,47,48,49,50,51,52",",")

'Selection for campus names
sub sel_campus_onchange
  Dim CampusName
  clear_combo sel_room
  select case sel_campus.value
    Case 0 'Campus
    Case 1 'Alamo
      CampusName = "AL"
      load_combo sel_room, alamo_rooms
    Case 2 'Apache
      CampusName = "AP"
      load_combo sel_room, apache_rooms
    Case 3 'Intermediate
      CampusName = "IN"
      load_combo sel_room, intermediate_rooms
    Case 4 'Middle School
      CampusName = "MS"
      load_combo sel_room, ms_rooms
    Case 5 'High School
      CampusName="HS"
      load_combo sel_room, hs_rooms
    Case 6 'Butz
      CampusName="BU"
      load_combo sel_room, butz_rooms
    Case 7 'Food Services
      CampusName="IN"
      load_combo sel_room, fs_rooms
    Case 8 'Central Office
      CampusName="CO"
      load_combo sel_room, co_rooms
    Case 9 'Bus Barn
      CampusName="BB"
      load_combo sel_room, bb_rooms
    Case 10 'Special Services
      CampusName="SS"
      load_combo sel_room, ss_rooms
    Case 11 'Technology
      CampusName="TC"
      load_combo sel_room, tech_rooms
    Case 12 'Maintenance
      CampusName="HS"
      load_combo sel_room, mai_rooms
  End select

  'You may be able to remove each CampusName='xx' section with some logic here
  'but we seem to be missing some elements (for Food Services, Special Services, Technology?)

  ComputerName.value = CampusName
end Sub

'Selection for campus rooms
sub sel_room_onchange
  Dim RoomNumber, rn
  clear_combo sel_computer
  if sel_room.value = 0 Then exit sub
  rn = sel_room.value
  load_combo sel_computer, com_type
  select case sel_campus.value
    case 1 'Alamo rooms
      select case true
        case rn < 11
    	RoomNumber = "RMA" & right("0" & rn,2)
        case rn < 20
          RoomNumber = "RMB" & right("0" & rn-10,2)
        case rn < 31
          RoomNumber = "RMC" & right("0" & rn-19,2)
        case rn < 42 
          RoomNumber = "RMD" & right("0" & rn-30,2)
        case else
          if rn = 42 Then RoomNumber = "RMCOU"
          if rn = 43 Then RoomNumber = "RMFRD"
          if rn = 44 Then RoomNumber = "RMNUR"
          if rn = 45 Then RoomNumber = "RMPRI"
          if rn = 46 Then RoomNumber = "RMSEC"
          if rn = 47 Then RoomNumber = "RMTCL"
          if rn = 48 Then RoomNumber = "RMMSC"
          if rn = 49 Then RoomNumber = "RMLIB"
          if rn = 50 Then RoomNumber = "RMGYM"
          if rn = 51 Then RoomNumber = "RMCAF"
          If rn = 52 Then RoomNumber = "ML001"
      end select
    case 2  'Apache Rooms
      select case true
        case rn < 26
          RoomNumber = "RM" & Right("00" & rn,3)
        case rn < 36
          RoomNumber = "RM3" & rn
        case else
	  if rn = 36 Then RoomNumber = "RMCOU"
	  if rn = 37 Then RoomNumber = "RMFRD"
	  if rn = 38 Then RoomNumber = "RMNUR"
	  if rn = 39 Then RoomNumber = "RMPRI"
	  if rn = 40 Then RoomNumber = "RMSEC"
	  if rn = 41 Then RoomNumber = "RMTCL"
	  if rn = 42 Then RoomNumber = "RMMSC"
	  if rn = 43 Then RoomNumber = "RMLIB"
	  if rn = 44 Then RoomNumber = "RMGYM"
	  if rn = 45 Then RoomNumber = "RMCAF"
	  If rn = 46 Then RoomNumber = "ML001"
	  If rn = 47 Then RoomNumber = "ML002"
      end select
    case 3  'Intermediate Rooms
      select case true
        case rn = 1
          RoomNumber = "RMDAR"
        case rn < 29
          RoomNumber = "RM" & Right("RM00" & rn,3)
        case else
 	  if rn = 29 Then RoomNumber = "RMCOU"
 	  if rn = 30 Then RoomNumber = "RMFRD"
 	  if rn = 31 Then RoomNumber = "RMNUR"
 	  if rn = 32 Then RoomNumber = "RMPRI"
 	  if rn = 33 Then RoomNumber = "RMSEC"
 	  if rn = 34 Then RoomNumber = "RMTCL"
 	  if rn = 35 Then RoomNumber = "RMMSC"
 	  if rn = 36 Then RoomNumber = "RMLIB"
 	  if rn = 37 Then RoomNumber = "RMGYM"
 	  if rn = 38 Then RoomNumber = "RMISS"
 	  if rn = 39 Then RoomNumber = "RMCAF"
 	  If rn = 40 Then RoomNumber = "ML001"
        end select
    case 4  'Middle School Rooms
      select case true
        case rn < 52
          RoomNumber = "RM" & right("10" & rn,3)
        case else
  	  if rn = 52 Then RoomNumber = "RMCOU"
	  if rn = 53 Then RoomNumber = "RMFRD"
      If rn = 54 Then RoomNumber = "RMNUR"
      If rn = 55 Then RoomNumber = "RMPRI"
      If rn = 56 Then RoomNumber = "RMAPRI"
      If rn = 57 Then RoomNumber = "RMSEC"
      If rn = 58 Then RoomNumber = "RMTCL"
      If rn = 59 Then RoomNumber = "RMBND"
      If rn = 60 Then RoomNumber = "RMCHR"
      If rn = 61 Then RoomNumber = "RMLIB"
      If rn = 62 Then RoomNumber = "RMGYM"
      If rn = 63 Then RoomNumber = "RMISS"
      If rn = 64 Then RoomNumber = "RMCAF"
      If rn = 65 Then RoomNumber = "ML001"
      end select 
    case 5  'High School Rooms
      select case True
        Case rn < 53
          RoomNumber = "RM" & Right("00" & rn,3)
        case Else
          if rn = 53 Then RoomNumber = "RMCOU"
          if rn = 54 Then RoomNumber = "RMFRD"
          if rn = 55 Then RoomNumber = "RMNUR"
          if rn = 56 Then RoomNumber = "RMPRI"
          if rn = 57 Then RoomNumber = "RMAPRI"
          if rn = 58 Then RoomNumber = "RMSEC"
          if rn = 59 Then RoomNumber = "RMTCL"
          if rn = 60 Then RoomNumber = "RMBND"
          if rn = 61 Then RoomNumber = "RMCHR"
          if rn = 62 Then RoomNumber = "RMLIB"
          if rn = 63 Then RoomNumber = "RMGYM"
          if rn = 64 Then RoomNumber = "RMISS"
          if rn = 65 Then RoomNumber = "RMGCS"
          if rn = 66 Then RoomNumber = "RMCAF"
          If rn = 67 Then RoomNumber = "RMV01"
          If rn = 68 Then RoomNumber = "RMV02"
          If rn = 69 Then RoomNumber = "RMV03"
          If rn = 70 Then RoomNumber = "RMV04"
          If rn = 71 Then RoomNumber = "RMV05"
          If rn = 72 Then RoomNumber = "RMV06"
          If rn = 73 Then RoomNumber = "RMV07"
          If rn = 74 Then RoomNumber = "RMV08"          
          If rn = 75 Then RoomNumber = "MLLIB"
          If rn = 76 Then RoomNumber = "MLCAT"
          If rn = 77 Then RoomNumber = "MLENS"
          If rn = 78 Then RoomNumber = "MLMAS"
      end select 
    case 6  'Butz Rooms
      if rn= 1 then RoomNumber = "RMBLD"
      if rn = 2 then RoomNumber = "RMBLS"
      if rn = 3 then RoomNumber = "RMPRI"
      if rn = 4 then RoomNumber = "RMTCL"
      if rn = 5 then RoomNumber = "RMCUR"
      if rn = 6 then RoomNumber = "RMDAE"
      if rn = 7 then RoomNumber = "RMDCD"
      if rn = 8 then RoomNumber = "RMTSC"
      if rn = 9 then RoomNumber = "RMDCT"
      if rn = 10 then RoomNumber = "RMDPC"
      if rn = 11 then RoomNumber = "RMMIR"
      if rn = 12 then RoomNumber = "RMMRA"
      if rn = 13 then RoomNumber = "RMNUR"
      if rn = 14 then RoomNumber = "RMCAF"
    case 7  'Food Services Rooms
      if rn = 1 Then RoomNumber = "RMFDS"
    case 8  'Central Office Rooms
      if rn = 1 Then RoomNumber = "RMAPC"
      if rn = 2 Then RoomNumber = "RMASU"
      if rn = 3 Then RoomNumber = "RMASC"
      if rn = 4 Then RoomNumber = "RMBMA"
      if rn = 5 Then RoomNumber = "RMGUE"
      if rn = 6 Then RoomNumber = "RMPRC"
      if rn = 7 Then RoomNumber = "RMSUP"
      if rn = 8 Then RoomNumber = "RMASU"
    case 9  'Bus Barn Rooms
      if rn = 1 Then RoomNumber = "RMOFC"
      if rn = 2 Then RoomNumber = "RMATT"
    case 10  'Special Services Rooms
      RoomNumber = "RM" & Right("00" & rn+30,3)
    case 11  'Technology Rooms
      if rn = 1 Then RoomNumber = "NETAD"
      if rn = 2 Then RoomNumber = "FRTDK"
      if rn = 3 Then RoomNumber = "SYSAD"
      if rn = 4 Then RoomNumber = "TECHD"
      if rn = 5 Then RoomNumber = "WEBMR"
      if rn = 6 Then RoomNumber = "WASPC"
      if rn = 7 Then RoomNumber = "TECH1"
      if rn = 8 Then RoomNumber = "TECH2"
      if rn = 9 Then RoomNumber = "RMTLE"
      if rn = 10 Then RoomNumber = "RMTLW"
    case 12   'Maintenance
      if rn = 1 Then RoomNumber = "MAINT"
  end select
  ComputerName.value = Left(ComputerName.value,2) & RoomNumber
end Sub
'Selection for computer type
  dim DeviceType
Sub sel_computer_onchange
  clear_combo sel_level
  if sel_computer.value=0 then exit sub
  load_combo sel_level, com_level
    If sel_computer.value = 1 Then
    DeviceType = "D"
  ElseIf sel_computer.value = 2 Then
    DeviceType = "L"
  Else
  	DeviceType = "N"
  End If
  ComputerName.value = Left(ComputerName.value,7) & DeviceType
end Sub

'Selection for level number
sub sel_level_onchange
  dim PersonType
  clear_combo sel_number
  if sel_level.value=0 then exit sub
  load_combo sel_number, com_num
    If sel_level.value = 1 Then
    PersonType = "T"
  ElseIf sel_level.value = 2 Then
    PersonType = "S"
  Else
  	PersonType = "C"
  End If
  ComputerName.value = Left(Computername.value,8) & PersonType
end Sub

'Select for number
sub sel_number_onchange
  ComputerName.value = Left(ComputerName.value,9) & Right("0" & sel_number.value, 2)
  If Right(ComputerName.value,2) > 9 Then
  	ComputerName.value = Left(ComputerName.value,9) & Right(sel_number.value, 2)
  End If
'Select for computer number
'sub sel_number_onchange
'	Dim ComNum, cn
'	If sel_number.value = 0 Then Exit Sub
'	cn = sel_number.value
'	load_combo sel_number , com_num
'	Select case sel_number.value
'	Case 1 'Teacher Numbers
'      select case True
'        Case cn < 7
'          ComNum = Right("0" & cn,2)
'      end select 
'	Case 2 'Student Numbers
'      select case True
'        Case cn < 53
'          ComNum = right("0" & cn-50,2)
'      end select 
'  ComputerName.value = Left(ComputerName.value,9) & ComNum
'end Sub
  ''''''''''''''''''''
Dim objNetwork, strNewComputer, strDomain
Dim objTrans, strComputerDN

Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1

' Prompt for NetBIOS name of computer.
strNewComputer = ComputerName.value

' Retrieve NetBIOS name of the domain.
Set objNetwork = CreateObject("Wscript.Network")
strDomain = objNetwork.UserDomain

' Use NameTranslate to convert NT name into DN.
Set objTrans = CreateObject("NameTranslate")
' Initialize by locating GC.
objTrans.Init ADS_NAME_INITTYPE_GC, ""

' Use Set method to specify NT format of name.
' Be sure to append the "$" to the NetBIOS name of the computer.
' Trap error if object does not exist.
On Error Resume Next
objTrans.Set ADS_NAME_TYPE_NT4, strDomain & "\" & strNewComputer & "$"
If (Err.Number = 0) Then
  On Error GoTo 0
  ' Computer exists.
  ' Use Get method to retrieve DN.
  strComputerDN = objTrans.Get(ADS_NAME_TYPE_1779)
  DataArea.InnerHTML = "Computer name already exists in Active Directory!" & "<br>" & "Contact admins before renaming computer!"
  DataArea2.InnerHTML = ""
    document.GetElementByID("Rename").disabled = true
Else
  On Error GoTo 0
  DataArea2.InnerHTML = "WARNING! WILL REBOOT COMPUTER!"
  DataArea.InnerHTML = ""
    document.GetElementByID("Rename").disabled = false
End If
''''''''''''''''''''''
'  document.GetElementByID("Rename").disabled = false
end sub

Sub RenamePC
  Dim strComputer, strDomainUser, strDomainPasswd, strLocalUser, strLocalPasswd, NewComputerName, uName, uPassword
  Dim iResponse : iResponse = Msgbox("Rename " & oldComputerName.value & " to " & Computername.value & "?", _
        vbYesNo, "Proceed with rename?")
  If iResponse = vbNo Then
    Msgbox "No changes will be made."
    exit sub
  End If
strComputer=OldComputerName.value
'strNewComputer = ComputerName.value
strDomainUser = document.getElementById("uName").value & "@fsisd.local"
strDomainPasswd = document.getElementById("uPassword").value
strLocalUser = strComputer & "\administrator"
strLocalPasswd = "XXXXXXXX" 
' ------ END CONFIGURATION --------- 

'########################### 
' Connect to Computer 
'###########################
Dim objWMILocator, objWMIComputer, objWMIComputerSystem, rc, WScript, objWMIService, colOperatingSystems, objOperatingSystem
Set objWMILocator = CreateObject("WbemScripting.SWbemLocator") 
objWMILocator.Security_.AuthenticationLevel = 6 
Set objWMIComputer = objWMILocator.ConnectServer(strComputer, "root\cimv2", strLocalUser, strLocalPasswd) 
Set objWMIComputerSystem = objWMIComputer.Get( "Win32_ComputerSystem.Name='" & strComputer & "'") 
'########################### 
' Rename Computer 
'########################### 
rc = objWMIComputerSystem.Rename(strNewComputer, strDomainPasswd, strDomainUser) 
if rc <> 0 then 
Msgbox "Rename failed with error: " & rc 
else 
Msgbox "Successfully renamed " & strComputer & " to " & strNewComputer 
Msgbox "Rebooting..." 
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Shutdown)}!\\" & _
        strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    objOperatingSystem.Reboot()
Next

End if 

'  Next
end sub

sub disableButton()
  document.GetElementByID("Rename").disabled = true
end sub
</script>

<body bgcolor="white" onload="disableButton()">
<p>
<table>
	<tr>
		<td>
			<font color="white" size="5"><b>Old Computer Name:</b></font>
		</td>
		<td>
			<input type=text id="OldComputerName" name=OldComputerName size=45>
		</td>
	</tr>
	<tr>
		<td>
			<font color="white" size="5"><b>New Computer Name:</b></font>
		</td>
		<td>
			<input type=text id="ComputerName" name=ComputerName size=45>
		<td>
	</tr>
	<tr>
		<td>
			<font color="white" size="5"><b>User Name:</b></font>
		</td>
		<td>
			<input type=text name=uName size=45>
		</td>
	</tr>
	<tr>
		<td>
			<font color="white" size="5"><b>User Password:</b></font>
		</td>
		<td>
			<input type=password name=uPassword size=45>
		</td>
	</tr>
</table>
 <br>
 <span id = "DataArea" style="color: white; font-weight: bold; font-size: 36;"></span><br>
 <span id = "DataArea2" style="color: white; font-weight: bold; font-size: 36;"></span><br>
<!-- <font color="white" size="7"><b></b></font>--><BR>
<button onclick="RenamePC" id="Rename">Rename Computer</button>
</body>
</html>

Open in new window

sirbounty

Unfortunately I'm in and out a lot this week, so I'm not going to have much time to spend on this.
However, it appears that this is beginning to stray a bit from your opening question.  It's hard to zero in on a solution when the requirements keep getting modified.  
Perhaps you can close this question out and ask for help on extending your code's functionality.  Hopefully other experts will be able to assist with those changes.
Gabriel Clifton

ASKER
It is in the original question to limit the number of computer numbers, but I am sorry. I had that as an idea at first and was not really pushing it because I was more focused on the main functionality. It was not until my boss said to make the tech not be able to select a computer number higher than what is allowed that I started to steer my focus a bit. I am not in a huge rush on this since we are not performing the next big reimaging and inventory move until around mid next month. If I need to start a new thread I will. I want to be fair and only wish I could award more points that what is allowed.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
sirbounty

No, it's more about the amount of time I've put into this, and how little I can contribute for a while (being on-call is never fun).  I've expereienced similar questions where someone else would swoop in and put on the final touches and get the bulk of the points - not fun for me to waste my time for that sort of outcome...
I'd love to help finish this off, but wanted to be upfront and let you know I won't be able to examine your recent updates until my coverage ends.
Gabriel Clifton

ASKER
Understandable, will keep racking my brain on it.
RobSampson

PantherTech, let's give SirBounty the points here, and we'll post a new question where I can take over and restructure the room allocation.

From what I can see, the computer numbers are currently listed as 1 to 52 no matter what room or type is selected.

Honestly, I think that since you have different "Computer Number" requirements for every Campus, Room, Type, and Teacher, the selections will have to be completely rewritten, and you will need to spell out your allocations down the tree, in the form of a room map, which I'm thinking we might create in the code as recordsets.

What I mean is, you're going to need something like
[campusID],[campus]
C1,Alamo
C2,Apache

[campusID],[roomID],[room]
C1,R1,001
C1,R2,002
C2,R3,001
C2,R4,002

[roomID],[typeID],[type]
R1,T1,Desktop
R1,T2,Laptop
R2,T3,Desktop
R2,T4,Laptop
R3,T5,Desktop
R3,T6,Laptop
R4,T7,Desktop
R4,T8,Laptop

[typeID],[userID],[user]
T1,U1,Teacher
T1,U2,Student
T2,U3,Teacher
T2,U4,Teacher
T3,U5,Teacher
T3,U6,Teacher
T4,U7,Teacher
T4,U8,Teacher
T5,U9,Teacher
T5,U10,Teacher
T6,U11,Teacher
T6,U12,Teacher
T7,U13,Teacher
T7,U14,Teacher
T8,U15,Teacher
T8,U16,Teacher

[userID],[numberID],[number]
U1,N1,01
U1,N2,02
U2,N3,01
U2,N4,02
U3,N5,01
U3,N6,02
U4,N7,01
U4,N8,02
U5,N9,01
U5,N10,02
U6,N11,01
U6,N12,02
U7,N13,01
U7,N14,02
U8,N15,01
U8,N16,02
U9,N17,01
U9,N18,02
U10,N19,01
U10,N20,02
U11,N21,01
U11,N22,02
U12,N23,01
U12,N24,02
U13,N25,01
U13,N26,02
U14,N27,01
U14,N28,02
U15,N29,01
U15,N30,02
U16,N31,01
U16,N32,02


So this would be a very large list for you, but you can see how it would give you the very granular control that you need, over which rooms you present for the selected campus, which computer types you present for the selected room, which user types you present for the selected computer type, and finally which computer numbers you present for the selected user type (for that computer type, in that room, at that campus).

You could fill it out in Excel, then we can run a macro to generate the recordset code to paste into this code.

Let me know if you have any others ideas though.

Regards,

Rob.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Gabriel Clifton

ASKER
This has turned out fantastic. I thank you sirbounty so much for your time, effort, and ability to put up with me. I am going to open this script up in a new post to be reworked for the classroom computer number limitation because I was focused on sections at a time and did not realize this would need to be reworked.

As I usually do on posts like this, I am awarding points for most of the steps since it is a constant work in progress.
Gabriel Clifton

ASKER