VB Script





VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.

Share tech news, updates, or what's on your mind.

Sign up to Post

we have some remote PCs that contain users outlook pst files.

is there any script (powershell, wmic, vbs, etc) to get for each user in that remote PC , the path of the pst files mounted in Outlook (2010, 2013, 2016)?
I have a spreadsheet that has 2 TABS, SCCM DATA and RAW DATA, both have Source Computer (Column A) and Migration Status (Column F), everyday I copy the raw data over from SCCM to RAW DATA, after I copy the raw data from SCCM, I would like a Macro to compare the Source computer info on RAW DATA with SCCM DATA, if the Migration Status is different, then copy the updated Migration Status to SCCM DATA.

For Example: SCCM DATA                                                  For Example: RAW DATA
Source Computer     Migration Status                             Source Computer             Migration Status
Xhostname                 Not Started                                      xhostname                       completed

so what I need is the macro to do is update the migration status of SCCM DATA with the RAW DATA Migration Status. If there is no change then do nothing.

Thank you in advance.
I am looking for a batch, VB or Powershell script that can parse a file name for a date, and then delete that file if the Date is older than 90 days. Files will be in subfolders, so the script would need to be able to drill down into the subfolders.
Here example of file names:

Hello experts,

I am looking for a batch, powershell or vbscript to cover the following requirement:

-Loop a reported folder with drill down
-Check the various files and folder
-Replace SourceString by TargetString
-SourceString and TargetString should be reported as parameter

BaseDir= C:\Test
SourceString= “_”
TargetString “-“

-Various files and folders which contains source string “_” should be replaced by target  “-“.

If you have questions, please contact me.
Thank you.
Hello experts,

I am looking for a batch, powershell or vbscript to cover the following requirement:

Loop a reported folder (no drill down needed):
-Rename the various files with reported folder name and add a numbering based on modified date from oldest to newest
BaseDir= “C:\toto” contains filea.csv filea.xls fileb.csv
Expected result is the following:
toto-1.csv, toto-2.xls, toto-3.csv

If you have questions, please contact me.
Thank you.
I am experiencing an SQL 2014 Job Package that is not connecting to MS Access when the package is either scheduled or manually running it. The package connects and runs fine when I developed it in VBS with no errors. The package dtsx was deployed to SSIS in the Integration Services Catalog SSISB.

Connection String value:  Data Source=\\xxxx\xxxx\xxxx\Databases\Mmaster.mdb;Provider=Microsoft.Jet.OLEDB.4.0;
Server Name:  \\xxxx\xxxx\xxxx\Databases\Mmaster.mdb
UserName: admin
Password: [left blank as there is no mdw and the mdb is not password protected]
InitialCatalog: NULL
RetainSameConnection: False

These are the Connections available through the Connection Manager, once I select the OLEDB, then I selected the Microsoft Jet 4.0 OLE DB Provider. It tests and connects with VBS, just not in the SSIS Server Agent Jobs.
Connections-1.jpg Connections-2.jpg
Hello Experts,

I'd like to create a list of available dates for employees in excel. We're working on a project and I'm trying to group departments together on the dates they'll be in the office.

I've attached a spreadsheet with an example but need the formula to put it all in place - if not a formula maybe it needs VB code to get it to work as desired?

- I have the dates employees will NOT be available (Unavailable Dates in attached spreadsheet)
- I have a Holidays tab to list Holidays where no one will be available
- I have a weekday calendar that lists all the days of the week

The available dates (Available Dates tab in the spreadsheet) will be produced by looking at the weekday calendar and excluding Dates Unavailable and Holidays. At least that's what I need it to do. Once I get that part working, I can do a pivot table to group the departments on their available dates.

 I hope it all makes sense, thanks!
Hi guys

I'm trying to come up with an effective way of creating a budget planning system that gives myself and the directors an idea of where we are on the project in comparison with the percentage of the budget spent.

Let's say we have signed off £100,000 for a project. We start the project and by the time 20% of the project is completed, we have burned through 50% of the budget already which, which could well be a disaster.

So two things I'm asking is:

a. Is there a way that you could apply a weighting system which would in turn give you an idea of how much of the project is done? Basically, a way of measuring the percentage of the project that has been completed/incomplete through entering data in necessary fields/excel sheets.

