Page 1 of 1 1
Topic Options
#203899 - 2011-12-09 08:55 AM Time Zones- International Roaming- Kix Script - Help
Jacob_Kreed Offline
Fresh Scripter

Registered: 2001-12-14
Posts: 19
Loc: UK
I did to create a kix script, to change the time from GMT to EST by ip address as the users login

 Code:
shell "c:\scripts\getipadr.cmd" : Collect WTSClientAddress
sleep 5 
$x=open(1,"%temp%\ipaddress.txt")
$ip=readline(1)

$Systems= LTRIM(substr($ip,18,11))  ; Test IP Address
$NY=LCASE $Systems="10.176.192" ; Test Scope
	Run "REGEDIT.EXE /S C:\Scripts\USA.Reg" : Registory for USA
	Run "Regedit.exe /S C:\Scripts\NY.reg"  : Registory for EST
	? "Timezone set to GMT"
	sleep 1
	CASE $NY="10.20.84"
	Run "REGEDIT.EXE /S C:\Scripts\USA.Reg"
	Run "Regedit.exe /S C:\Scripts\NY.reg
	? "TimeZone set to EST"
	Sleep 1
	CASE $CH="10.50.11"
	? "TimeZone Set to CST"
	Sleep 1
	
ENDSELECTTRIM(Substr($ip,18,9))  ; 10.20.84
$CH=LTRIM(Substr($ip,18,9))  ; 10.50.11
SELECT


Edited by Mart (2011-12-09 09:58 AM)
Edit Reason: Please use code tags when posting code.

Top
#203900 - 2011-12-09 12:21 PM Re: Time Zones- International Roaming- Kix Script - Help [Re: Jacob_Kreed]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
Not sure why you are doing this. The timezone shouldn't have to be changed every time someone logs in. Also, this isn't a function a user should be doing. It is accessing the HKEY_LOCAL_MACHINE hive which normal users should not have write access to. So, if you need to do it once, run it as a remote application from a domain administrator's account on a central server.

That being said, you are shelling out to the OS to do functions that Kixtart was designed for. Take a look in the manual at the macros. You can get the ip address from them. Take a look at the writevalue function. Also, your "Case" statement is missing the "Select" begin word. I suspect the "ENDSELECTTRIM" is supposed to be "ENDSELECT" followed by a carriage return and then a "TRIM?"

Lots of work to do, but you should change it to a remote function. It could be run as a start up script from GPO if needed.

Top
#203901 - 2011-12-09 03:57 PM Re: Time Zones- International Roaming- Kix Script - Help [Re: BradV]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
I could be wrong, but the timezone shouldn't be changing based on the user that is logging in. So, even though someone might be home-based in London and then travels to New York to log in to a system there, the timezone on the New York system should not have to be changed. Anyone else know that I am wrong?
Top
#203902 - 2011-12-09 04:19 PM Re: Time Zones- International Roaming- Kix Script - Help [Re: BradV]
Jacob_Kreed Offline
Fresh Scripter

Registered: 2001-12-14
Posts: 19
Loc: UK
All the servers are hosted in the UK,
Top
#203903 - 2011-12-09 04:26 PM Re: Time Zones- International Roaming- Kix Script - Help [Re: Jacob_Kreed]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Well, there are numerous flaws in the code that you posted. :'s are not comment characters like the ;'s are. Also not sure what you are trying to do with the line that is just $NY=LCASE ...Also missing the SELECT statement before the case statements. Honestly I have no idea what you're trying to do in there.
Top
#203904 - 2011-12-09 06:06 PM Re: Time Zones- International Roaming- Kix Script - Help [Re: ShaneEP]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
But it doesn't matter where your domain server is, the workstation's HKEY_LOCAL_MACHINE will have the timezone set for it. Unless you are overriding this somehow in the user's hive?
Top
#203905 - 2011-12-09 06:10 PM Re: Time Zones- International Roaming- Kix Script - Help [Re: BradV]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4557
Loc: USA
There is also tzutil.exe for Vista/Win7 and a hack of sorts that worked on OSs before Vista... "Control.exe TIMEDATE.CPL,,/Z Pacific Standard Time"
Top
#203910 - 2011-12-12 05:19 PM Re: Time Zones- International Roaming- Kix Script - Help [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Something like this maybe?

 Code:
