Solved

Script for Netdom and Time Zone

Posted on 2012-04-11
26
1,963 Views
Last Modified: 2012-06-27
I have found this script that works pretty well in using netdom to rename a compuer... but I need it to do a little more.

'On Error Resume Next

'open the file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")
set WSHShell = wscript.createObject("wscript.shell")

Dim sNewCname     'Variable to hold Computer Name you enter in the inputbox
Dim sOldCname        'computers current name

'First param is message text, second is message title
sOldCname = InputBox("Enter computers current name","Windows 2k3 Netdom Rename Script")
sNewCname = InputBox("Enter computers new name","Windows 2k3 Netdom Rename Script")

Call WSHShell.Run("cmd.exe /K netdom renamecomputer " & sOldCname & " /newname:" & sNewCname & " /userd:DOMAIN\ADMINISTRATOR /passwordd:PASSWORD /usero:DOMAIN\ADMINISTRATOR /passwordo:PASSWORD /force ")

Open in new window


I would like this to be modified so that it RCMDs to the old machine first and executes Timedate.cpl to change the timezone based on the operators input of Eastern, Central, Mountain, Pacifc, Alaska, Hawaii into the text box. Then it carries out the netdom procedure as above.
0
Comment
Question by:jbyrd1981
  • 13
  • 12
26 Comments
 
LVL 17

Expert Comment

by:Anuroopsundd
Comment Utility
0
 
LVL 1

Author Comment

by:jbyrd1981
Comment Utility
I need someone to write a merged script, timezone change remotely with RCMD and netdom to rename the computer. It also needs to ask which timzone to change to and do it in the script. Then rename the computer. Unfortunately my scripting abilty is extremely limited but I am pretty sure this can be done. Thanks!
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Hi, this command would execute the timedate.cpl remotely:
c:\tools\psexec -accepteula -i \\remotePC rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,1

So, to put that into the script, just add
Call WSHShell.Run("cmd.exe /K c:\tools\psexec -accepteula -i -user:DOMAIN\ADMINISTRATOR -p:PASSWORD \\" & sOldName & " rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,1", 1, True)

Open in new window



Regards,

Rob.
0
 
LVL 1

Author Comment

by:jbyrd1981
Comment Utility
Seemed to want to work but this What I got.

PsExec v1.94 - Execute processes remotely
Copyright (C) 2001-2008 Mark Russinovich
Sysinternals - www.sysinternals.com

Password:
Couldn't access :
The network path was not found.

Make sure that the default admin$ share is enabled on .
0
 
LVL 1

Author Comment

by:jbyrd1981
Comment Utility
It only asked me for the password but not username. Is that implied based on the account using the command Window?
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Sorry, this this
Call WSHShell.Run("cmd.exe /K c:\tools\psexec -accepteula -i -u DOMAIN\ADMINISTRATOR -p PASSWORD \\" & sOldName & " rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,1", 1, True)

The domain account and password are specified in that line. If you want to be prompted for the password, just leave out -p PASSWORD

Also, try PSExec 1.96 or 1.98. They seem to work better.

Regards,

Rob.
0
 
LVL 1

Author Comment

by:jbyrd1981
Comment Utility
Using 1.98 neither code works... In fact the last one does not prompt me for the password anymore. I am not sure if PSexec will work on my network. Maybe something with the router config or network encryption.
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
The last one won't prompt for the password since we put it in the command with the -p switch.

Try running this directly at a command prompt, and let me know what the output says:
c:\tools\psexec -accepteula -i -u DOMAIN\ADMINISTRATOR -p PASSWORD \\REMOTEPCNAME rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,1

Open in new window


If you're on Windows 7, you may need to run an elevated command prompt by right-clicking cmd.exe and then click Run As Administrator.

Regards,

Rob.
0
 
LVL 1

Author Comment

by:jbyrd1981
Comment Utility
Here is what I got. I am actually running this from an XP machine to remotely change a Win 7 computer.

rundll32.exe exited on Machine with error code -1073741502.
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
OK, try this manually:
c:\tools\psexec -accepteula -i -u DOMAIN\ADMINISTRATOR -p PASSWORD \\REMOTEPCNAME cmd /c rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,1
0
 
LVL 1

Author Comment

