Location: Mail List

Ads

Skyscraper

The GPTalk Mailing List

The GPTALK mailing list is where you can send and receive email related to Windows Group Policy. You must subscribe to the list to send and receive mail from the list. The purpose of the list is to provide a forum for asking and answering technical questions related to Group Policy. Any question is fair game as long as it is related to Windows Group Policy.  The Archives for this list can be found on this page.

 

List Posts

Subject: [gptalk] wshShell.Run
Prev Next
You are not authorized to post a reply.

AuthorMessages
MaryWinterUser is Offline

Posts:45

08/02/2011 6:04 PM  
I have seen this issue described on web forums but none of them has an answer published. Please forgive me if this has already been covered. I have a timezone.vbs script that tests to see what segment the PCs are on and sets the timezone. Some of our segments are in the Eastern time zone and others are in the Central time zone. The script needed to be updated because it used control.exe which does not work in Windows 7. Now it uses TZUtil. The script runs locally but will not run as a startup script through group policy. Several people reported this issue and some were pointed to the wshShell.Run command as the problem. My question, what would I use instead of this command to run TZUtil? Thank you in advance for your help.

Mary Winter
IT Infrastructure Consultant
Desktop Services


DarraghOShaughnessyUser is Offline

Posts:177

08/02/2011 6:10 PM  
You could use the '.exec' method but we need more detail. Why does it not
run as a group policy?



From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com]
On Behalf Of Winter.Mary
Sent: 02 August 2011 15:13
To: gptalk@lists.gpoguy.com
Subject: [gptalk] wshShell.Run



I have seen this issue described on web forums but none of them has an
answer published. Please forgive me if this has already been covered. I
have a timezone.vbs script that tests to see what segment the PCs are on and
sets the timezone. Some of our segments are in the Eastern time zone and
others are in the Central time zone. The script needed to be updated
because it used control.exe which does not work in Windows 7. Now it uses
TZUtil. The script runs locally but will not run as a startup script
through group policy. Several people reported this issue and some were
pointed to the wshShell.Run command as the problem. My question, what would
I use instead of this command to run TZUtil? Thank you in advance for your
help.



Mary Winter
IT Infrastructure Consultant
Desktop Services


MaryWinterUser is Offline

Posts:45

08/02/2011 6:36 PM  
Sorry Darragh,
I don't know why. GPresult shows that the GPO has been applied but the script does not run and there are no errors for it in the event log. In fact for all of my startup scripts I get the line: LastExecuted: This script has not yet been executed.
This is not true though because the other two scripts do run. Neither of them uses wshShell.run.
Mary

From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Darragh O'Shaughnessy
Sent: Tuesday, August 02, 2011 9:18 AM
To: gptalk@lists.gpoguy.com
Subject: RE: [gptalk] wshShell.Run

You could use the '.exec' method but we need more detail. Why does it not run as a group policy?

From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Winter.Mary
Sent: 02 August 2011 15:13
To: gptalk@lists.gpoguy.com
Subject: [gptalk] wshShell.Run

I have seen this issue described on web forums but none of them has an answer published. Please forgive me if this has already been covered. I have a timezone.vbs script that tests to see what segment the PCs are on and sets the timezone. Some of our segments are in the Eastern time zone and others are in the Central time zone. The script needed to be updated because it used control.exe which does not work in Windows 7. Now it uses TZUtil. The script runs locally but will not run as a startup script through group policy. Several people reported this issue and some were pointed to the wshShell.Run command as the problem. My question, what would I use instead of this command to run TZUtil? Thank you in advance for your help.

Mary Winter
IT Infrastructure Consultant
Desktop Services

DarraghOShaughnessyUser is Offline

Posts:177

08/02/2011 6:39 PM  
If I ever execute .vbs scripts in my gpos, I use a wrapper .cmd file like
this





Contents of wrapper.cmd:



Cscript //nologo <myscript.vbs> > %tmp%\myscript.log



I usually have a flag at the top of my script that enables some logging to
the console which in turn is dumped to the log file above for further
analysis. Can you dump the script code itself?





From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com]
On Behalf Of Winter.Mary
Sent: 02 August 2011 15:40
To: 'gptalk@lists.gpoguy.com'
Subject: RE: [gptalk] wshShell.Run



Sorry Darragh,