shell "c:\scripts\envtscip.exe > %temp%\ipaddress.txt" 
$nul = Open(1,"%temp%\ipaddress.txt")
$ip = ReadLine(1)
$nul = Close(1)
$systems = SubStr($ip,18,11)
$ip = SubStr($ip,18,9)

Select
   Case Left($systems,10) = "10.176.192"
      Shell 'Regedit.exe /S C:\Scripts\USA.Reg'
      Shell 'Regedit.exe /S C:\Scripts\NewYork.reg'
      Shell 'control.exe timedate.cpl,,/Z GMT Standard Time'
   Case Left($ip,8) = "10.80.84"
      Shell 'Regedit.exe /S C:\Scripts\USA.Reg'
      Shell 'Regedit.exe /S C:\Scripts\NY.reg'
      Shell 'control.exe timedate.cpl,,/Z Eastern Standard Time'
   Case Left($ip,8) = "10.78.11"
      Shell 'control.exe timedate.cpl,,/Z Central Standard Time'
EndSelect

Top
#203911 - 2011-12-12 06:37 PM Re: Time Zones- International Roaming- Kix Script - Help [Re: ShaneEP]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4557
Loc: USA
I might be wrong, but something in the back of my mind says the TIMEDATE.CPL has to be in all caps.
Top
#203912 - 2011-12-12 06:47 PM Re: Time Zones- International Roaming- Kix Script - Help [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
It worked in lower case via command prompt. My only concern is if it works on anything newer than xp, since that's all I have to test on at work.
Top
#203913 - 2011-12-13 12:46 AM Re: Time Zones- International Roaming- Kix Script - Help [Re: ShaneEP]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4557
Loc: USA
Yeah... you have to check the os before running it. The control.exe version does not work after XP.
Top
#203914 - 2011-12-13 12:56 AM Re: Time Zones- International Roaming- Kix Script - Help [Re: ShaneEP]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
This is a GPO setting and should not be setup using any type of script.
I have it set and my users around the World see the time from their local workstation just fine.

Configuring Terminal Server for Differing Time Zones

 Quote:
Configuring Terminal Server for Differing Time Zones

Updated: March 28, 2003

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2

By default Terminal Server keeps track of time according to the time zone in which it has been configured, rather than on a per-user basis. This can be a problem when a user connects to a terminal server outside of the time zone in which the user is located because the local computer uses the time configured on the terminal server rather than the local time. If you are hosting time-sensitive applications on your terminal server or if you have processes in place that depend on the user’s current local time, such as financial systems and calendaring, you might want to enable the Allow Time Zone Redirection Group Policy setting. This policy is located in Windows Components/Terminal Services. With this setting enabled, Terminal Services uses the server base time on the terminal server and the client time zone information to calculate the time on the session.



 Quote:
Allow time zone redirection


This policy setting determines whether the client computer redirects its time zone settings to the Terminal Services session.

If you enable this policy setting, clients that are capable of time zone redirection send their time zone information to the server. The server base time is then used to calculate the current session time (current session time = server base time + client time zone).

If you disable or do not configure this policy setting, the client computer does not redirect its time zone information and the session time zone is the same as the server time zone.
noteNote
Time zone redirection is possible only when connecting to at least a Windows Server 2003 terminal server with a client that is using RDP 5.1 or later.



All Group Policy Settings for Terminal Services in Windows Server 2008


The link above shows many other policies that can be set for Terminal Server

 

Top
#203915 - 2011-12-13 02:03 AM Re: Time Zones- International Roaming- Kix Script - Help [Re: NTDOC]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Can you not just use DHCP to set the TZ?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#203919 - 2011-12-14 05:16 AM Re: Time Zones- International Roaming- Kix Script - Help [Re: Les]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Well you can but that would not correct Terminal Server time differences/issues it would only update the client workstation which hopefully is already set.
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 581 anonymous users online.
Newest Members
Audio, Hoschi, Comet, rrosell, PatrickPinto
17880 Registered Users

Generated in 0.13 seconds in which 0.081 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org