by:jbyrd1981
Comment Utility
Same error. :(
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
From a command prompt on the windows 7 machine, what happens if you run
rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,1

Then, try right clicking CMD.exe on the Windows 7 machine and click Run As Adminstrator, and try the same command.  Do they work?

Rob.
0
 
LVL 1

Author Comment

by:jbyrd1981
Comment Utility
The date and time GUI pops up...
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:jbyrd1981
Comment Utility
I tried this command remotely to an XP machine.

c:\tools\psexec -accepteula -i -u DOMAIN\ADMINISTRATOR -p PASSWORD \\REMOTEPCNAME cmd /c rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,1

It worked... kind of. The GUI was there on the machine when I logged into it but I need to be able to change it remotely. I got the error code 0 when after I closed it on the remote computer.

PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com

cmd exited on Machine with error code 0.

I have been able to rcmd to a computer from the command prompt and then run timedate.cpl when connected. The command would look something like this....

control TIMEDATE.cpl,,/Z (GMT-08:00) Pacific Time

I just need to be able to script it.
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Oh OK.  I didn't realise you actually wanted to change it...I thought you wanted to give the user the option to change it.

From here:
http://www.mytechguide.org/7792/set-time-zone-using-command-prompt-windows-7/

"
To change the time zone, use the /s parameter. For example,
tzutil /s "universal standard time"

To display the current time zone, use the /g parameter. For example,
tzutil /g

To get a list of all available time zones, use the /l parameter. For example,
tzutil /l
"

So, in that case, try this for Windows 7:
c:\tools\psexec -accepteula -i -u DOMAIN\ADMINISTRATOR -p PASSWORD \\REMOTEPCNAME cmd /c tzutil /s "Pacific Standard Time"

but you may need to find out the exact time zone name based on the list from the tzutil /l command

Regards,

Rob.
0
 
LVL 1

Author Comment

by:jbyrd1981
Comment Utility
Ok, here are the two commands that finally worked. One for Win 7 machines and one for XP. I do not think the tzutil command exists for XP.

For win 7 I had to change cmd to cmd.exe otherwise I was recieveing the message Logon failure: unknown user name or bad password.

psexec -accepteula -i -h -u DOMAIN\NAME \\COMPUTER cmd.exe /c tzutil /s "Pacific Standard Time"

For XP I used this command...

psexec -accepteula -i -u DOMAIN\NAME \\COMPUTER cmd.exe /c control TIMEDATE.cpl,,/Z (GMT-05:00) Eastern Time

Now I need to combine this with my netdom script so it is all done with its execution. Here is what I have so far for that.

'On Error Resume Next

'open the file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")
set WSHShell = wscript.createObject("wscript.shell")

Dim sNewCname     'Variable to hold Computer Name you enter in the inputbox
Dim sOldCname        'computers current name
Dim User	'variable for Domain account

'First param is message text, second is message title
sOldCname = InputBox("Enter computers current name","NETDOM RENAME COMPUTER")
sNewCname = InputBox("Enter computers new name","NETDOM RENAME COMPUTER")
User = InputBox("Enter Admin Name","NETDOM RENAME COMPUTER")

Call WSHShell.Run("cmd.exe /K netdom renamecomputer " & sOldCname & " /newname:" & sNewCname & " /userd:DOMAIN\" & User & " /passwordd:* /usero:DOMAIN\" & User & " /passwordo:* /force ")

Open in new window


I envision this not only doing what is in this script above but taking the timezone and incorporating it. Since there are two different OSs (XP and Win 7) I guess there would need to a input box where you can specify so it knows which line to use. It also needs to have a way to select the time zone you want through a text box... This is getting complicated but that is my ultimate goal.
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
OK, this doesn't include the NetDom part, but see how it goes in testing against an XP and 7 machine to change the timezone.  I have commented out a lot of the time zones because you probably won't need them.  Feel free to change the commented ones around, but don't change the text in them.

Regards,

Rob.

sOldName = InputBox("Enter computers current name","NETDOM RENAME COMPUTER")
Set objWMIService = GetObject("winmgmts:\\" & sOldName & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select Caption from Win32_OperatingSystem",,48)
For Each objItem In colItems
	If InStr(objItem.Caption, "XP") > 0 Then
		strOS = "XP"
		strPrefix = "GMT"
	Else
		strOS = "7"
		strPrefix = "UTC"
	End If
Next
Set colItems = objWMIService.ExecQuery("Select Description from Win32_TimeZone",,48)
For Each objItem in colItems
    MsgBox "Operating system is Windows " & strOS & vbCrLf & "Current timezone is " & objItem.Description
Next

Set objTimeZones = CreateObject("Scripting.Dictionary")
'objTimeZones.Add "(" & strPrefix & "-12:00) International Date Line West", "Dateline Standard Time"
'objTimeZones.Add "(" & strPrefix & "-11:00) Coordinated Universal Time-11", "UTC-11"
objTimeZones.Add "(" & strPrefix & "-10:00) Hawaii", "Hawaiian Standard Time"
objTimeZones.Add "(" & strPrefix & "-09:00) Alaska", "Alaskan Standard Time"
'objTimeZones.Add "(" & strPrefix & "-08:00) Baja California", "Pacific Standard Time (Mexico)"
objTimeZones.Add "(" & strPrefix & "-08:00) Pacific Time (US & Canada)", "Pacific Standard Time"
objTimeZones.Add "(" & strPrefix & "-07:00) Arizona", "US Mountain Standard Time"
'objTimeZones.Add "(" & strPrefix & "-07:00) Chihuahua, La Paz, Mazatlan", "Mountain Standard Time (Mexico)"
objTimeZones.Add "(" & strPrefix & "-07:00) Mountain Time (US & Canada)", "Mountain Standard Time"
objTimeZones.Add "(" & strPrefix & "-06:00) Central America", "Central America Standard Time"
objTimeZones.Add "(" & strPrefix & "-06:00) Central Time (US & Canada)", "Central Standard Time"
'objTimeZones.Add "(" & strPrefix & "-06:00) Guadalajara, Mexico City, Monterrey", "Central Standard Time (Mexico)"
'objTimeZones.Add "(" & strPrefix & "-06:00) Saskatchewan", "Canada Central Standard Time"
'objTimeZones.Add "(" & strPrefix & "-05:00) Bogota, Lima, Quito", "SA Pacific Standard Time"
objTimeZones.Add "(" & strPrefix & "-05:00) Eastern Time (US & Canada)", "Eastern Standard Time"
'objTimeZones.Add "(" & strPrefix & "-05:00) Indiana (East)", "US Eastern Standard Time"
'objTimeZones.Add "(" & strPrefix & "-04:30) Caracas", "Venezuela Standard Time"
'objTimeZones.Add "(" & strPrefix & "-04:00) Asuncion", "Paraguay Standard Time"
objTimeZones.Add "(" & strPrefix & "-04:00) Atlantic Time (Canada)", "Atlantic Standard Time"
'objTimeZones.Add "(" & strPrefix & "-04:00) Cuiaba", "Central Brazilian Standard Time"
'objTimeZones.Add "(" & strPrefix & "-04:00) Georgetown, La Paz, Manaus, San Juan", "SA Western Standard Time"
objTimeZones.Add "(" & strPrefix & "-04:00) Santiago", "Pacific SA Standard Time"
'objTimeZones.Add "(" & strPrefix & "-03:30) Newfoundland", "Newfoundland Standard Time"
'objTimeZones.Add "(" & strPrefix & "-03:00) Brasilia", "E. South America Standard Time"
'objTimeZones.Add "(" & strPrefix & "-03:00) Buenos Aires", "Argentina Standard Time"
'objTimeZones.Add "(" & strPrefix & "-03:00) Cayenne, Fortaleza", "SA Eastern Standard Time"
'objTimeZones.Add "(" & strPrefix & "-03:00) Greenland", "Greenland Standard Time"
'objTimeZones.Add "(" & strPrefix & "-03:00) Montevideo", "Montevideo Standard Time"
'objTimeZones.Add "(" & strPrefix & "-03:00) Salvador", "Bahia Standard Time"
'objTimeZones.Add "(" & strPrefix & "-02:00) Coordinated Universal Time-02", "UTC-02"
'objTimeZones.Add "(" & strPrefix & "-02:00) Mid-Atlantic", "Mid-Atlantic Standard Time"
'objTimeZones.Add "(" & strPrefix & "-01:00) Azores", "Azores Standard Time"
'objTimeZones.Add "(" & strPrefix & "-01:00) Cape Verde Is.", "Cape Verde Standard Time"
'objTimeZones.Add "(" & strPrefix & ") Casablanca", "Morocco Standard Time"
'objTimeZones.Add "(" & strPrefix & ") Coordinated Universal Time", "UTC"
'objTimeZones.Add "(" & strPrefix & ") Dublin, Edinburgh, Lisbon, London", "GMT Standard Time"
'objTimeZones.Add "(" & strPrefix & ") Monrovia, Reykjavik", "Greenwich Standard Time"
'objTimeZones.Add "(" & strPrefix & "+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna", "W. Europe Standard Time"
'objTimeZones.Add "(" & strPrefix & "+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague", "Central Europe Standard Time"
'objTimeZones.Add "(" & strPrefix & "+01:00) Brussels, Copenhagen, Madrid, Paris", "Romance Standard Time"
'objTimeZones.Add "(" & strPrefix & "+01:00) Sarajevo, Skopje, Warsaw, Zagreb", "Central European Standard Time"
'objTimeZones.Add "(" & strPrefix & "+01:00) West Central Africa", "W. Central Africa Standard Time"
'objTimeZones.Add "(" & strPrefix & "+01:00) Windhoek", "Namibia Standard Time"
'objTimeZones.Add "(" & strPrefix & "+02:00) Amman", "Jordan Standard Time"
'objTimeZones.Add "(" & strPrefix & "+02:00) Athens, Bucharest", "GTB Standard Time"
'objTimeZones.Add "(" & strPrefix & "+02:00) Beirut", "Middle East Standard Time"
'objTimeZones.Add "(" & strPrefix & "+02:00) Cairo", "Egypt Standard Time"
'objTimeZones.Add "(" & strPrefix & "+02:00) Damascus", "Syria Standard Time"
'objTimeZones.Add "(" & strPrefix & "+02:00) Harare, Pretoria", "South Africa Standard Time"
'objTimeZones.Add "(" & strPrefix & "+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius", "FLE Standard Time"
'objTimeZones.Add "(" & strPrefix & "+02:00) Istanbul", "Turkey Standard Time"
'objTimeZones.Add "(" & strPrefix & "+02:00) Jerusalem", "Israel Standard Time"
'objTimeZones.Add "(" & strPrefix & "+02:00) Nicosia", "E. Europe Standard Time"
'objTimeZones.Add "(" & strPrefix & "+03:00) Baghdad", "Arabic Standard Time"
'objTimeZones.Add "(" & strPrefix & "+03:00) Kaliningrad, Minsk", "Kaliningrad Standard Time"
'objTimeZones.Add "(" & strPrefix & "+03:00) Kuwait, Riyadh", "Arab Standard Time"
'objTimeZones.Add "(" & strPrefix & "+03:00) Nairobi", "E. Africa Standard Time"
'objTimeZones.Add "(" & strPrefix & "+03:30) Tehran", "Iran Standard Time"
'objTimeZones.Add "(" & strPrefix & "+04:00) Abu Dhabi, Muscat", "Arabian Standard Time"
'objTimeZones.Add "(" & strPrefix & "+04:00) Baku", "Azerbaijan Standard Time"
'objTimeZones.Add "(" & strPrefix & "+04:00) Moscow, St. Petersburg, Volgograd", "Russian Standard Time"
'objTimeZones.Add "(" & strPrefix & "+04:00) Port Louis", "Mauritius Standard Time"
'objTimeZones.Add "(" & strPrefix & "+04:00) Tbilisi", "Georgian Standard Time"
'objTimeZones.Add "(" & strPrefix & "+04:00) Yerevan", "Caucasus Standard Time"
'objTimeZones.Add "(" & strPrefix & "+04:30) Kabul", "Afghanistan Standard Time"
'objTimeZones.Add "(" & strPrefix & "+05:00) Islamabad, Karachi", "Pakistan Standard Time"
'objTimeZones.Add "(" & strPrefix & "+05:00) Tashkent", "West Asia Standard Time"
'objTimeZones.Add "(" & strPrefix & "+05:30) Chennai, Kolkata, Mumbai, New Delhi", "India Standard Time"
'objTimeZones.Add "(" & strPrefix & "+05:30) Sri Jayawardenepura", "Sri Lanka Standard Time"
'objTimeZones.Add "(" & strPrefix & "+05:45) Kathmandu", "Nepal Standard Time"
'objTimeZones.Add "(" & strPrefix & "+06:00) Astana", "Central Asia Standard Time"
'objTimeZones.Add "(" & strPrefix & "+06:00) Dhaka", "Bangladesh Standard Time"
'objTimeZones.Add "(" & strPrefix & "+06:00) Ekaterinburg", "Ekaterinburg Standard Time"
'objTimeZones.Add "(" & strPrefix & "+06:30) Yangon (Rangoon)", "Myanmar Standard Time"
'objTimeZones.Add "(" & strPrefix & "+07:00) Bangkok, Hanoi, Jakarta", "SE Asia Standard Time"
'objTimeZones.Add "(" & strPrefix & "+07:00) Novosibirsk", "N. Central Asia Standard Time"
'objTimeZones.Add "(" & strPrefix & "+08:00) Beijing, Chongqing, Hong Kong, Urumqi", "China Standard Time"
'objTimeZones.Add "(" & strPrefix & "+08:00) Krasnoyarsk", "North Asia Standard Time"
'objTimeZones.Add "(" & strPrefix & "+08:00) Kuala Lumpur, Singapore", "Singapore Standard Time"
objTimeZones.Add "(" & strPrefix & "+08:00) Perth", "W. Australia Standard Time"
'objTimeZones.Add "(" & strPrefix & "+08:00) Taipei", "Taipei Standard Time"
'objTimeZones.Add "(" & strPrefix & "+08:00) Ulaanbaatar", "Ulaanbaatar Standard Time"
'objTimeZones.Add "(" & strPrefix & "+09:00) Irkutsk", "North Asia East Standard Time"
'objTimeZones.Add "(" & strPrefix & "+09:00) Osaka, Sapporo, Tokyo", "Tokyo Standard Time"
'objTimeZones.Add "(" & strPrefix & "+09:00) Seoul", "Korea Standard Time"
objTimeZones.Add "(" & strPrefix & "+09:30) Adelaide", "Cen. Australia Standard Time"
objTimeZones.Add "(" & strPrefix & "+09:30) Darwin", "AUS Central Standard Time"
objTimeZones.Add "(" & strPrefix & "+10:00) Brisbane", "E. Australia Standard Time"
objTimeZones.Add "(" & strPrefix & "+10:00) Canberra, Melbourne, Sydney", "AUS Eastern Standard Time"
'objTimeZones.Add "(" & strPrefix & "+10:00) Guam, Port Moresby", "West Pacific Standard Time"
'objTimeZones.Add "(" & strPrefix & "+10:00) Hobart", "Tasmania Standard Time"
'objTimeZones.Add "(" & strPrefix & "+10:00) Yakutsk", "Yakutsk Standard Time"
'objTimeZones.Add "(" & strPrefix & "+11:00) Solomon Is., New Caledonia", "Central Pacific Standard Time"
'objTimeZones.Add "(" & strPrefix & "+11:00) Vladivostok", "Vladivostok Standard Time"
objTimeZones.Add "(" & strPrefix & "+12:00) Auckland, Wellington", "New Zealand Standard Time"
'objTimeZones.Add "(" & strPrefix & "+12:00) Coordinated Universal Time+12", "UTC+12"
'objTimeZones.Add "(" & strPrefix & "+12:00) Fiji", "Fiji Standard Time"
'objTimeZones.Add "(" & strPrefix & "+12:00) Magadan", "Magadan Standard Time"
'objTimeZones.Add "(" & strPrefix & "+13:00) Nuku'alofa", "Tonga Standard Time"
'objTimeZones.Add "(" & strPrefix & "+13:00) Samoa", "Samoa Standard Time"

blnValid = False
While blnValid = False
	strNewTZ = InputBox("Enter new time zone EXACTLY as shown: " & vbCrLf & Join(objTimeZones.Keys, vbCrLf), "Select Time Zone")
	If objTimeZones.Exists(strNewTZ) = True Then blnValid = True
Wend

MsgBox "Setting time zone to " & strNewTZ & ": " & objTimeZones(strNewTZ)

If strOS = "7" Then
	strCommand = "C:\Tools\psexec -accepteula -i -h -u DOMAIN\NAME \\" & sOldName & " cmd.exe /c tzutil /s """ & objTimeZones(strNewTZ) & """"
Else
	strCommand = "C:\Tools\psexec -accepteula -i -u DOMAIN\NAME \\" & sOldName & " cmd.exe /c control TIMEDATE.cpl,,/Z """ & strNewTZ & """"
End If

Set objShell = CreateObject("WScript.Shell")
objShell.Run strCommand, 1, True

MsgBox "Command has been run. Please check time zone."

Open in new window

0
 
LVL 1

Author Comment

by:jbyrd1981
Comment Utility
Rob,

Wow! This is great! This is significant significant progress. It worked great on the Win 7 machine. However, not so much on the XP machine. I think I know why though.... I think that timedate.cpl does not recognize input like (-08:00) Pacific Time (US & Canada)… Other than that I was wondering if there is any way to make the selection of the time zone easier so you did not have to type so much? Thanks again! I would not have been able to do this even in my dreams!
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Hi, I think I made a mistake with enclosing the time zone in quotes on this line (line 131 in the snippet above):
	strCommand = "C:\Tools\psexec -accepteula -i -u DOMAIN\NAME \\" & sOldName & " cmd.exe /c control TIMEDATE.cpl,,/Z """ & strNewTZ & """"

Open in new window


It should be this I believe
	strCommand = "C:\Tools\psexec -accepteula -i -u DOMAIN\NAME \\" & sOldName & " cmd.exe /c control TIMEDATE.cpl,,/Z " & objTimeZones(strNewTZ)

Open in new window


If you could test that and see if it works, I think the best way forward to make the selection easier is to build a HTA in which you can use a drop down box to select the timezone instead of typing anything.

Regards,

Rob.
0
 
LVL 1

Author Comment

by:jbyrd1981
Comment Utility
That worked but I have no idea how to build an HTA!
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
No problem. I'll knock one up for you tomorrow.

Rob.
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Hi, I finally got around to knocking up a HTA for you.  Save the code here into Notepad, then save it as something like "SetTZ.hta" and double click that file to run it.

Regards,

Rob.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>My HTML Application</title>
<script language="vbscript">
Dim strOS
Sub Window_OnLoad
	span_timezones.InnerHTML = "<select id='lst_timezones' name='lst_timezones' size='1'></select>"
	btn_settz.disabled = True
End Sub

Sub QueryComputer
	btn_settz.disabled = True
	span_timezones.InnerHTML = "<select id='lst_timezones' name='lst_timezones' size='1'></select>"
	sOldName = txt_oldname.Value
	If Ping(sOldName) = True Then
		Set objWMIService = GetObject("winmgmts:\\" & sOldName & "\root\cimv2")
		Set colItems = objWMIService.ExecQuery("Select Caption from Win32_OperatingSystem",,48)
		For Each objItem In colItems
			If InStr(objItem.Caption, "XP") > 0 Then
				strOS = "XP"
				strPrefix = "GMT"
			Else
				strOS = "7"
				strPrefix = "UTC"
			End If
		Next
		Set colItems = objWMIService.ExecQuery("Select Description from Win32_TimeZone",,48)
		For Each objItem in colItems
		    MsgBox "Operating system is Windows " & strOS & vbCrLf & "Current timezone is " & objItem.Description
		Next
	
		strHTML = "<select id='lst_timezones' name='lst_timezones' size='1'>"
		'Set objTimeZones = CreateObject("Scripting.Dictionary")
		strHTML = strHTML & vbCrLf & "<option value='Dateline Standard Time'>(" & strPrefix & "-12:00) International Date Line West</option>"
		strHTML = strHTML & vbCrLf & "<option value='UTC-11'>(" & strPrefix & "-11:00) Coordinated Universal Time-11</option>"
		strHTML = strHTML & vbCrLf & "<option value='Hawaiian Standard Time'>(" & strPrefix & "-10:00) Hawaii</option>"
		strHTML = strHTML & vbCrLf & "<option value='Alaskan Standard Time'>(" & strPrefix & "-09:00) Alaska</option>"
		strHTML = strHTML & vbCrLf & "<option value='Pacific Standard Time (Mexico)'>(" & strPrefix & "-08:00) Baja California</option>"
		strHTML = strHTML & vbCrLf & "<option value='Pacific Standard Time'>(" & strPrefix & "-08:00) Pacific Time (US & Canada)</option>"
		strHTML = strHTML & vbCrLf & "<option value='US Mountain Standard Time'>(" & strPrefix & "-07:00) Arizona</option>"
		strHTML = strHTML & vbCrLf & "<option value='Mountain Standard Time (Mexico)'>(" & strPrefix & "-07:00) Chihuahua, La Paz, Mazatlan</option>"
		strHTML = strHTML & vbCrLf & "<option value='Mountain Standard Time'>(" & strPrefix & "-07:00) Mountain Time (US & Canada)</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central America Standard Time'>(" & strPrefix & "-06:00) Central America</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Standard Time'>(" & strPrefix & "-06:00) Central Time (US & Canada)</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Standard Time (Mexico)'>(" & strPrefix & "-06:00) Guadalajara, Mexico City, Monterrey</option>"
		strHTML = strHTML & vbCrLf & "<option value='Canada Central Standard Time'>(" & strPrefix & "-06:00) Saskatchewan</option>"
		strHTML = strHTML & vbCrLf & "<option value='SA Pacific Standard Time'>(" & strPrefix & "-05:00) Bogota, Lima, Quito</option>"
		strHTML = strHTML & vbCrLf & "<option value='Eastern Standard Time'>(" & strPrefix & "-05:00) Eastern Time (US & Canada)</option>"
		strHTML = strHTML & vbCrLf & "<option value='US Eastern Standard Time'>(" & strPrefix & "-05:00) Indiana (East)</option>"
		strHTML = strHTML & vbCrLf & "<option value='Venezuela Standard Time'>(" & strPrefix & "-04:30) Caracas</option>"
		strHTML = strHTML & vbCrLf & "<option value='Paraguay Standard Time'>(" & strPrefix & "-04:00) Asuncion</option>"
		strHTML = strHTML & vbCrLf & "<option value='Atlantic Standard Time'>(" & strPrefix & "-04:00) Atlantic Time (Canada)</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Brazilian Standard Time'>(" & strPrefix & "-04:00) Cuiaba</option>"
		strHTML = strHTML & vbCrLf & "<option value='SA Western Standard Time'>(" & strPrefix & "-04:00) Georgetown, La Paz, Manaus, San Juan</option>"
		strHTML = strHTML & vbCrLf & "<option value='Pacific SA Standard Time'>(" & strPrefix & "-04:00) Santiago</option>"
		strHTML = strHTML & vbCrLf & "<option value='Newfoundland Standard Time'>(" & strPrefix & "-03:30) Newfoundland</option>"
		strHTML = strHTML & vbCrLf & "<option value='E. South America Standard Time'>(" & strPrefix & "-03:00) Brasilia</option>"
		strHTML = strHTML & vbCrLf & "<option value='Argentina Standard Time'>(" & strPrefix & "-03:00) Buenos Aires</option>"
		strHTML = strHTML & vbCrLf & "<option value='SA Eastern Standard Time'>(" & strPrefix & "-03:00) Cayenne, Fortaleza</option>"
		strHTML = strHTML & vbCrLf & "<option value='Greenland Standard Time'>(" & strPrefix & "-03:00) Greenland</option>"
		strHTML = strHTML & vbCrLf & "<option value='Montevideo Standard Time'>(" & strPrefix & "-03:00) Montevideo</option>"
		strHTML = strHTML & vbCrLf & "<option value='Bahia Standard Time'>(" & strPrefix & "-03:00) Salvador</option>"
		strHTML = strHTML & vbCrLf & "<option value='UTC-02'>(" & strPrefix & "-02:00) Coordinated Universal Time-02</option>"
		strHTML = strHTML & vbCrLf & "<option value='Mid-Atlantic Standard Time'>(" & strPrefix & "-02:00) Mid-Atlantic</option>"
		strHTML = strHTML & vbCrLf & "<option value='Azores Standard Time'>(" & strPrefix & "-01:00) Azores</option>"
		strHTML = strHTML & vbCrLf & "<option value='Cape Verde Standard Time'>(" & strPrefix & "-01:00) Cape Verde Is.</option>"
		strHTML = strHTML & vbCrLf & "<option value='Morocco Standard Time'>(" & strPrefix & ") Casablanca</option>"
		strHTML = strHTML & vbCrLf & "<option value='UTC'>(" & strPrefix & ") Coordinated Universal Time</option>"
		strHTML = strHTML & vbCrLf & "<option value='GMT Standard Time'>(" & strPrefix & ") Dublin, Edinburgh, Lisbon, London</option>"
		strHTML = strHTML & vbCrLf & "<option value='Greenwich Standard Time'>(" & strPrefix & ") Monrovia, Reykjavik</option>"
		strHTML = strHTML & vbCrLf & "<option value='W. Europe Standard Time'>(" & strPrefix & "+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Europe Standard Time'>(" & strPrefix & "+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague</option>"
		strHTML = strHTML & vbCrLf & "<option value='Romance Standard Time'>(" & strPrefix & "+01:00) Brussels, Copenhagen, Madrid, Paris</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central European Standard Time'>(" & strPrefix & "+01:00) Sarajevo, Skopje, Warsaw, Zagreb</option>"
		strHTML = strHTML & vbCrLf & "<option value='W. Central Africa Standard Time'>(" & strPrefix & "+01:00) West Central Africa</option>"
		strHTML = strHTML & vbCrLf & "<option value='Namibia Standard Time'>(" & strPrefix & "+01:00) Windhoek</option>"
		strHTML = strHTML & vbCrLf & "<option value='Jordan Standard Time'>(" & strPrefix & "+02:00) Amman</option>"
		strHTML = strHTML & vbCrLf & "<option value='GTB Standard Time'>(" & strPrefix & "+02:00) Athens, Bucharest</option>"
		strHTML = strHTML & vbCrLf & "<option value='Middle East Standard Time'>(" & strPrefix & "+02:00) Beirut</option>"
		strHTML = strHTML & vbCrLf & "<option value='Egypt Standard Time'>(" & strPrefix & "+02:00) Cairo</option>"
		strHTML = strHTML & vbCrLf & "<option value='Syria Standard Time'>(" & strPrefix & "+02:00) Damascus</option>"
		strHTML = strHTML & vbCrLf & "<option value='South Africa Standard Time'>(" & strPrefix & "+02:00) Harare, Pretoria</option>"
		strHTML = strHTML & vbCrLf & "<option value='FLE Standard Time'>(" & strPrefix & "+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius</option>"
		strHTML = strHTML & vbCrLf & "<option value='Turkey Standard Time'>(" & strPrefix & "+02:00) Istanbul</option>"
		strHTML = strHTML & vbCrLf & "<option value='Israel Standard Time'>(" & strPrefix & "+02:00) Jerusalem</option>"
		strHTML = strHTML & vbCrLf & "<option value='E. Europe Standard Time'>(" & strPrefix & "+02:00) Nicosia</option>"
		strHTML = strHTML & vbCrLf & "<option value='Arabic Standard Time'>(" & strPrefix & "+03:00) Baghdad</option>"
		strHTML = strHTML & vbCrLf & "<option value='Kaliningrad Standard Time'>(" & strPrefix & "+03:00) Kaliningrad, Minsk</option>"
		strHTML = strHTML & vbCrLf & "<option value='Arab Standard Time'>(" & strPrefix & "+03:00) Kuwait, Riyadh</option>"
		strHTML = strHTML & vbCrLf & "<option value='E. Africa Standard Time'>(" & strPrefix & "+03:00) Nairobi</option>"
		strHTML = strHTML & vbCrLf & "<option value='Iran Standard Time'>(" & strPrefix & "+03:30) Tehran</option>"
		strHTML = strHTML & vbCrLf & "<option value='Arabian Standard Time'>(" & strPrefix & "+04:00) Abu Dhabi, Muscat</option>"
		strHTML = strHTML & vbCrLf & "<option value='Azerbaijan Standard Time'>(" & strPrefix & "+04:00) Baku</option>"
		strHTML = strHTML & vbCrLf & "<option value='Russian Standard Time'>(" & strPrefix & "+04:00) Moscow, St. Petersburg, Volgograd</option>"
		strHTML = strHTML & vbCrLf & "<option value='Mauritius Standard Time'>(" & strPrefix & "+04:00) Port Louis</option>"
		strHTML = strHTML & vbCrLf & "<option value='Georgian Standard Time'>(" & strPrefix & "+04:00) Tbilisi</option>"
		strHTML = strHTML & vbCrLf & "<option value='Caucasus Standard Time'>(" & strPrefix & "+04:00) Yerevan</option>"
		strHTML = strHTML & vbCrLf & "<option value='Afghanistan Standard Time'>(" & strPrefix & "+04:30) Kabul</option>"
		strHTML = strHTML & vbCrLf & "<option value='Pakistan Standard Time'>(" & strPrefix & "+05:00) Islamabad, Karachi</option>"
		strHTML = strHTML & vbCrLf & "<option value='West Asia Standard Time'>(" & strPrefix & "+05:00) Tashkent</option>"
		strHTML = strHTML & vbCrLf & "<option value='India Standard Time'>(" & strPrefix & "+05:30) Chennai, Kolkata, Mumbai, New Delhi</option>"
		strHTML = strHTML & vbCrLf & "<option value='Sri Lanka Standard Time'>(" & strPrefix & "+05:30) Sri Jayawardenepura</option>"
		strHTML = strHTML & vbCrLf & "<option value='Nepal Standard Time'>(" & strPrefix & "+05:45) Kathmandu</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Asia Standard Time'>(" & strPrefix & "+06:00) Astana</option>"
		strHTML = strHTML & vbCrLf & "<option value='Bangladesh Standard Time'>(" & strPrefix & "+06:00) Dhaka</option>"
		strHTML = strHTML & vbCrLf & "<option value='Ekaterinburg Standard Time'>(" & strPrefix & "+06:00) Ekaterinburg</option>"
		strHTML = strHTML & vbCrLf & "<option value='Myanmar Standard Time'>(" & strPrefix & "+06:30) Yangon (Rangoon)</option>"
		strHTML = strHTML & vbCrLf & "<option value='SE Asia Standard Time'>(" & strPrefix & "+07:00) Bangkok, Hanoi, Jakarta</option>"
		strHTML = strHTML & vbCrLf & "<option value='N. Central Asia Standard Time'>(" & strPrefix & "+07:00) Novosibirsk</option>"
		strHTML = strHTML & vbCrLf & "<option value='China Standard Time'>(" & strPrefix & "+08:00) Beijing, Chongqing, Hong Kong, Urumqi</option>"
		strHTML = strHTML & vbCrLf & "<option value='North Asia Standard Time'>(" & strPrefix & "+08:00) Krasnoyarsk</option>"
		strHTML = strHTML & vbCrLf & "<option value='Singapore Standard Time'>(" & strPrefix & "+08:00) Kuala Lumpur, Singapore</option>"
		strHTML = strHTML & vbCrLf & "<option value='W. Australia Standard Time'>(" & strPrefix & "+08:00) Perth</option>"
		strHTML = strHTML & vbCrLf & "<option value='Taipei Standard Time'>(" & strPrefix & "+08:00) Taipei</option>"
		strHTML = strHTML & vbCrLf & "<option value='Ulaanbaatar Standard Time'>(" & strPrefix & "+08:00) Ulaanbaatar</option>"
		strHTML = strHTML & vbCrLf & "<option value='North Asia East Standard Time'>(" & strPrefix & "+09:00) Irkutsk</option>"
		strHTML = strHTML & vbCrLf & "<option value='Tokyo Standard Time'>(" & strPrefix & "+09:00) Osaka, Sapporo, Tokyo</option>"
		strHTML = strHTML & vbCrLf & "<option value='Korea Standard Time'>(" & strPrefix & "+09:00) Seoul</option>"
		strHTML = strHTML & vbCrLf & "<option value='Cen. Australia Standard Time'>(" & strPrefix & "+09:30) Adelaide</option>"
		strHTML = strHTML & vbCrLf & "<option value='AUS Central Standard Time'>(" & strPrefix & "+09:30) Darwin</option>"
		strHTML = strHTML & vbCrLf & "<option value='E. Australia Standard Time'>(" & strPrefix & "+10:00) Brisbane</option>"
		strHTML = strHTML & vbCrLf & "<option value='AUS Eastern Standard Time'>(" & strPrefix & "+10:00) Canberra, Melbourne, Sydney</option>"
		strHTML = strHTML & vbCrLf & "<option value='West Pacific Standard Time'>(" & strPrefix & "+10:00) Guam, Port Moresby</option>"
		strHTML = strHTML & vbCrLf & "<option value='Tasmania Standard Time'>(" & strPrefix & "+10:00) Hobart</option>"
		strHTML = strHTML & vbCrLf & "<option value='Yakutsk Standard Time'>(" & strPrefix & "+10:00) Yakutsk</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Pacific Standard Time'>(" & strPrefix & "+11:00) Solomon Is., New Caledonia</option>"
		strHTML = strHTML & vbCrLf & "<option value='Vladivostok Standard Time'>(" & strPrefix & "+11:00) Vladivostok</option>"
		strHTML = strHTML & vbCrLf & "<option value='New Zealand Standard Time'>(" & strPrefix & "+12:00) Auckland, Wellington</option>"
		strHTML = strHTML & vbCrLf & "<option value='UTC+12'>(" & strPrefix & "+12:00) Coordinated Universal Time+12</option>"
		strHTML = strHTML & vbCrLf & "<option value='Fiji Standard Time'>(" & strPrefix & "+12:00) Fiji</option>"
		strHTML = strHTML & vbCrLf & "<option value='Magadan Standard Time'>(" & strPrefix & "+12:00) Magadan</option>"
		strHTML = strHTML & vbCrLf & "<option value='Tonga Standard Time'>(" & strPrefix & "+13:00) Nuku</option>"
		strHTML = strHTML & vbCrLf & "<option value='Samoa Standard Time'>(" & strPrefix & "+13:00) Samoa</option>"
		strHTML = strHTML & vbCrLf & "</select>"
		span_timezones.InnerHTML = strHTML
		btn_settz.disabled = False
	Else
		MsgBox "Unable to ping " & sOldName
	End If
End Sub

Sub SetTZ
	strNewTZ = lst_timezones.Value
	MsgBox "Setting time zone to " & strNewTZ

	If strOS = "7" Then
		strCommand = "C:\Tools\psexec -accepteula -i -h -u DOMAIN\NAME \\" & txt_oldname.Value & " cmd.exe /c tzutil /s """ & strNewTZ & """"
	Else
		strCommand = "C:\Tools\psexec -accepteula -i -u DOMAIN\NAME \\" & txt_oldname.Value & " cmd.exe /c control TIMEDATE.cpl,,/Z " & strNewTZ
	End If
	
	Set objShell = CreateObject("WScript.Shell")
	objShell.Run strCommand, 1, True
	
	MsgBox "Command has been run. Please check time zone."

End Sub

Function Ping(strComputer)
	Dim objShell, boolCode
	Set objShell = CreateObject("WScript.Shell")
	boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
	If boolCode = 0 Then
		Ping = True
	Else
		Ping = False
	End If
End Function
</script>
<hta:application
	applicationname="MyHTA"	
	border="dialog"
	borderstyle="normal"
	caption="My HTML Application"
	contextmenu="no"
	icon="myicon.ico"
	maximizebutton="no"
	minimizebutton="yes"
	navigable="no"
	scroll="no"
	selection="no"
	showintaskbar="yes"
	singleinstance="yes"
	sysmenu="yes"
	version="1.0"
	windowstate="normal"
>
</head>
<body>
	<table>
		<tr>
			<td>
				Enter old computer name:
			</td>
			<td>
				<input id="txt_oldname" name="txt_oldname" type="text" size="30" maxlength="20">
			</td>
		</tr>
		<tr>
			<td>
				Select time zone:
			</td>
			<td>
				<span id="span_timezones"></span>
			</td>
		</tr>
		<tr>
			<td colspan="2" align="centre">
				<input type="button" value="Query Computer" id="btn_query" name="btn_query" onclick="QueryComputer">
			</td>
		</tr>
		<tr>
			<td colspan="2" align="centre">
				<input type="button" value="Set TZ" id="btn_settz" name="btn_settz" onclick="SetTZ">
			</td>
		</tr>
	</table>
</body>
</html>

Open in new window

0
 
LVL 1

Author Comment

by:jbyrd1981
Comment Utility
Rob, this worked great!!! I did add another box with a variable to your code that allows the input of the admin's login. The modified Time Change code is below. Now I need this to have another input box for the new computer name variable so that it can call the netdom command after the time change is successful. Then this will be exactly what I was looking for.  The code for the working netdom script is in my original post above. Hopefully this is possible. Thanks again for all your help with this.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Time Zone Changer</title>
<script language="vbscript">
Dim strOS
Sub Window_OnLoad
	span_timezones.InnerHTML = "<select id='lst_timezones' name='lst_timezones' size='1'></select>"
	btn_settz.disabled = True
End Sub

Sub QueryComputer
	btn_settz.disabled = True
	span_timezones.InnerHTML = "<select id='lst_timezones' name='lst_timezones' size='1'></select>"
	sOldName = txt_oldname.Value
	If Ping(sOldName) = True Then
		Set objWMIService = GetObject("winmgmts:\\" & sOldName & "\root\cimv2")
		Set colItems = objWMIService.ExecQuery("Select Caption from Win32_OperatingSystem",,48)
		For Each objItem In colItems
			If InStr(objItem.Caption, "XP") > 0 Then
				strOS = "XP"
				strPrefix = "GMT"
			Else
				strOS = "7"
				strPrefix = "UTC"
			End If
		Next
		Set colItems = objWMIService.ExecQuery("Select Description from Win32_TimeZone",,48)
		For Each objItem in colItems
		    MsgBox "Operating system is Windows " & strOS & vbCrLf & "Current timezone is " & objItem.Description
		Next
	
		strHTML = "<select id='lst_timezones' name='lst_timezones' size='1'>"
		'Set objTimeZones = CreateObject("Scripting.Dictionary")
		strHTML = strHTML & vbCrLf & "<option value='Dateline Standard Time'>(" & strPrefix & "-12:00) International Date Line West</option>"
		strHTML = strHTML & vbCrLf & "<option value='UTC-11'>(" & strPrefix & "-11:00) Coordinated Universal Time-11</option>"
		strHTML = strHTML & vbCrLf & "<option value='Hawaiian Standard Time'>(" & strPrefix & "-10:00) Hawaii</option>"
		strHTML = strHTML & vbCrLf & "<option value='Alaskan Standard Time'>(" & strPrefix & "-09:00) Alaska</option>"
		strHTML = strHTML & vbCrLf & "<option value='Pacific Standard Time (Mexico)'>(" & strPrefix & "-08:00) Baja California</option>"
		strHTML = strHTML & vbCrLf & "<option value='Pacific Standard Time'>(" & strPrefix & "-08:00) Pacific Time (US & Canada)</option>"
		strHTML = strHTML & vbCrLf & "<option value='US Mountain Standard Time'>(" & strPrefix & "-07:00) Arizona</option>"
		strHTML = strHTML & vbCrLf & "<option value='Mountain Standard Time (Mexico)'>(" & strPrefix & "-07:00) Chihuahua, La Paz, Mazatlan</option>"
		strHTML = strHTML & vbCrLf & "<option value='Mountain Standard Time'>(" & strPrefix & "-07:00) Mountain Time (US & Canada)</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central America Standard Time'>(" & strPrefix & "-06:00) Central America</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Standard Time'>(" & strPrefix & "-06:00) Central Time (US & Canada)</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Standard Time (Mexico)'>(" & strPrefix & "-06:00) Guadalajara, Mexico City, Monterrey</option>"
		strHTML = strHTML & vbCrLf & "<option value='Canada Central Standard Time'>(" & strPrefix & "-06:00) Saskatchewan</option>"
		strHTML = strHTML & vbCrLf & "<option value='SA Pacific Standard Time'>(" & strPrefix & "-05:00) Bogota, Lima, Quito</option>"
		strHTML = strHTML & vbCrLf & "<option value='Eastern Standard Time'>(" & strPrefix & "-05:00) Eastern Time (US & Canada)</option>"
		strHTML = strHTML & vbCrLf & "<option value='US Eastern Standard Time'>(" & strPrefix & "-05:00) Indiana (East)</option>"
		strHTML = strHTML & vbCrLf & "<option value='Venezuela Standard Time'>(" & strPrefix & "-04:30) Caracas</option>"
		strHTML = strHTML & vbCrLf & "<option value='Paraguay Standard Time'>(" & strPrefix & "-04:00) Asuncion</option>"
		strHTML = strHTML & vbCrLf & "<option value='Atlantic Standard Time'>(" & strPrefix & "-04:00) Atlantic Time (Canada)</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Brazilian Standard Time'>(" & strPrefix & "-04:00) Cuiaba</option>"
		strHTML = strHTML & vbCrLf & "<option value='SA Western Standard Time'>(" & strPrefix & "-04:00) Georgetown, La Paz, Manaus, San Juan</option>"
		strHTML = strHTML & vbCrLf & "<option value='Pacific SA Standard Time'>(" & strPrefix & "-04:00) Santiago</option>"
		strHTML = strHTML & vbCrLf & "<option value='Newfoundland Standard Time'>(" & strPrefix & "-03:30) Newfoundland</option>"
		strHTML = strHTML & vbCrLf & "<option value='E. South America Standard Time'>(" & strPrefix & "-03:00) Brasilia</option>"
		strHTML = strHTML & vbCrLf & "<option value='Argentina Standard Time'>(" & strPrefix & "-03:00) Buenos Aires</option>"
		strHTML = strHTML & vbCrLf & "<option value='SA Eastern Standard Time'>(" & strPrefix & "-03:00) Cayenne, Fortaleza</option>"
		strHTML = strHTML & vbCrLf & "<option value='Greenland Standard Time'>(" & strPrefix & "-03:00) Greenland</option>"
		strHTML = strHTML & vbCrLf & "<option value='Montevideo Standard Time'>(" & strPrefix & "-03:00) Montevideo</option>"
		strHTML = strHTML & vbCrLf & "<option value='Bahia Standard Time'>(" & strPrefix & "-03:00) Salvador</option>"
		strHTML = strHTML & vbCrLf & "<option value='UTC-02'>(" & strPrefix & "-02:00) Coordinated Universal Time-02</option>"
		strHTML = strHTML & vbCrLf & "<option value='Mid-Atlantic Standard Time'>(" & strPrefix & "-02:00) Mid-Atlantic</option>"
		strHTML = strHTML & vbCrLf & "<option value='Azores Standard Time'>(" & strPrefix & "-01:00) Azores</option>"
		strHTML = strHTML & vbCrLf & "<option value='Cape Verde Standard Time'>(" & strPrefix & "-01:00) Cape Verde Is.</option>"
		strHTML = strHTML & vbCrLf & "<option value='Morocco Standard Time'>(" & strPrefix & ") Casablanca</option>"
		strHTML = strHTML & vbCrLf & "<option value='UTC'>(" & strPrefix & ") Coordinated Universal Time</option>"
		strHTML = strHTML & vbCrLf & "<option value='GMT Standard Time'>(" & strPrefix & ") Dublin, Edinburgh, Lisbon, London</option>"
		strHTML = strHTML & vbCrLf & "<option value='Greenwich Standard Time'>(" & strPrefix & ") Monrovia, Reykjavik</option>"
		strHTML = strHTML & vbCrLf & "<option value='W. Europe Standard Time'>(" & strPrefix & "+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Europe Standard Time'>(" & strPrefix & "+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague</option>"
		strHTML = strHTML & vbCrLf & "<option value='Romance Standard Time'>(" & strPrefix & "+01:00) Brussels, Copenhagen, Madrid, Paris</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central European Standard Time'>(" & strPrefix & "+01:00) Sarajevo, Skopje, Warsaw, Zagreb</option>"
		strHTML = strHTML & vbCrLf & "<option value='W. Central Africa Standard Time'>(" & strPrefix & "+01:00) West Central Africa</option>"
		strHTML = strHTML & vbCrLf & "<option value='Namibia Standard Time'>(" & strPrefix & "+01:00) Windhoek</option>"
		strHTML = strHTML & vbCrLf & "<option value='Jordan Standard Time'>(" & strPrefix & "+02:00) Amman</option>"
		strHTML = strHTML & vbCrLf & "<option value='GTB Standard Time'>(" & strPrefix & "+02:00) Athens, Bucharest</option>"
		strHTML = strHTML & vbCrLf & "<option value='Middle East Standard Time'>(" & strPrefix & "+02:00) Beirut</option>"
		strHTML = strHTML & vbCrLf & "<option value='Egypt Standard Time'>(" & strPrefix & "+02:00) Cairo</option>"
		strHTML = strHTML & vbCrLf & "<option value='Syria Standard Time'>(" & strPrefix & "+02:00) Damascus</option>"
		strHTML = strHTML & vbCrLf & "<option value='South Africa Standard Time'>(" & strPrefix & "+02:00) Harare, Pretoria</option>"
		strHTML = strHTML & vbCrLf & "<option value='FLE Standard Time'>(" & strPrefix & "+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius</option>"
		strHTML = strHTML & vbCrLf & "<option value='Turkey Standard Time'>(" & strPrefix & "+02:00) Istanbul</option>"
		strHTML = strHTML & vbCrLf & "<option value='Israel Standard Time'>(" & strPrefix & "+02:00) Jerusalem</option>"
		strHTML = strHTML & vbCrLf & "<option value='E. Europe Standard Time'>(" & strPrefix & "+02:00) Nicosia</option>"
		strHTML = strHTML & vbCrLf & "<option value='Arabic Standard Time'>(" & strPrefix & "+03:00) Baghdad</option>"
		strHTML = strHTML & vbCrLf & "<option value='Kaliningrad Standard Time'>(" & strPrefix & "+03:00) Kaliningrad, Minsk</option>"
		strHTML = strHTML & vbCrLf & "<option value='Arab Standard Time'>(" & strPrefix & "+03:00) Kuwait, Riyadh</option>"
		strHTML = strHTML & vbCrLf & "<option value='E. Africa Standard Time'>(" & strPrefix & "+03:00) Nairobi</option>"
		strHTML = strHTML & vbCrLf & "<option value='Iran Standard Time'>(" & strPrefix & "+03:30) Tehran</option>"
		strHTML = strHTML & vbCrLf & "<option value='Arabian Standard Time'>(" & strPrefix & "+04:00) Abu Dhabi, Muscat</option>"
		strHTML = strHTML & vbCrLf & "<option value='Azerbaijan Standard Time'>(" & strPrefix & "+04:00) Baku</option>"
		strHTML = strHTML & vbCrLf & "<option value='Russian Standard Time'>(" & strPrefix & "+04:00) Moscow, St. Petersburg, Volgograd</option>"
		strHTML = strHTML & vbCrLf & "<option value='Mauritius Standard Time'>(" & strPrefix & "+04:00) Port Louis</option>"
		strHTML = strHTML & vbCrLf & "<option value='Georgian Standard Time'>(" & strPrefix & "+04:00) Tbilisi</option>"
		strHTML = strHTML & vbCrLf & "<option value='Caucasus Standard Time'>(" & strPrefix & "+04:00) Yerevan</option>"
		strHTML = strHTML & vbCrLf & "<option value='Afghanistan Standard Time'>(" & strPrefix & "+04:30) Kabul</option>"
		strHTML = strHTML & vbCrLf & "<option value='Pakistan Standard Time'>(" & strPrefix & "+05:00) Islamabad, Karachi</option>"
		strHTML = strHTML & vbCrLf & "<option value='West Asia Standard Time'>(" & strPrefix & "+05:00) Tashkent</option>"
		strHTML = strHTML & vbCrLf & "<option value='India Standard Time'>(" & strPrefix & "+05:30) Chennai, Kolkata, Mumbai, New Delhi</option>"
		strHTML = strHTML & vbCrLf & "<option value='Sri Lanka Standard Time'>(" & strPrefix & "+05:30) Sri Jayawardenepura</option>"
		strHTML = strHTML & vbCrLf & "<option value='Nepal Standard Time'>(" & strPrefix & "+05:45) Kathmandu</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Asia Standard Time'>(" & strPrefix & "+06:00) Astana</option>"
		strHTML = strHTML & vbCrLf & "<option value='Bangladesh Standard Time'>(" & strPrefix & "+06:00) Dhaka</option>"
		strHTML = strHTML & vbCrLf & "<option value='Ekaterinburg Standard Time'>(" & strPrefix & "+06:00) Ekaterinburg</option>"
		strHTML = strHTML & vbCrLf & "<option value='Myanmar Standard Time'>(" & strPrefix & "+06:30) Yangon (Rangoon)</option>"
		strHTML = strHTML & vbCrLf & "<option value='SE Asia Standard Time'>(" & strPrefix & "+07:00) Bangkok, Hanoi, Jakarta</option>"
		strHTML = strHTML & vbCrLf & "<option value='N. Central Asia Standard Time'>(" & strPrefix & "+07:00) Novosibirsk</option>"
		strHTML = strHTML & vbCrLf & "<option value='China Standard Time'>(" & strPrefix & "+08:00) Beijing, Chongqing, Hong Kong, Urumqi</option>"
		strHTML = strHTML & vbCrLf & "<option value='North Asia Standard Time'>(" & strPrefix & "+08:00) Krasnoyarsk</option>"
		strHTML = strHTML & vbCrLf & "<option value='Singapore Standard Time'>(" & strPrefix & "+08:00) Kuala Lumpur, Singapore</option>"
		strHTML = strHTML & vbCrLf & "<option value='W. Australia Standard Time'>(" & strPrefix & "+08:00) Perth</option>"
		strHTML = strHTML & vbCrLf & "<option value='Taipei Standard Time'>(" & strPrefix & "+08:00) Taipei</option>"
		strHTML = strHTML & vbCrLf & "<option value='Ulaanbaatar Standard Time'>(" & strPrefix & "+08:00) Ulaanbaatar</option>"
		strHTML = strHTML & vbCrLf & "<option value='North Asia East Standard Time'>(" & strPrefix & "+09:00) Irkutsk</option>"
		strHTML = strHTML & vbCrLf & "<option value='Tokyo Standard Time'>(" & strPrefix & "+09:00) Osaka, Sapporo, Tokyo</option>"
		strHTML = strHTML & vbCrLf & "<option value='Korea Standard Time'>(" & strPrefix & "+09:00) Seoul</option>"
		strHTML = strHTML & vbCrLf & "<option value='Cen. Australia Standard Time'>(" & strPrefix & "+09:30) Adelaide</option>"
		strHTML = strHTML & vbCrLf & "<option value='AUS Central Standard Time'>(" & strPrefix & "+09:30) Darwin</option>"
		strHTML = strHTML & vbCrLf & "<option value='E. Australia Standard Time'>(" & strPrefix & "+10:00) Brisbane</option>"
		strHTML = strHTML & vbCrLf & "<option value='AUS Eastern Standard Time'>(" & strPrefix & "+10:00) Canberra, Melbourne, Sydney</option>"
		strHTML = strHTML & vbCrLf & "<option value='West Pacific Standard Time'>(" & strPrefix & "+10:00) Guam, Port Moresby</option>"
		strHTML = strHTML & vbCrLf & "<option value='Tasmania Standard Time'>(" & strPrefix & "+10:00) Hobart</option>"
		strHTML = strHTML & vbCrLf & "<option value='Yakutsk Standard Time'>(" & strPrefix & "+10:00) Yakutsk</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Pacific Standard Time'>(" & strPrefix & "+11:00) Solomon Is., New Caledonia</option>"
		strHTML = strHTML & vbCrLf & "<option value='Vladivostok Standard Time'>(" & strPrefix & "+11:00) Vladivostok</option>"
		strHTML = strHTML & vbCrLf & "<option value='New Zealand Standard Time'>(" & strPrefix & "+12:00) Auckland, Wellington</option>"
		strHTML = strHTML & vbCrLf & "<option value='UTC+12'>(" & strPrefix & "+12:00) Coordinated Universal Time+12</option>"
		strHTML = strHTML & vbCrLf & "<option value='Fiji Standard Time'>(" & strPrefix & "+12:00) Fiji</option>"
		strHTML = strHTML & vbCrLf & "<option value='Magadan Standard Time'>(" & strPrefix & "+12:00) Magadan</option>"
		strHTML = strHTML & vbCrLf & "<option value='Tonga Standard Time'>(" & strPrefix & "+13:00) Nuku</option>"
		strHTML = strHTML & vbCrLf & "<option value='Samoa Standard Time'>(" & strPrefix & "+13:00) Samoa</option>"
		strHTML = strHTML & vbCrLf & "</select>"
		span_timezones.InnerHTML = strHTML
		btn_settz.disabled = False
	Else
		MsgBox "Unable to ping " & sOldName
	End If
End Sub

Sub SetTZ
	strNewTZ = lst_timezones.Value
	MsgBox "Setting time zone to " & strNewTZ

	If strOS = "7" Then
		strCommand = "C:\temp\psexec -accepteula -i -h -u MYDOMAIN\" & txt_admname.Value & " \\" & txt_oldname.Value & " cmd.exe /c tzutil /s """ & strNewTZ & """"
	Else
		strCommand = "C:\temp\psexec -accepteula -i -u MYDOMAIN\" & txt_admname.Value & " \\" & txt_oldname.Value & " cmd.exe /c control TIMEDATE.cpl,,/Z " & strNewTZ
	End If
	
	Set objShell = CreateObject("WScript.Shell")
	objShell.Run strCommand, 1, True
	
	MsgBox "Command has been run. Please check time zone."

End Sub

Function Ping(strComputer)
	Dim objShell, boolCode
	Set objShell = CreateObject("WScript.Shell")
	boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
	If boolCode = 0 Then
		Ping = True
	Else
		Ping = False
	End If
End Function
</script>
<hta:application
	applicationname="MyHTA"	
	border="dialog"
	borderstyle="normal"
	caption="My HTML Application"
	contextmenu="no"
	icon="myicon.ico"
	maximizebutton="no"
	minimizebutton="yes"
	navigable="no"
	scroll="no"
	selection="no"
	showintaskbar="yes"
	singleinstance="yes"
	sysmenu="yes"
	version="1.0"
	windowstate="normal"
>
</head>
<body>
	<table>
		<tr>
			<td>
				Enter old computer name:
			</td>
			<td>
				<input id="txt_oldname" name="txt_oldname" type="text" size="30" maxlength="20">
			</td>
		</tr>
		<tr>
			<td>
				Enter Admin Login:
			</td>
			<td>
				<input id="txt_admname" name="txt_admname" type="text" size="30" maxlength="20">
			</td>
		</tr>
		<tr>
			<td>
				Select time zone:
			</td>
			<td>
				<span id="span_timezones"></span>
			</td>
		</tr>
		<tr>
			<td colspan="2" align="centre">
				<input type="button" value="Query Computer" id="btn_query" name="btn_query" onclick="QueryComputer">
			</td>
		</tr>
		<tr>
			<td colspan="2" align="centre">
				<input type="button" value="Set TZ" id="btn_settz" name="btn_settz" onclick="SetTZ">
			</td>
		</tr>
	</table>
</body>
</html>

Open in new window

0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
Comment Utility
Hi, glad it's working so far.  I haven't tested this, but let's see how it goes.  I've added a password field as well.

Regards,

Rob.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Time Zone Changer</title>
<script language="vbscript">
Dim strOS
Sub Window_OnLoad
	span_timezones.InnerHTML = "<select id='lst_timezones' name='lst_timezones' size='1'></select>"
	btn_settz.disabled = True
	btn_rename.disabled = True
End Sub

Sub QueryComputer
	If txt_oldname.Value = "" Then
		MsgBox "Please enter an old name."
		txt_oldname.focus
		Exit Sub
	End If
	
	btn_settz.disabled = True
	btn_rename.disabled = True
	span_timezones.InnerHTML = "<select id='lst_timezones' name='lst_timezones' size='1'></select>"
	sOldName = txt_oldname.Value
	If Ping(sOldName) = True Then
		Set objWMIService = GetObject("winmgmts:\\" & sOldName & "\root\cimv2")
		Set colItems = objWMIService.ExecQuery("Select Caption from Win32_OperatingSystem",,48)
		For Each objItem In colItems
			If InStr(objItem.Caption, "XP") > 0 Then
				strOS = "XP"
				strPrefix = "GMT"
			Else
				strOS = "7"
				strPrefix = "UTC"
			End If
		Next
		Set colItems = objWMIService.ExecQuery("Select Description from Win32_TimeZone",,48)
		For Each objItem in colItems
		    MsgBox "Operating system is Windows " & strOS & vbCrLf & "Current timezone is " & objItem.Description
		Next
	
		strHTML = "<select id='lst_timezones' name='lst_timezones' size='1'>"
		'Set objTimeZones = CreateObject("Scripting.Dictionary")
		strHTML = strHTML & vbCrLf & "<option value='Dateline Standard Time'>(" & strPrefix & "-12:00) International Date Line West</option>"
		strHTML = strHTML & vbCrLf & "<option value='UTC-11'>(" & strPrefix & "-11:00) Coordinated Universal Time-11</option>"
		strHTML = strHTML & vbCrLf & "<option value='Hawaiian Standard Time'>(" & strPrefix & "-10:00) Hawaii</option>"
		strHTML = strHTML & vbCrLf & "<option value='Alaskan Standard Time'>(" & strPrefix & "-09:00) Alaska</option>"
		strHTML = strHTML & vbCrLf & "<option value='Pacific Standard Time (Mexico)'>(" & strPrefix & "-08:00) Baja California</option>"
		strHTML = strHTML & vbCrLf & "<option value='Pacific Standard Time'>(" & strPrefix & "-08:00) Pacific Time (US & Canada)</option>"
		strHTML = strHTML & vbCrLf & "<option value='US Mountain Standard Time'>(" & strPrefix & "-07:00) Arizona</option>"
		strHTML = strHTML & vbCrLf & "<option value='Mountain Standard Time (Mexico)'>(" & strPrefix & "-07:00) Chihuahua, La Paz, Mazatlan</option>"
		strHTML = strHTML & vbCrLf & "<option value='Mountain Standard Time'>(" & strPrefix & "-07:00) Mountain Time (US & Canada)</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central America Standard Time'>(" & strPrefix & "-06:00) Central America</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Standard Time'>(" & strPrefix & "-06:00) Central Time (US & Canada)</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Standard Time (Mexico)'>(" & strPrefix & "-06:00) Guadalajara, Mexico City, Monterrey</option>"
		strHTML = strHTML & vbCrLf & "<option value='Canada Central Standard Time'>(" & strPrefix & "-06:00) Saskatchewan</option>"
		strHTML = strHTML & vbCrLf & "<option value='SA Pacific Standard Time'>(" & strPrefix & "-05:00) Bogota, Lima, Quito</option>"
		strHTML = strHTML & vbCrLf & "<option value='Eastern Standard Time'>(" & strPrefix & "-05:00) Eastern Time (US & Canada)</option>"
		strHTML = strHTML & vbCrLf & "<option value='US Eastern Standard Time'>(" & strPrefix & "-05:00) Indiana (East)</option>"
		strHTML = strHTML & vbCrLf & "<option value='Venezuela Standard Time'>(" & strPrefix & "-04:30) Caracas</option>"
		strHTML = strHTML & vbCrLf & "<option value='Paraguay Standard Time'>(" & strPrefix & "-04:00) Asuncion</option>"
		strHTML = strHTML & vbCrLf & "<option value='Atlantic Standard Time'>(" & strPrefix & "-04:00) Atlantic Time (Canada)</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Brazilian Standard Time'>(" & strPrefix & "-04:00) Cuiaba</option>"
		strHTML = strHTML & vbCrLf & "<option value='SA Western Standard Time'>(" & strPrefix & "-04:00) Georgetown, La Paz, Manaus, San Juan</option>"
		strHTML = strHTML & vbCrLf & "<option value='Pacific SA Standard Time'>(" & strPrefix & "-04:00) Santiago</option>"
		strHTML = strHTML & vbCrLf & "<option value='Newfoundland Standard Time'>(" & strPrefix & "-03:30) Newfoundland</option>"
		strHTML = strHTML & vbCrLf & "<option value='E. South America Standard Time'>(" & strPrefix & "-03:00) Brasilia</option>"
		strHTML = strHTML & vbCrLf & "<option value='Argentina Standard Time'>(" & strPrefix & "-03:00) Buenos Aires</option>"
		strHTML = strHTML & vbCrLf & "<option value='SA Eastern Standard Time'>(" & strPrefix & "-03:00) Cayenne, Fortaleza</option>"
		strHTML = strHTML & vbCrLf & "<option value='Greenland Standard Time'>(" & strPrefix & "-03:00) Greenland</option>"
		strHTML = strHTML & vbCrLf & "<option value='Montevideo Standard Time'>(" & strPrefix & "-03:00) Montevideo</option>"
		strHTML = strHTML & vbCrLf & "<option value='Bahia Standard Time'>(" & strPrefix & "-03:00) Salvador</option>"
		strHTML = strHTML & vbCrLf & "<option value='UTC-02'>(" & strPrefix & "-02:00) Coordinated Universal Time-02</option>"
		strHTML = strHTML & vbCrLf & "<option value='Mid-Atlantic Standard Time'>(" & strPrefix & "-02:00) Mid-Atlantic</option>"
		strHTML = strHTML & vbCrLf & "<option value='Azores Standard Time'>(" & strPrefix & "-01:00) Azores</option>"
		strHTML = strHTML & vbCrLf & "<option value='Cape Verde Standard Time'>(" & strPrefix & "-01:00) Cape Verde Is.</option>"
		strHTML = strHTML & vbCrLf & "<option value='Morocco Standard Time'>(" & strPrefix & ") Casablanca</option>"
		strHTML = strHTML & vbCrLf & "<option value='UTC'>(" & strPrefix & ") Coordinated Universal Time</option>"
		strHTML = strHTML & vbCrLf & "<option value='GMT Standard Time'>(" & strPrefix & ") Dublin, Edinburgh, Lisbon, London</option>"
		strHTML = strHTML & vbCrLf & "<option value='Greenwich Standard Time'>(" & strPrefix & ") Monrovia, Reykjavik</option>"
		strHTML = strHTML & vbCrLf & "<option value='W. Europe Standard Time'>(" & strPrefix & "+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Europe Standard Time'>(" & strPrefix & "+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague</option>"
		strHTML = strHTML & vbCrLf & "<option value='Romance Standard Time'>(" & strPrefix & "+01:00) Brussels, Copenhagen, Madrid, Paris</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central European Standard Time'>(" & strPrefix & "+01:00) Sarajevo, Skopje, Warsaw, Zagreb</option>"
		strHTML = strHTML & vbCrLf & "<option value='W. Central Africa Standard Time'>(" & strPrefix & "+01:00) West Central Africa</option>"
		strHTML = strHTML & vbCrLf & "<option value='Namibia Standard Time'>(" & strPrefix & "+01:00) Windhoek</option>"
		strHTML = strHTML & vbCrLf & "<option value='Jordan Standard Time'>(" & strPrefix & "+02:00) Amman</option>"
		strHTML = strHTML & vbCrLf & "<option value='GTB Standard Time'>(" & strPrefix & "+02:00) Athens, Bucharest</option>"
		strHTML = strHTML & vbCrLf & "<option value='Middle East Standard Time'>(" & strPrefix & "+02:00) Beirut</option>"
		strHTML = strHTML & vbCrLf & "<option value='Egypt Standard Time'>(" & strPrefix & "+02:00) Cairo</option>"
		strHTML = strHTML & vbCrLf & "<option value='Syria Standard Time'>(" & strPrefix & "+02:00) Damascus</option>"
		strHTML = strHTML & vbCrLf & "<option value='South Africa Standard Time'>(" & strPrefix & "+02:00) Harare, Pretoria</option>"
		strHTML = strHTML & vbCrLf & "<option value='FLE Standard Time'>(" & strPrefix & "+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius</option>"
		strHTML = strHTML & vbCrLf & "<option value='Turkey Standard Time'>(" & strPrefix & "+02:00) Istanbul</option>"
		strHTML = strHTML & vbCrLf & "<option value='Israel Standard Time'>(" & strPrefix & "+02:00) Jerusalem</option>"
		strHTML = strHTML & vbCrLf & "<option value='E. Europe Standard Time'>(" & strPrefix & "+02:00) Nicosia</option>"
		strHTML = strHTML & vbCrLf & "<option value='Arabic Standard Time'>(" & strPrefix & "+03:00) Baghdad</option>"
		strHTML = strHTML & vbCrLf & "<option value='Kaliningrad Standard Time'>(" & strPrefix & "+03:00) Kaliningrad, Minsk</option>"
		strHTML = strHTML & vbCrLf & "<option value='Arab Standard Time'>(" & strPrefix & "+03:00) Kuwait, Riyadh</option>"
		strHTML = strHTML & vbCrLf & "<option value='E. Africa Standard Time'>(" & strPrefix & "+03:00) Nairobi</option>"
		strHTML = strHTML & vbCrLf & "<option value='Iran Standard Time'>(" & strPrefix & "+03:30) Tehran</option>"
		strHTML = strHTML & vbCrLf & "<option value='Arabian Standard Time'>(" & strPrefix & "+04:00) Abu Dhabi, Muscat</option>"
		strHTML = strHTML & vbCrLf & "<option value='Azerbaijan Standard Time'>(" & strPrefix & "+04:00) Baku</option>"
		strHTML = strHTML & vbCrLf & "<option value='Russian Standard Time'>(" & strPrefix & "+04:00) Moscow, St. Petersburg, Volgograd</option>"
		strHTML = strHTML & vbCrLf & "<option value='Mauritius Standard Time'>(" & strPrefix & "+04:00) Port Louis</option>"
		strHTML = strHTML & vbCrLf & "<option value='Georgian Standard Time'>(" & strPrefix & "+04:00) Tbilisi</option>"
		strHTML = strHTML & vbCrLf & "<option value='Caucasus Standard Time'>(" & strPrefix & "+04:00) Yerevan</option>"
		strHTML = strHTML & vbCrLf & "<option value='Afghanistan Standard Time'>(" & strPrefix & "+04:30) Kabul</option>"
		strHTML = strHTML & vbCrLf & "<option value='Pakistan Standard Time'>(" & strPrefix & "+05:00) Islamabad, Karachi</option>"
		strHTML = strHTML & vbCrLf & "<option value='West Asia Standard Time'>(" & strPrefix & "+05:00) Tashkent</option>"
		strHTML = strHTML & vbCrLf & "<option value='India Standard Time'>(" & strPrefix & "+05:30) Chennai, Kolkata, Mumbai, New Delhi</option>"
		strHTML = strHTML & vbCrLf & "<option value='Sri Lanka Standard Time'>(" & strPrefix & "+05:30) Sri Jayawardenepura</option>"
		strHTML = strHTML & vbCrLf & "<option value='Nepal Standard Time'>(" & strPrefix & "+05:45) Kathmandu</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Asia Standard Time'>(" & strPrefix & "+06:00) Astana</option>"
		strHTML = strHTML & vbCrLf & "<option value='Bangladesh Standard Time'>(" & strPrefix & "+06:00) Dhaka</option>"
		strHTML = strHTML & vbCrLf & "<option value='Ekaterinburg Standard Time'>(" & strPrefix & "+06:00) Ekaterinburg</option>"
		strHTML = strHTML & vbCrLf & "<option value='Myanmar Standard Time'>(" & strPrefix & "+06:30) Yangon (Rangoon)</option>"
		strHTML = strHTML & vbCrLf & "<option value='SE Asia Standard Time'>(" & strPrefix & "+07:00) Bangkok, Hanoi, Jakarta</option>"
		strHTML = strHTML & vbCrLf & "<option value='N. Central Asia Standard Time'>(" & strPrefix & "+07:00) Novosibirsk</option>"
		strHTML = strHTML & vbCrLf & "<option value='China Standard Time'>(" & strPrefix & "+08:00) Beijing, Chongqing, Hong Kong, Urumqi</option>"
		strHTML = strHTML & vbCrLf & "<option value='North Asia Standard Time'>(" & strPrefix & "+08:00) Krasnoyarsk</option>"
		strHTML = strHTML & vbCrLf & "<option value='Singapore Standard Time'>(" & strPrefix & "+08:00) Kuala Lumpur, Singapore</option>"
		strHTML = strHTML & vbCrLf & "<option value='W. Australia Standard Time'>(" & strPrefix & "+08:00) Perth</option>"
		strHTML = strHTML & vbCrLf & "<option value='Taipei Standard Time'>(" & strPrefix & "+08:00) Taipei</option>"
		strHTML = strHTML & vbCrLf & "<option value='Ulaanbaatar Standard Time'>(" & strPrefix & "+08:00) Ulaanbaatar</option>"
		strHTML = strHTML & vbCrLf & "<option value='North Asia East Standard Time'>(" & strPrefix & "+09:00) Irkutsk</option>"
		strHTML = strHTML & vbCrLf & "<option value='Tokyo Standard Time'>(" & strPrefix & "+09:00) Osaka, Sapporo, Tokyo</option>"
		strHTML = strHTML & vbCrLf & "<option value='Korea Standard Time'>(" & strPrefix & "+09:00) Seoul</option>"
		strHTML = strHTML & vbCrLf & "<option value='Cen. Australia Standard Time'>(" & strPrefix & "+09:30) Adelaide</option>"
		strHTML = strHTML & vbCrLf & "<option value='AUS Central Standard Time'>(" & strPrefix & "+09:30) Darwin</option>"
		strHTML = strHTML & vbCrLf & "<option value='E. Australia Standard Time'>(" & strPrefix & "+10:00) Brisbane</option>"
		strHTML = strHTML & vbCrLf & "<option value='AUS Eastern Standard Time'>(" & strPrefix & "+10:00) Canberra, Melbourne, Sydney</option>"
		strHTML = strHTML & vbCrLf & "<option value='West Pacific Standard Time'>(" & strPrefix & "+10:00) Guam, Port Moresby</option>"
		strHTML = strHTML & vbCrLf & "<option value='Tasmania Standard Time'>(" & strPrefix & "+10:00) Hobart</option>"
		strHTML = strHTML & vbCrLf & "<option value='Yakutsk Standard Time'>(" & strPrefix & "+10:00) Yakutsk</option>"
		strHTML = strHTML & vbCrLf & "<option value='Central Pacific Standard Time'>(" & strPrefix & "+11:00) Solomon Is., New Caledonia</option>"
		strHTML = strHTML & vbCrLf & "<option value='Vladivostok Standard Time'>(" & strPrefix & "+11:00) Vladivostok</option>"
		strHTML = strHTML & vbCrLf & "<option value='New Zealand Standard Time'>(" & strPrefix & "+12:00) Auckland, Wellington</option>"
		strHTML = strHTML & vbCrLf & "<option value='UTC+12'>(" & strPrefix & "+12:00) Coordinated Universal Time+12</option>"
		strHTML = strHTML & vbCrLf & "<option value='Fiji Standard Time'>(" & strPrefix & "+12:00) Fiji</option>"
		strHTML = strHTML & vbCrLf & "<option value='Magadan Standard Time'>(" & strPrefix & "+12:00) Magadan</option>"
		strHTML = strHTML & vbCrLf & "<option value='Tonga Standard Time'>(" & strPrefix & "+13:00) Nuku</option>"
		strHTML = strHTML & vbCrLf & "<option value='Samoa Standard Time'>(" & strPrefix & "+13:00) Samoa</option>"
		strHTML = strHTML & vbCrLf & "</select>"
		span_timezones.InnerHTML = strHTML
		btn_settz.disabled = False
		btn_rename.disabled = False
	Else
		MsgBox "Unable to ping " & sOldName
	End If
End Sub

Sub SetTZ
	If txt_admname.Value = "" Then
		MsgBox "Please enter an admin username"
		txt_admname.focus
		Exit Sub
	End If
	If txt_admpass.Value = "" Then
		MsgBox "Please enter an admin password"
		txt_admpass.focus
		Exit Sub
	End If
	
	strNewTZ = lst_timezones.Value
	MsgBox "Setting time zone to " & strNewTZ

	If strOS = "7" Then
		strCommand = "C:\temp\psexec -accepteula -i -h -u MYDOMAIN\" & txt_admname.Value & " -p " & txt_admpass.Value & " \\" & txt_oldname.Value & " cmd.exe /c tzutil /s """ & strNewTZ & """"
	Else
		strCommand = "C:\temp\psexec -accepteula -i -u MYDOMAIN\" & txt_admname.Value & " -p " & txt_admpass.Value & " \\" & txt_oldname.Value & " cmd.exe /c control TIMEDATE.cpl,,/Z " & strNewTZ
	End If
	
	Set objShell = CreateObject("WScript.Shell")
	objShell.Run strCommand, 1, True
	
	MsgBox "Command has been run. Please check time zone."

End Sub

Sub RenameComputer
	If txt_admname.Value = "" Then
		MsgBox "Please enter an admin username"
		txt_admname.focus
		Exit Sub
	End If
	If txt_admpass.Value = "" Then
		MsgBox "Please enter an admin password"
		txt_admpass.focus
		Exit Sub
	End If
	If txt_newname.Value = "" Then
		MsgBox "Please enter a new computer name"
		txt_newname.focus
		Exit Sub
	End If
	
	Set objShell = CreateObject("WScript.Shell")
	btn_settz.disabled = True
	btn_rename.disabled = True
	sOldName = txt_oldname.Value
	sNewName = txt_newname.Value
	intReturn = objShell.Run("cmd.exe /K netdom renamecomputer " & sOldName & " /newname:" & sNewName & " /userd:MYDOMAIN\" & txt_admname.Value & " /passwordd:" & txt_admpass.Value & " /usero:MYDOMAIN\" & txt_admname.Value & " /passwordo:" & txt_admpass.Value & " /force")
	If intReturn = 0 Then
		MsgBox "Rename successful"
	Else
		MsgBox "Rename failed with return code " & intReturn
	End If
	btn_settz.disabled = False
	btn_rename.disabled = False
End Sub

Function Ping(strComputer)
	Dim objShell, boolCode
	Set objShell = CreateObject("WScript.Shell")
	boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
	If boolCode = 0 Then
		Ping = True
	Else
		Ping = False
	End If
End Function
</script>
<hta:application
	applicationname="MyHTA"	
	border="dialog"
	borderstyle="normal"
	caption="My HTML Application"
	contextmenu="no"
	icon="myicon.ico"
	maximizebutton="no"
	minimizebutton="yes"
	navigable="no"
	scroll="no"
	selection="no"
	showintaskbar="yes"
	singleinstance="yes"
	sysmenu="yes"
	version="1.0"
	windowstate="normal"
>
</head>
<body>
	<table>
		<tr>
			<td>
				Enter old computer name:
			</td>
			<td>
				<input id="txt_oldname" name="txt_oldname" type="text" size="30" maxlength="20">
			</td>
		</tr>
		<tr>
			<td colspan="2" align="centre">
				<input type="button" value="Query Computer" id="btn_query" name="btn_query" onclick="QueryComputer">
			</td>
		</tr>
		<tr>
			<td>
				Select time zone:
			</td>
			<td>
				<span id="span_timezones"></span>
			</td>
		</tr>
		<tr>
			<td>
				Enter Admin Username:
			</td>
			<td>
				<input id="txt_admname" name="txt_admname" type="text" size="30" maxlength="20">
			</td>
		</tr>
		<tr>
			<td>
				Enter Admin Password:
			</td>
			<td>
				<input id="txt_admpass" name="txt_admpass" type="password" size="30" maxlength="20">
			</td>
		</tr>
		<tr>
			<td colspan="2" align="centre">
				<input type="button" value="Set TZ" id="btn_settz" name="btn_settz" onclick="SetTZ">
			</td>
		</tr>
		<tr>
			<td>
				Enter new computer name:
			</td>
			<td>
				<input id="txt_newname" name="txt_newname" type="text" size="30" maxlength="20">
			</td>
		</tr>
		<tr>
			<td colspan="2" align="centre">
				<input type="button" value="Rename Computer" id="btn_rename" name="btn_rename" onclick="RenameComputer">
			</td>
		</tr>
	</table>
</body>
</html>

Open in new window

0
 
LVL 1

Author Closing Comment

by:jbyrd1981
Comment Utility
Perfect! Exactly what I wanted and more! THANK YOU!!!
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
No problem. Thanks for the grade.

Rob.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now