Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A simple question for the brainy

Status
Not open for further replies.

GrimR

IS-IT--Management
Jun 17, 2007
1,149
ZA
If I put this at the top of a script
Code:
'RunLogonScriptOnceADay
'==========================================================================
Dim varToday, Verify, LastRunDate
Set WshShell = CreateObject("Wscript.Shell")
 
varToday = Weekday(Date)

Verify = "HKLM\SOFTWARE\MyInstallsAndFixes\"

 'Check if scan has run today and if so exit
On Error Resume Next
LastRunDate = WshShell.RegRead(Verify & "WhatYouWantToCallIT")
If LastRunDate =  cstr(Date) Then
      WScript.Quit
Else
     WshShell.RegWrite Verify & "WhatYouWantToCallIT",Date,"REG_SZ"
End If


Then there a bunch of code that goes here.
Can I then add this next part in the middle of the script to bypass this section for the next X number of days

Code:
'Now Create a registry value so if this is run it wont run again for a Month
'==========================================================================
Dim WshShell, varToday, Verify, LastScanDate, MsgText
 
Set WshShell = CreateObject("Wscript.Shell")
varToday = (Date)

Verify = "HKLM\SOFTWARE\MyInstallsAndFixes\"

'Check if scan has run today and if so Exit
On Error Resume Next
LastRunDate = WshShell.RegRead(Verify & "WhatYouWantToCallIT")

If DateDiff("d", LastRunDate, varToday) < 30 Then
   WScript.Quit
Else
  WshShell.RegWrite Verify & "WhatYouWantToCallIT",Date,"REG_SZ"
End If

MCITP:EA/SA, MCSE, MCSA, MCDBA, MCTS, MCP+I, MCP
 
Yes you can do that but you only need to add this portion of the code:
Code:
If DateDiff("d", LastRunDate, varToday) < 30 Then
   WScript.Quit
Else
  WshShell.RegWrite Verify & "WhatYouWantToCallIT",Date,"REG_SZ"
End If


I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Thanks, Mark it was you that made the code after all.

MCITP:EA/SA, MCSE, MCSA, MCDBA, MCTS, MCP+I, MCP
 
Yes, I recognized it as my CheckIfFixRun code from my FAQ. :)

Glad you are able to make use of it.

I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top