Tag Archives: vbscript

VBScript to list shares and permissions in Windows OS

I thought that this would be an easy script to find, but surprising there are no complete script to be found. I found the following powershell script in the respository

It works and lists the shares, but it does not product the path of the share!

Found another helpful posts for VBScript version here:

It works but for some reasons the security permissions are not correct

The closest I find is this:

Works well BUT it again does not list the path of share. Why in the world would I not want to know where a share path is? Read the rest of this entry »


Posted by on February 27, 2013 in Scripts, VBScripts, Windows



VBScript to grab server names from a list of HP Blade enclosures

Challenge: How to get all blade’s server names (iLO name really) from a list of Enclosure’s IP address? This so far works only for HP Blade C series enclosure

set objArg = WScript.Arguments
if objArg.Count >= 4 then

  set WshShell = WScript.CreateObject("WScript.Shell")

  Encl_IP = objArg(0)
  Encl_Name = objArg(1)
  LogonID = objArg(2)
  LogonPWD = objArg(3) "telnet.exe -f .\" & Encl_Name & "_" _
   & Encl_IP & ".log " & Encl_IP
  WScript.Sleep 2000

  wshShell.AppActivate ("telnet.exe " & objArg(0))
  WshShell.SendKeys LogonID
  WshShell.SendKeys ("{Enter}")
  WScript.Sleep 1000

  wshShell.AppActivate ("telnet.exe " & objArg(0))
  WshShell.SendKeys LogonPWD
  WshShell.SendKeys ("{Enter}")
  WScript.Sleep 1000

  wshShell.AppActivate ("telnet.exe " & objArg(0))
  WshShell.SendKeys "SHOW SERVER LIST"
  WScript.Sleep 1500

  wshShell.AppActivate ("telnet.exe " & objArg(0))
  WshShell.SendKeys "exit"
  WshShell.SendKeys ("{Enter}")
  WScript.Sleep 1500

  wshShell.AppActivate ("telnet.exe " & objArg(0))
  WshShell.SendKeys ("{Enter}")

  Set fso = CreateObject("Scripting.FileSystemObject")
  set f = fso.OpenTextFile(".\" & Encl_Name & "_" & Encl_IP & ".log")

  Is_SOL = false  'Is start of line?
  SvrInfo = ""
  do while not f.AtEndOfStream
    t = f.readline
    if instr(t,"Bay iLO Name ") > 0 then
      t = f.readline
      t = f.readline
      Is_SOL = true
    elseif instr(t,"Totals:") > 0 then
      Is_SOL = false
      exit do
    end if

    if Is_SOL then  'grab server name from current line
      t = mid(t,5,29) & vbTab & Encl_Name & vbTab & Encl_IP
      SvrInfo = t & vbCrLf & SvrInfo
    end if



  set f1 = fso.OpenTextFile(".\ServerList.log",8,true)
  f1.Writeline SvrInfo


  Wscript.echo " "
  Wscript.echo "<encl. IP> <encl. name>  "
  Wscript.echo " "
  Wscript.echo "Log file for telnet session = <encl. name>_log.log"

end if
Leave a comment

Posted by on August 1, 2012 in Scripts, VBScripts


Tags: ,

VBScript: Convert/Split seconds to days, hours, minutes and seconds

This function converts the number of seconds to its day, hour, min and sec components. It returns a comma-delimited string in format “day,hour,min,sec”. You can use the split() function to extract it into an array, example, MyTime = split(SplitSec(449786), “,”)

Function SplitSec(pNumSec)
  Dim d, h, m, s
  Dim h1, m1

  d = int(pNumSec/86400)
  h1 = pNumSec - (d * 86400)
  h = int(h1/3600)
  m1 = h1 - (h * 3600)
  m = int(m1/60)
  s = m1 - (m * 60)

  SplitSec = cStr(d) & "," & cStr(h) & "," & cStr(m) & "," & cStr(s)
End Function
Leave a comment

Posted by on August 3, 2011 in Scripts



VBScript: comparing two files using dictionary object

Here is a VBScript function to compare 2 files and get the changes between them. The function will return a multi-line string with what was added, modified and deleted between the old and new file.

This function was initially developed for me to compare changes between an old and new input file in my script. I need to know which server was added or removed and which server had its parameters modified. The input files is a delimited file using “~” as a delimiter and contains 2 values in each line: “server name” & “parameter”. Read the rest of this entry »

Leave a comment

Posted by on May 6, 2011 in Scripts, VBScripts



Rightfax COM API using VBScript

This is something that you hardly can find on the internet nor off the rightfax vendor site. The main reason is that most of the programming is done by programmers using C or VB.Net or some programming framework. But as an administrator of RightFax servers, sometimes its good that I can fire up vbscripts to automate some reporting on my end. Read the rest of this entry »


Posted by on June 30, 2010 in VBScripts, Windows


Tags: ,

VBscript: Grabbing subfolders recursively

I was working on a script that needs me to grab a list of subfolders recursive off the user data area and found that vbscript language does not natively support a recursive function in its filesystemobject. So the first thing is to ask Mr. google who studiously brought up the pages I required. Obviously the Microsoft Scripting Center has the most referenced samples for this function.

Set FSO = CreateObject("Scripting.FileSystemObject")
ShowSubfolders FSO.GetFolder("C:\Scripts")
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
  Wscript.Echo Subfolder.Path
  ShowSubFolders Subfolder
End Sub

Sure this is a quick and easy sample, but most of the time, when we are looking for solution, we actually want to do something with the folders! I have seen many examples of how functions can be used and most of them are just simple and mostly useless immediately. Basically, if I want to display all subfolders in a folder, I don’t need to use vbscript, just “dir /b /s /a:d” will give me the same results! Read the rest of this entry »

Leave a comment

Posted by on May 4, 2010 in Scripts, VBScripts



VBScript: nth Day of the month

Recently I needed a function to calculate the nth day of the month, that is, first sunday, 2nd thursday, last friday, etc. I thought such functions would be easy to find in the internet, however, I couldn’t find a complete function and so decided to write one:

Apologise for the formatting, wordpress don’t like programming codes in their blogs Read the rest of this entry »


Posted by on December 24, 2008 in Scripts, VBScripts