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

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?
Hello, All.

I need to subtract time.
My output is the following format.

Time of Video = 01:30:00
Time played    = 00:07:17

I tried the accepted code from this post here. VBScript Time difference

I THINK I am using it correctly.
So, I tried the following.

theMTS = "00:07:17"
TTime = "01:30:00"


Open in new window

Output SHOULD be: 01:22:43

I get the following error.

Microsoft VBScript runtime error '800a000d'
Type mismatch: 'Cint'
/media/test2.asp, line 96

This is the line 96
BegTime = Cint(iStart)

Here is the code from the above-mentioned page.

Function SubtractTimes(iStart, iEnd)
' Given the following input values...
'    @TimBeg = 0815
'    @TimEnd = 1000
' the result should be 0145

Dim BegTime  ' Beginning time converted to an integer
Dim EndTime  ' Ending    time converted to an integer
Dim BH       ' Beginning hour converted to minutes since midnight
Dim BM       ' Beginning mins
Dim BT       ' Beginning time in minutes since midnight
Dim EH       ' Ending hour converted to minutes since midnight
Dim EM       ' Ending mins
Dim ET       ' Ending time in minutes since midnight
Dim TM       ' Total minutes in interval
Dim IH       ' Interval hours
Dim IM       ' Interval mins
Dim IT       ' 

Open in new window

I have an Excel spreadsheet populated with data only in column A. The number of rows vary.
Each cell in column A (A1, A2, ...) is filled with a text that starts with a number appended with a text string.
Eg: A1 = "102heaven"; A2 = "56flower"....
I need a macro that will put the number in column B and the text in column C
A1="102heaven" --> B1 = 102 and C1 = "heaven"
Hey Everyone,

I'm looking to create an Access 365 sub that does the following things:

1.)  Creates a Folder
2.)  Exports the results of a query to that folder in a .txt tab delimited format
3.)  Copies a file from the C drive to this folder
4.)  Zips the folder

I'm a novice with coding in general so I'm being stopped at step 2.  My code to create the folder is:

Dim rstemp As String
rstemp = "//SharedDrivePath/" & Me.OrderID.Value & ".FlowerOrder"
If Dir(rstemp, vbDirectory) = "" Then MkDir rstemp

Open in new window

That seems to work well

The query I want to export is based on a single table.  So getting the query to work is easy, but exporting as a .txt file has tripped me up.  Everything I try fails.

Here is an example table:
I've also attached that example table here as an excel sheet.

This is my basic select query with some slight formatting:

SELECT [FlowerName] & "_" & [Color] AS Flower_Color, Format([SproutDate],"yyyy/mm/dd") & "_" & Format([SproutDate],"hhnn") AS FormatSproutDate, FlowersTable.ScanCode, FlowersTable.FrostDate
FROM FlowersTable;

Open in new window

The resulting query looks like this:
If anyone could help me with this I would really appreciate it.  Thank you and have a wonderful day.
NOTE : This is a follow up question from : https://www.experts-exchange.com/questions/29139469/Macro-to-convert-data-in-txt-into-excel-format.html?headerLink=workspace_answered_questions

Instead of having 1 set of data, i have multiple sets basically the structure is repeated several times.

Currently i am pasting the text file individually by transferring the multiples into 1 .txt file each so that the macro can read all the txt files and convert them to data in excel.
How to have a macro to also read text files with several repeated structure ?

See attached file. In this file, you can see that the structure appear 3 times.
Excel: Create new Sheet, parse heading into column against content of that column.

Example excel worksheet contains Sheet 1 with Columns A B C as address columns and intermittent rows containing contents under different headings in about 50 more columns.
Copy content to Sheet2 as per: For each column from Column D to Column BB, where a row contains content, copy the address row for Columns A B and C, plus the content from the row for the column, and add the column heading into the adjacent cell on the same row as per the example in Sheet 2.

PowerShell drag and drop, then hash the file that was dropped onto the form.
I can't figure out where to add something like "$fileHash = Get-FileHash -path $file -A SHA256" and then append to the file path.
The code below shows the file path when dragging a file, I want to hash that same file and add it's hash to the end
c:\some\file\path\here.txt, F70363B8AE41B113AC96F9762DB46262B8F436B29A4B7D1E2A3ADAB101E75299
I may further call a VirusTotal API call to look the hash up and append more info on the end later.
Right now all I need is the hash of the file(s) that get drug onto the form.