I don't know why. GPresult shows that the GPO has been applied but the
script does not run and there are no errors for it in the event log. In
fact for all of my startup scripts I get the line: LastExecuted: This script
has not yet been executed.

This is not true though because the other two scripts do run. Neither of
them uses wshShell.run.

Mary



From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com]
On Behalf Of Darragh O'Shaughnessy
Sent: Tuesday, August 02, 2011 9:18 AM
To: gptalk@lists.gpoguy.com
Subject: RE: [gptalk] wshShell.Run



You could use the '.exec' method but we need more detail. Why does it not
run as a group policy?



From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com]
On Behalf Of Winter.Mary
Sent: 02 August 2011 15:13
To: gptalk@lists.gpoguy.com
Subject: [gptalk] wshShell.Run



I have seen this issue described on web forums but none of them has an
answer published. Please forgive me if this has already been covered. I
have a timezone.vbs script that tests to see what segment the PCs are on and
sets the timezone. Some of our segments are in the Eastern time zone and
others are in the Central time zone. The script needed to be updated
because it used control.exe which does not work in Windows 7. Now it uses
TZUtil. The script runs locally but will not run as a startup script
through group policy. Several people reported this issue and some were
pointed to the wshShell.Run command as the problem. My question, what would
I use instead of this command to run TZUtil? Thank you in advance for your
help.



Mary Winter
IT Infrastructure Consultant
Desktop Services


MaryWinterUser is Offline

Posts:45

08/02/2011 6:45 PM  
'----------------------------------------
' Update the Time Zone.
'----------------------------------------
Sub UpdateTimeZone(TZ)

Dim sCommandToRun

' Set the Time Zone
Set WshShell = WScript.CreateObject("WScript.Shell")

' Create command line
sCommandToRun = "c:\windows\system32\tzutil /s " & chr(34) & TZ & chr(34)
Wscript.Echo "sCommandToRun: " & sCommandToRun

' Run command
WshShell.run sCommandToRun
' Stop and Start the Time Service to take effect.
WshShell.run "net stop w32Time",iHide, bWaitOnReturn
wscript.sleep 500
WshShell.run "net start w32Time", iHide, bWaitOnReturn

set WshShell = Nothing

End Sub

From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Darragh O'Shaughnessy
Sent: Tuesday, August 02, 2011 9:46 AM
To: 'gptalk@lists.gpoguy.com'
Subject: RE: [gptalk] wshShell.Run

Run method is defined here:

http://msdn.microsoft.com/en-us/library/d5fk67ky%28v=vs.85%29.aspx

Can you post the line of code that calls this method? I use it in other start up scripts on Windows 7 and it runs fine.


From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Winter.Mary
Sent: 02 August 2011 15:40
To: 'gptalk@lists.gpoguy.com'
Subject: RE: [gptalk] wshShell.Run

Sorry Darragh,
I don't know why. GPresult shows that the GPO has been applied but the script does not run and there are no errors for it in the event log. In fact for all of my startup scripts I get the line: LastExecuted: This script has not yet been executed.
This is not true though because the other two scripts do run. Neither of them uses wshShell.run.
Mary

From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Darragh O'Shaughnessy
Sent: Tuesday, August 02, 2011 9:18 AM
To: gptalk@lists.gpoguy.com
Subject: RE: [gptalk] wshShell.Run

You could use the '.exec' method but we need more detail. Why does it not run as a group policy?

From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Winter.Mary
Sent: 02 August 2011 15:13
To: gptalk@lists.gpoguy.com
Subject: [gptalk] wshShell.Run

I have seen this issue described on web forums but none of them has an answer published. Please forgive me if this has already been covered. I have a timezone.vbs script that tests to see what segment the PCs are on and sets the timezone. Some of our segments are in the Eastern time zone and others are in the Central time zone. The script needed to be updated because it used control.exe which does not work in Windows 7. Now it uses TZUtil. The script runs locally but will not run as a startup script through group policy. Several people reported this issue and some were pointed to the wshShell.Run command as the problem. My question, what would I use instead of this command to run TZUtil? Thank you in advance for your help.

Mary Winter
IT Infrastructure Consultant
Desktop Services

DarraghOShaughnessyUser is Offline

Posts:177

08/02/2011 7:26 PM  
I would adjust the script as below (added some logging to help debug). Also, are the following variables defined globally as you use them in the subroutine?



· iHide

· bWaitOnReturn



_____