b. Is there a way of using the budget given to do some sort of comparison with the percentage of project completed, so that you could get an idea of what percentage of the budget we have gone through in comparison to the percentage completion of budget.

All of this would ideally be done in Excel.

Does this make sense? If it does, any input would be great. Perhaps you do it a different way and it has helped you and that input may help a lot too.

Thanks for helping

We currently have a scheduled task that runs a script daily. This script is used to synchronise multiple AD security groups with the Adobe cloud. At the moment we have multiple security groups such as Adobe_Photoshop, Adobe_Indesign, etc. When a member of staff is added anyone of these security groups they are allocated a licence the next time the sync occurs. Obviously we can run this hourly but we don't want to run the script that often as it takes time.

Does anyone know how we could monitor security groups for a change and when a change occurs kick off a script? This was we can ensure that we allocate licences to our team without delay.

I have the following macro and im trying to run but it keeps coming up excel not responding and closes down.

In the folder im trying to copy I just realised I don't need the whole workbook copying but only the sheets called  "Period Summary" and "Sheet 1"

How do I amend this?

Sub test()
Dim sName As Variant, bFolder As String, dest As String

sName = InputBox("Subfolder name")
If sName = "" Then Exit Sub

bFolder = "X:\backup"

If Dir(bFolder & "" & sName, vbDirectory) = "" Then
MkDir bFolder & "" & sName
End If
dest = bFolder & "" & sName & ""


End Sub
Hello experts,
I have the following vbscript that help me to move files based on extension.
I got an out of memory error message when I launch the script and one of the reported folder doesn't exist.
I think the makedir function needed to be adjusted but I don't know how to proceed.
' ==============================================================================
' C O N S T A N T S   &   V A R I A B L E S
' ==============================================================================

' Define needed constants
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const TriStateUseDefault = -2

' Specify path to folder of files to process, default destination, and log file
strScriptDir = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
strBaseDir = strScriptDir
strLogFile = strScriptDir & "\log-file.log"

' ==============================================================================
' I N I T I A L I Z A T I O N
' ==============================================================================

' Create filesystem object
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Open log file (append)
Set objLogFile = objFSO.OpenTextFile(strLogFile, ForWriting, True)

