Results 1 to 8 of 8

Thread: Check date: If Wednesday run batch script

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2012
    Posts
    5

    Check date: If Wednesday run batch script

    Hi guys,

    We use avast adnm 4.8 and it has no shutdown scanning option.
    I have made a batch script to run Avast on shutting down.
    _________________________________________________________________
    @echo off
    shutwdown -a
    pushd "C:\Program Files\Alwil Software\Avast4"
    cls
    echo --------------------------------------------------------------
    echo Bezig met scannen, de computer wordt automatisch uitgezet...
    echo --------------------------------------------------------------
    aswcmd C: /m /*
    popd "C:\Program Files\Alwil Software\Avast4"
    shutdown -s
    _________________________________________________________________

    But I only want to scan the computers on wednesday. So if its not Wednesday computers must shutdown without scan.

    I need a script to check de current date and run if it's wednesday. I want to use this script as shutdown script. If it is possible with a batch script its also fine.

    Thanks in advance,

    e2e2

  2. #2
    Addicted Member
    Join Date
    Jul 2009
    Posts
    208

    Re: Check date: If Wednesday run batch script

    Use one of the techniques here - http://superuser.com/questions/90758...-in-batch-file

    Or convert your batch script to VBScript, then it's simply:

    Code:
    If DatePart("W",Date) = 4 Then
      'Wednesday
    End If

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2012
    Posts
    5

    Re: Check date: If Wednesday run batch script

    Quote Originally Posted by His Nibbs View Post
    Use one of the techniques here - http://superuser.com/questions/90758...-in-batch-file

    Or convert your batch script to VBScript, then it's simply:

    Code:
    If DatePart("W",Date) = 4 Then
      'Wednesday
    End If
    Hi,

    Tnx for your reply. I am new to VBscript.

    I look for a vbscript that check the date, if it is Wednesday start the batch script if not go shut down.

  4. #4
    Addicted Member
    Join Date
    Jul 2009
    Posts
    208

    Re: Check date: If Wednesday run batch script

    Try this as a Windows shutdown script (set in Group Policy), named scan.vbs for example.
    Code:
    Dim WshShell
    
    Set WshShell = CreateObject("WScript.Shell")
    
    If DatePart("W",Date) = 4 Then
      'Today is Wednesday, so run the virus scan
      WshShell.Run """C:\Program Files\Alwil Software\Avast4\aswcmd"" C: /m /*", , True
    End If
    That's all you need, because if this script is run on system shutdown it will exit (after the End If) and the computer will shut down.

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2012
    Posts
    5

    Re: Check date: If Wednesday run batch script

    Quote Originally Posted by His Nibbs View Post
    Try this as a Windows shutdown script (set in Group Policy), named scan.vbs for example.
    Code:
    Dim WshShell
    
    Set WshShell = CreateObject("WScript.Shell")
    
    If DatePart("W",Date) = 4 Then
      'Today is Wednesday, so run the virus scan
      WshShell.Run """C:\Program Files\Alwil Software\Avast4\aswcmd"" C: /m /*", , True
    End If
    That's all you need, because if this script is run on system shutdown it will exit (after the End If) and the computer will shut down.
    This is working perfect. Thank you very much !

    I want also that every computer that runs av create .txt file to network directory "\\server\avastlog". only on wednesday. How can i do that?

  6. #6
    Addicted Member
    Join Date
    Jul 2009
    Posts
    208

    Re: Check date: If Wednesday run batch script

    Sorry, I've no idea. Maybe look at what command line options your Avast provides.

  7. #7

    Thread Starter
    New Member
    Join Date
    Mar 2012
    Posts
    5

    Re: Check date: If Wednesday run batch script

    Quote Originally Posted by His Nibbs View Post
    Sorry, I've no idea. Maybe look at what command line options your Avast provides.
    I will. Thanks
    Last edited by e2e2; Mar 8th, 2012 at 11:07 AM.

  8. #8

    Thread Starter
    New Member
    Join Date
    Mar 2012
    Posts
    5

    Re: Check date: If Wednesday run batch script

    If a computer run's the script on Wednesday, i want that it creates a %computername*.txt file in a netwok map. In batch script i can to it with %computername%.txt, what code can i use it for VBS script?

    vb Code:
    1. Dim WshShell
    2.  
    3. Set WshShell = CreateObject("WScript.Shell")
    4.  
    5. If DatePart("W",Date) = 4 Then
    6.  
    7. Set objFSO = CreateObject("Scripting.FileSystemObject")
    8. Set objFile = objFSO.CreateTextFile("\\server\Avast Scan Log\%computername%.txt")
    9.  
    10.   'Today is Wednesday, so run the virus scan
    11.   WshShell.Run """C:\Program Files\Alwil Software\Avast4\aswcmd"" M: /m /*", , True
    12. End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width