'----------------------------------------
' Update the Time Zone.
'----------------------------------------
Sub UpdateTimeZone(TZ)
  On Error Resume Next

  Dim sCommandToRun

  ' Set the Time Zone
  Set WshShell = WScript.CreateObject("WScript.Shell")
  If Err.Number <> 0 Then logRuntimeErr "Cuuld not create WScript.Shell instance",true,true

  ' Create command line
  sCommandToRun = "c:\windows\system32\tzutil /s " & chr(34) & TZ & chr(34)
  logInfo "sCommandToRun: " & sCommandToRun

  ' Run command
  WshShell.Run sCommandToRun

  ' Stop and Start the Time Service to take effect.
  WshShell.run "net stop w32Time",iHide, bWaitOnReturn
  wscript.sleep 500
  WshShell.run "net start w32Time", iHide, bWaitOnReturn

  set WshShell = Nothing

End Sub

Sub logInfo (sMsg)
    WScript.StdOut.WriteLine(Time & " - " & sMsg)
End Sub

Sub logRuntimeErr(sMsg,bclear,bQuit)
    WScript.StdOut.WriteLine("Error:" & sMsg)
    WScript.StdOut.WriteLine("|- No  :" & Err.Number)
    WScript.StdOut.WriteLine("|- Desc:" & Err.Description)
    WScript.StdOut.WriteLine("|- Src :" & Err.Source)

    If bClear Then Err.Clear
    If bQuit Then WScript.Quit(Err.Number)

End sub





From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Winter.Mary
Sent: 02 August 2011 15:52
To: 'gptalk@lists.gpoguy.com'
Subject: RE: [gptalk] wshShell.Run



I will create the wrapper. Thanks for your input.



From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Darragh O'Shaughnessy
Sent: Tuesday, August 02, 2011 9:44 AM
To: 'gptalk@lists.gpoguy.com'
Subject: RE: [gptalk] wshShell.Run



If I ever execute .vbs scripts in my gpos, I use a wrapper .cmd file like this





Contents of wrapper.cmd:



Cscript //nologo <myscript.vbs> > %tmp%\myscript.log



I usually have a flag at the top of my script that enables some logging to the console which in turn is dumped to the log file above for further analysis. Can you dump the script code itself?





From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Winter.Mary
Sent: 02 August 2011 15:40
To: 'gptalk@lists.gpoguy.com'
Subject: RE: [gptalk] wshShell.Run



Sorry Darragh,

I don’t know why. GPresult shows that the GPO has been applied but the script does not run and there are no errors for it in the event log. In fact for all of my startup scripts I get the line: LastExecuted: This script has not yet been executed.

This is not true though because the other two scripts do run. Neither of them uses wshShell.run.

Mary



From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Darragh O'Shaughnessy
Sent: Tuesday, August 02, 2011 9:18 AM
To: gptalk@lists.gpoguy.com
Subject: RE: [gptalk] wshShell.Run



You could use the ‘.exec’ method but we need more detail. Why does it not run as a group policy?



From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Winter.Mary
Sent: 02 August 2011 15:13
To: gptalk@lists.gpoguy.com
Subject: [gptalk] wshShell.Run



I have seen this issue described on web forums but none of them has an answer published. Please forgive me if this has already been covered. I have a timezone.vbs script that tests to see what segment the PCs are on and sets the timezone. Some of our segments are in the Eastern time zone and others are in the Central time zone. The script needed to be updated because it used control.exe which does not work in Windows 7. Now it uses TZUtil. The script runs locally but will not run as a startup script through group policy. Several people reported this issue and some were pointed to the wshShell.Run command as the problem. My question, what would I use instead of this command to run TZUtil? Thank you in advance for your help.



Mary Winter
IT Infrastructure Consultant
Desktop Services


MaryWinterUser is Offline

Posts:45

08/02/2011 8:00 PM  
Yes they are defined globally. Thanks for your help. I’ll let you know how my testing goes.

From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Darragh O'Shaughnessy
Sent: Tuesday, August 02, 2011 10:29 AM
To: 'gptalk@lists.gpoguy.com'
Subject: RE: [gptalk] wshShell.Run

I would adjust the script as below (added some logging to help debug). Also, are the following variables defined globally as you use them in the subroutine?


· iHide

· bWaitOnReturn

________________________________