$Form1 = New-Object System.Windows.Forms.Form
$Form1.ClientSize = "391, 190"
$Form1.TopMost = $true
$TextBox1 = New-Object System.Windows.Forms.TextBox
$TextBox1.Anchor = "Top,Bottom,Left,Right"
$TextBox1.Location = "12, 12"
$TextBox1.Multiline = $true
$TextBox1.ScrollBars = "Both"
$TextBox1.Size = "368, 166"
$TextBox1.AllowDrop = $true
function FNprocess( $object ){
  foreach ($file in $object.Data.GetFileDropList()){

Open in new window

Hello experts,

I have the following procedure:
' File I/O constants
Const ForAppending = 8

'Create the file system object
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Define folders and files to work with
strScriptDir = objFSO.GetParentFolderName(objFSO.GetFile(Wscript.ScriptFullName))
strLogFile = strScriptDir & "\log-copy.txt"
strStamp = TimeStamp(Now)
arrFolders = Array(ScriptDir)
strFromFolder = ""          ' Do not add trailing "\" to this variable
strToFolder = strScriptDir  "\Backups" ' Do not add trailing "\" to this variable
blnFolders = True
arrSkipFolders = Array("")

' Open log file for appending
Set objLog = objFSO.OpenTextFile(strLogFile, ForAppending, True)

' If the csv backup folder does not exist create it
strToPath = strToFolder
If Not objFSO.FolderExists(strToPath) Then
   objLog.WriteLine Now & " INFO: Created folder """ & strToPath & """."
End If

' Create a folder for todays backups
strToPath = strToPath & "\" & strStamp
If Not objFSO.FolderExists(strToPath) Then
   objLog.WriteLine Now & " INFO: Created folder """ & strToPath & """."
End If

' Loop through all folders, backup files
For Each strFolder in arrFolders
   BackupFilesFolders strFolder, blnFolders

' Wrap up

Wscript.Echo Now & " :" & vbCrLf & "Program has completed all the actions successfully"

' Process folder
Sub BackupFilesFolders(strPath, blnFolders)

   ' If the input 

Open in new window

Greeting Experts

I need to create a script to get a list of users in the Local Administrators Group on remote work stations. The script just needs to remote into each workstation using a text file with a list of device names and gather the names & Groups who are in the local Administrators Group in each pc.... Can somebody help me with this issue...
Excel ID rows in Column A are intermittently repeated.  The request is for a script to sum the repeated values in Column B and copy ID and total to Column D and E as per manual example in attached file.

Greetings Experts!

Working with vbscript and a limited (but growing, thanks to help received here!) knowledge of XML files, I'm trying to create a function that totals the quantities of materials issued to jobs by lot, bin, and serial number.  My XML file contains both material allocations (i.e. materials needed but not yet used) and material postings (i.e. specific information about materials that have been used).

In words, here’s what I’m trying to do:

For each material allocation, check to see whether the allocation has been completed. If it has not been completed, extract some information about the allocation from the XML and store it in a variable.  If it has been completed, look in the material postings and total up the quantities posted by lot, bin location, and serial number then store only those postings where the total quantity is not zero in the variable.

My latest attempt at this involved loading the material postings elements into an array and looping through that looking for lots that match the current lot and adding up the quantities. It kinda works but this will certainly take too long when my BOM has 500 items on it instead of 5 items.  Code shown here for context.

' create array of material postings
Dim arrMaterialPostings
arrMaterialPostings = BuildMaterialPostings(StockCodeSelection.CodeObject.Job)

Dim objDom, objAllocationsList, Counter, MyXML, objSerialNode, objBinNode, strBin, strSerial, EmptyXML
Dim objNodeList2, Counter2, 

Open in new window

I want to copy the application installation file or a vbs script on a share created on a file server.

on my workstation I want to have a text file with computer names in txt or csv format.

want to use a tool like psexec that executes a command on the remote computer

run the application or the vbs file on all the computers listed in the text file.

clients are windows 7 sp1

appreciate help
Hi Experts,

I have a report exported to Excel that contains info with headers and details.

looking to write a script that will just obtain all details along with the name portion of the header.

Purpose of this, to export all this into a SQL table.

See example attached.
Dear Experts,

I have the target to open all the existing .xls so Excel files in a certain folder through VB Script.

Actually found the following code which looks promising straightly providing that:

Set objFolder = objFSO.GetFolder("D:\Test")
For Each objFile in objFolder.Files
   If LCase(Right(objFile.Path, 4)) = ".xls" Then
      'do something
   End If

Open in new window

although pasting that code to a file with .vbs extension and double clicking on it, it brings VBScript runtime error:

Object required: 'objFSO'

Could you please advise how to fix that, eventually having some other code which could provide the same target?

Thanks in advance,

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.