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.