'----------------------------------------
' Update the Time Zone.
'----------------------------------------
Sub UpdateTimeZone(TZ)
  On Error Resume Next

  Dim sCommandToRun

  ' Set the Time Zone
  Set WshShell = WScript.CreateObject("WScript.Shell")
  If Err.Number <> 0 Then logRuntimeErr "Cuuld not create WScript.Shell instance",true,true

  ' Create command line
  sCommandToRun = "c:\windows\system32\tzutil /s " & chr(34) & TZ & chr(34)
  logInfo "sCommandToRun: " & sCommandToRun

  ' Run command
  WshShell.Run sCommandToRun

  ' Stop and Start the Time Service to take effect.
  WshShell.run "net stop w32Time",iHide, bWaitOnReturn
  wscript.sleep 500
  WshShell.run "net start w32Time", iHide, bWaitOnReturn

  set WshShell = Nothing

End Sub

Sub logInfo (sMsg)
    WScript.StdOut.WriteLine(Time & " - " & sMsg)
End Sub

Sub logRuntimeErr(sMsg,bclear,bQuit)
    WScript.StdOut.WriteLine("Error:" & sMsg)
    WScript.StdOut.WriteLine("|- No  :" & Err.Number)
    WScript.StdOut.WriteLine("|- Desc:" & Err.Description)
    WScript.StdOut.WriteLine("|- Src :" & Err.Source)

    If bClear Then Err.Clear
    If bQuit Then WScript.Quit(Err.Number)

End sub


From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Winter.Mary
Sent: 02 August 2011 15:52
To: 'gptalk@lists.gpoguy.com'
Subject: RE: [gptalk] wshShell.Run

I will create the wrapper. Thanks for your input.

From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Darragh O'Shaughnessy
Sent: Tuesday, August 02, 2011 9:44 AM
To: 'gptalk@lists.gpoguy.com'
Subject: RE: [gptalk] wshShell.Run

If I ever execute .vbs scripts in my gpos, I use a wrapper .cmd file like this


Contents of wrapper.cmd:

Cscript //nologo <myscript.vbs> > %tmp%\myscript.log

I usually have a flag at the top of my script that enables some logging to the console which in turn is dumped to the log file above for further analysis. Can you dump the script code itself?


From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Winter.Mary
Sent: 02 August 2011 15:40
To: 'gptalk@lists.gpoguy.com'
Subject: RE: [gptalk] wshShell.Run

Sorry Darragh,
I don’t know why. GPresult shows that the GPO has been applied but the script does not run and there are no errors for it in the event log. In fact for all of my startup scripts I get the line: LastExecuted: This script has not yet been executed.
This is not true though because the other two scripts do run. Neither of them uses wshShell.run.
Mary

From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Darragh O'Shaughnessy
Sent: Tuesday, August 02, 2011 9:18 AM
To: gptalk@lists.gpoguy.com
Subject: RE: [gptalk] wshShell.Run

You could use the ‘.exec’ method but we need more detail. Why does it not run as a group policy?

From: gptalk-owner@lists.gpoguy.com [mailto:gptalk-owner@lists.gpoguy.com] On Behalf Of Winter.Mary
Sent: 02 August 2011 15:13
To: gptalk@lists.gpoguy.com
Subject: [gptalk] wshShell.Run

I have seen this issue described on web forums but none of them has an answer published. Please forgive me if this has already been covered. I have a timezone.vbs script that tests to see what segment the PCs are on and sets the timezone. Some of our segments are in the Eastern time zone and others are in the Central time zone. The script needed to be updated because it used control.exe which does not work in Windows 7. Now it uses TZUtil. The script runs locally but will not run as a startup script through group policy. Several people reported this issue and some were pointed to the wshShell.Run command as the problem. My question, what would I use instead of this command to run TZUtil? Thank you in advance for your help.

Mary Winter
IT Infrastructure Consultant
Desktop Services
You are not authorized to post a reply.
Forums >GPTalk >GPTalk Mailing List > [gptalk] wshShell.Run



ActiveForums 3.7

Members

MembershipMembership:
Latest New UserLatest:carmicklec
New TodayNew Today:1
New YesterdayNew Yesterday:1
User CountOverall:1399

People OnlinePeople Online:
VisitorsVisitors:0
MembersMembers:0
TotalTotal:0

Online NowOnline Now:

Ads

Banner Inv
Copyright 2009 by GPOGUY.COM
Terms Of Use