?
Solved

Tzutil in vbscript help

Posted on 2011-02-15
5
Medium Priority
?
2,374 Views
Last Modified: 2012-05-11
Hi guys i need a bit of help.

I am creating a SOE image for a rollout of about 500 pc's.  These pc's will be all over australia so i am in the process of creating a vb script that will allow the users to select the state they are in and it will change the timezone on the machine accordingly.

I am using vbscript to call on the command line tool TZutil.exe. This is a summary of the code i am trying to get working

ChangeTimeZone("Aus Eastern Standard Time")

Sub ChangeTimeZone(strTimeZone)
   Set objShell = CreateObject("WScript.shell")  
   objShell.Run "tzutil.exe /s" & strTimeZone
   wscript.echo ("Timezone changed to " & strTimeZone)
End Sub


However i think the above code is presenting TZutil.exe /s Aus Eastern Standard Time instead of what i need in TZUTIL /s "Aus Eastern Standard Time"

The missing " " around the timezone name is what seems to be breaking this for me.  I need to find some what to ensure that the time zone is passed through to the command line with the " " around it

The question is how do i get this to work.  I have only started learning VB so this is a new thing for me.  Any assistace will be greatly appreciated. As this is the last thing of a long complicated process.

Is it simple process to get the command parsed through including the " " around the timezoneID or is there a major complicated re-write of code  I need to do.
0
Comment
Question by:tetran_au
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
Tompa99 earned 2000 total points
ID: 34904303
Hi

Try this

objShell.Run "tzutil.exe /s" & chr(34) & strTimeZone & chr(34)

best Regards Tompa
0
 
LVL 2

Author Comment

by:tetran_au
ID: 34904609
Hi Tompa

Thanks for the quick response

I have modified the script to now be



ChangeTimeZone("Fiji Standard Time")

Sub ChangeTimeZone(strTimeZone)
   Set objShell = CreateObject("WScript.shell")  
   objShell.Run "c:\windows\system32\tzutil.exe /s" & chr(34) & strTimeZone & chr(34)
   wscript.echo ("Timezone changed to " & chr(34) & strTimeZone & chr(34))
End Sub

The good point is while it is showing the " " in the wscript.echo it is still not running the command correctly. ;(

0
 
LVL 2

Author Comment

by:tetran_au
ID: 34905038
Hi Tompa,

Ignore my last post, You are truely a god

I modified the script to try and see what was going wrong

ChangeTimeZone("Aus Eastern Standard Time")

Sub ChangeTimeZone(strTimeZone)
   Set objShell = CreateObject("WScript.shell")  
   objShell.Run "c:\windows\system32\tzutil.exe /s" & chr(34) & strTimeZone & chr(34)
   wscript.echo ("c:\windows\system32\tzutil.exe /s " & chr(34) & strTimeZone & chr(34))
   wscript.echo ("Timezone changed to " & chr(34) & strTimeZone & chr(34))
End Sub

With the line you provided it was parsing thru the following

c:\windows\system32\tzutil.exe /s"TimeZoneID"

I tried this command from the cmd.exe and it bombed out.

i have since identified that it needed space between the /s and the "timezoneID"

So i changed
objShell.Run "c:\windows\system32\tzutil.exe /s" & chr(34) & strTimeZone & chr(34)
to
objShell.Run "c:\windows\system32\tzutil.exe /s " & chr(34) & strTimeZone & chr(34)

and it worked perfectly...

cant thank you enough for your help.

THANK YOUUUUUUUU

0
 
LVL 2

Author Closing Comment

by:tetran_au
ID: 34905048
Truely helpful expert.

eternally grateful
0
 
LVL 5

Expert Comment

by:Tompa99
ID: 34906230
Good good always happy to help.

Regards Tompa
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

777 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