' Make sure base directory exists
If Not objFSO.FolderExists(strBaseDir) Then
    objLogFile.WriteLine Now() & " *ERROR* Base directory does not exist """ & strBaseDir & """"
End If

' Create a dictionary to hold the list of extensions to move, and destination 

Open in new window

Hello experts,
I have .txt file (sub-procedures) in which I reported the various sub procedures that I use in my personal macro.
I listed the various procedures names in .csv file (procedures-listing)
I need a script that:
-Create the various txt files reported in csv file column b group
-Transfer procedure sub till end sub text based on the group related
-Create a txt files with the following name “Unknown-group” and transfer sub till end sub for procedures which are not reported in csv file with a related group
-Dummy files attached.
If you have questions, please contact me.
Thank you very much for your help.
In my application Splash Screen loads at the same time with my startup form. I don't know what is causing that my splash screen vb code like below. And also i took and screenshot from application settings.

Option Explicit On
Option Strict On

Public NotInheritable Class SplashScreen1

    'TODO: This form can easily be set as the splash screen for the application by going to the "Application" tab
    '  of the Project Designer ("Properties" under the "Project" menu).

    Private Sub frmSplashScreen_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Set up the dialog text at runtime according to the application's assembly information.  

        'TODO: Customize the application's assembly information in the "Application" pane of the project 
        '  properties dialog (under the "Project" menu).

        'Application title
        If My.Application.Info.Title <> "" Then
            ApplicationTitle.Text = My.Application.Info.Title
            'If the application title is missing, use the application name, without the extension
            ApplicationTitle.Text = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
        End If

        'Format the version information using the text set into the Version control at design time as the
        '  formatting string.  This allows for effective localization if desired.
        '  Build and revision information could be included by using the following 

Open in new window

Good Day,
Can you please help,
I'm searching for a script (batch, Vbs, PowerShell), to login to a remote ftp, (User Name & Pwd)
delete ,bak files older than XXX days.

I Don't have access to run any scripts on the remote ftp server.
I need to run the script from my computer.

Your help is greatly appreciated.
Most PCs/laptops (they're old models of Dell & Thinkpad X and T series) we have do not have BIOS password set:
is there a way to remotely set the BIOS password (for the 1st time) without physically accessing the PCs/laptops?

We have Desktop Central that could spawn a command prompt (owned by SYSTEM) to all PCs/laptops or get a
GUI login (Desktop Central agent on endpoints) but we've removed PowerShell from the PCs/laptops.

VBscript can still run (though I ack VB is a vulnerability too).
I want to modify the Macro script to remove any value from my "Final" in the Excel file attached.
I simply created a stored procedure that inserts data from an ASP page. I keep getting an error message "Failed to convert parameter value from a string to a boolean".
My Stored Procedure is
ALTER PROCEDURE [Merch].[MyStoredProcedure]
	@Suppint Varchar(50),
	@VendorCode Varchar(10),
	@classgroupAllocID Varchar(10),
	@Season Varchar(4),
	@quarter Varchar(50),
	@Month Varchar(50),
	@DateAllocated Date,
	@StyleCreated Varchar(5),
	@Category VARCHAR(50)
	INSERT INTO [Merch].[PurchasOrder] (Suppint,VendorCode,classgroupAllocID,Season,[quarter],CreateDate)
	VALUES (@Suppint,@VendorCode,@classgroupAllocID,@Season,@quarter,GETDATE());
	INSERT INTO [Merch].[purchasOrder2](POID,[Month],DateAllocated,StyleCreated,EDIT,Category,CreatDate) VALUES (@POID,@Month,@DateAllocated,@StyleCreated,@EDIT,@Category);

Open in new window

My vb code to take my web page objects into my sql server is the following.
        Dim strConnString As String = ConfigurationManager.ConnectionStrings("MerchData").ConnectionString
        Dim con As New SqlConnection(strConnString)
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "[Merch].[MyStoredProcedure]"
        cmd.Parameters.Add("@Suppint", SqlDbType.VarChar).Value = ddlSupplier.Text.Trim()
        cmd.Parameters.Add("@VendorCode", SqlDbType.VarChar).Value = tbsuppliercode.Text.Trim()

Open in new window

I have a the following dir structure


not all areas have the same years inside
not all years have the same months (some months have no data so no month dir is created for those)
if there is a month directory it means it contains a pdf inside it

sample dir:

I need a script batch,vb or powershell or python whatever
that will help me create the following HTML TABLE

     ford   chevy   toyota
Jan   x       x
Feb   x

The X should be an html link to the PDF, but I can do this with search / replace for the X so the main objective is to generate the table code.

I cannot change the directory structure
If you have a solution using csv file with excel and pivot tables it is also acceptable (so i can then use some text manipulating functions to get my desired html)

I have tried with some dir to html utils but they are very
limited and I end up with many tables that then I have to manually stitch together

Please Help
Hi all, I'm trying to make a program that picks up scanner codes from a hand scanner device that's plugged into a USB port on a Windows PC.  I'm writing it in Visual Basic 6 because it's still my favorite program for making quick apps like this.  The hand scanner just sends the string of text that's in the code to the PC, and it sends it very fast.  To start out, I made a pretty simple program just to see if it's possible to catch all the characters fast enough and I'm having trouble with that part.  It seems to grab random characters and I can't go lower than 1 ms on the timer.  

I need it to be able to grab the characters from the keyboard buffer even if it's not the program that's in focus so I used the GetAsyncKeyState function from windows api.  Here is my form code that isn't catching all of the characters:

Option Explicit

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

Private Sub Command1_Click()
    Label1.Caption = ""
End Sub

Private Sub Timer1_Timer()
    Dim nKey, nChar As Integer
    Dim nText As String
    For nChar = 16 To 255
        nKey = GetAsyncKeyState(nChar)
        If nKey = -32767 Or nKey = -32768 Then
            nText = CStr(nChar) + " "
            Label1.Caption = Label1.Caption + nText
        End If
End Sub

Open in new window

All I have on the form are a label, buttons, and timer with a 1 ms interval. The label1 will show a few random character codes from the code after I scan one. Does anyone have advice for making it catch all the characters from the hand scanner?  I also tried it with GetKeyState and it had the same problem.
I want to VBA code to encrypt the password/serial number saved in a column with a specific number.
for example if password is abc I will add a number to it I want to save it as abc+that number not the real password.
When I click on decrypt I want a popup to enter the number I added while saving.
Finally remove the number should give the correct passwords
I have the following in VB that creates an Excel file and places it in a folder:

DoCmd.OutputTo acOutputTable, "Data2", acFormatXLS, "C:\Feeds\Data2Export" & "\Data2-" & SuppID & ".xls", False

I need to convert that so it creates a tab delimited csv file instead. How to do that?
Trying to convert VB code to C#. Never really worked with C#. It's just taking a pulling the information from a JSON file so I can upload to a database. Have in VB but want to switch to C#. Below is the VB code:

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim filePath As String =
            IO.Path.Combine(_desktop, "Upload.txt")

        Dim data As Upload =
            JsonConvert.DeserializeObject(Of Upload)(IO.File.ReadAllText(filePath))
End Sub
Public Class Upload
        Public Property Primaryimage() As WebImage
        Public Property Secondaryimages() As List(Of WebImage)
        Public Property Notes() As List(Of String)
        Public Property SafetyPrecautions() As SafetyPrecautions
End Class
Class WebImage
        Public Property Alt() As String
        Public Property Src() As String
End Class
Public Class SafetyPrecautions
        Public Property Warnings() As List(Of String)
End Class

Open in new window

Might be all wrong but this is what I have for C#

public partial class frmProcessJsonFile : Form
        private string _desktop;
        public frmProcessJsonFile()

        private void Form1_Load(object sender, EventArgs e)
            string filePath = System.IO.Path.Combine(_desktop, "Upload.txt");

            Upload data = JsonConvert.DeserializeObject<Upload>(System.IO.File.ReadAllText(filePath));

        public class Upload
             public IEnumerable<WebImage> Primaryimage { get; set; }

        class WebImage
            public string Alt { get; set; }
            public string Src { get; set; }

Open in new window

Any help would be appreciated.
Trying to get an AutoHotKey script for copying from Excel.

Seems like the answer is in this link.


Where it resolved to just a single line of code in the end after about twenty iterations.

If you are just looking to trim the line feed off the clipboard content (like what you get after copying excel)

StringTrimRight, MyVar1, clipboard, 2

should store your string to MyVar1

However, don't know what the whole script should look like.


Looking to count the number of SQL records until a certain value in one of the table columns is reached. Using Asp /VBscript. Not sure how to formulate the query.

What I'd like is to organise the results by the column "points" in descending order, grouped by the "city_id". I then need the number of records counted until a specific "member_id" is matched. Some "points" values could also be the same, which can cause an incorrect count. Similar points values should be ignored.

the db table is named "rankings" and is structured like this:

id  |  member_id  |  city_id  |  points
1   |      1      |   12500   |    2
3   |      2      |   12500   |    5
4   |     34     |     800     |    1
5   |     14     |   12500   |    14
6   |      6      |     600     |    12
7   |     11     |   12500   |    11
8   |     12     |   12500   |    5

For example, if I want to find the ranking for member_id "2", who happens to belong to city_id "12500", the correct final returned value from should be 3. This is because member_id "2" has the third highest points value in city_id "12500", even after taking into account the tie in points with member_id "12".

This below is all I can think of as I'm not a pro by any means and I know it's missing a lot!

member_id = 2
city_id = 12500
SELECT Count() as city_ranking FROM (SELECT * from rankings WHERE city_id='"&city_id&"' AND member_id <> '"&member_id&"' ORDER BY points DESC)
Hello, All.

working on the last part of this project.
At least for the math anyway.

I have all my time in the database set as minutes.
90 = 1:30:00
So, what I need to do now, is convert the minutes into seconds.
90 = 5400

Everything I am finding is for the reverse.
Seconds into Minutes or hours.
Nothing for the opposite.

Any idea's on this one?

VB Script





VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.