none
VBS Script is not executing the batch file RRS feed

  • General discussion

  • I have created a vbs script that  schedules a task to execute a batch file daily.The task gets scheduled but the batch file does not gets executed

                


    Function DeleteLogFiles
     Dim sDomainUserName, sCommand, iReturn

      On Error Resume Next
      LogDetail("Start: Function DeleteLogFiles")
      'sDomainUserName = "s-" & Mid(sComputerName, 3,4)
      sCommand = "SchTasks.exe /delete  /f /TN " & chr(34) & "DeleteLog" & chr(34)
      LogDetail(sTab & "Deleting old DeleteLog task.")
      iReturn = oWShell.Run(sCommand,7,True)
      If iReturn <> 0 Then
    LogDetail(sTab & "ERROR! An error " & iReturn & " occurred while deleting the old task.")
    bCriticalErrors = True
      End If
    LogDetail(sTab & "This is a server, using s_GnightSrvr.ini")
    sCommand = "SchTasks.exe /create  /RU " & sScheduledTaskUser & " /RP " & sScheduledTaskPassword & " /SC Daily /TN " & chr(34) & "DeleteLog" & Chr(34) & " /TR " & chr(34) & "C:\winstore\apps\DeleteLog.bat" & Chr(34) & " /ST " & sNextDeleteTime & " /SD " & sNextDeleteDate 
      LogDetail(sTab & "Re-creating DeletLogFiles scheduled task.")
      iReturn = oWShell.Run(sCommand,7,True)
      If iReturn <> 0 Then
    LogDetail(sTab & "ERROR! An error " & iReturn & " occurred while re-creating the new task.")
    bCriticalErrors = True
      End If
      On Error goto 0
      LogDetail("End: Function DeleteLogFiles")
     End Function

    This is the function of the vbs script

     
    • Changed type Bill_Stewart Tuesday, May 8, 2018 6:24 PM
    • Moved by Bill_Stewart Tuesday, May 8, 2018 6:24 PM This is not "scripts on demand"
    Friday, March 9, 2018 4:54 AM

All replies