Showing posts with label VBS. Show all posts
Showing posts with label VBS. Show all posts

Thursday, February 2, 2017

VBScript: How to Automatically Restart MySQL Server


Set WshShell = CreateObject("WScript.Shell" ) 
'Just Start Apache Server & MySQL Server
WshShell.Run """C:\xampp\apache\bin\httpd.exe""", 0, false
WshShell.Run """C:\xampp\mysql\bin\mysqld.exe"" --defaults-file=C:\xampp\mysql\bin\my.ini --standalone --console", 0, false
'Stop & Start MySQL Server
WshShell.Run """C:\xampp\mysql_stop.bat""", 0, false
WshShell.Run """C:\xampp\mysql_start.bat"" --defaults-file=C:\xampp\mysql\bin\my.ini --standalone --console", 0, false
Set WshShell = Nothing

Wednesday, February 1, 2017

How can I delete only PDF File from a folder using VBS

Option Explicit
Dim FileSystemObject, RootFolder, SubFolder, File
On Error Resume Next
 Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
 RootFolder = "C:\Users\PRITOM\Downloads"
 
 For Each File In FileSystemObject.GetFolder(RootFolder).Files
  If StrComp(Right(File.Path, 4), ".pdf", vbTextCompare) = 0 Then
   Wscript.Echo File.Path + " Deleted"
   FileSystemObject.DeleteFile File.Path, True
  End If
 Next
 
 For Each SubFolder In FileSystemObject.GetFolder(RootFolder).SubFolders
 Do
  If StrComp(SubFolder.Name, "management", vbTextCompare) = 0 Then
   Exit Do
  End If
  For Each File In FileSystemObject.GetFolder(SubFolder.Path).Files
   If StrComp(Right(File.Path, 4), ".pdf", vbTextCompare) = 0 Then
    Wscript.Echo File.Path + " Deleted"
    FileSystemObject.DeleteFile File.Path, True
   End If
  Next
 Loop Until True
 Next
On Error Goto 0