[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More


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

I would like to modify a CSV file found at ..

A sample of the data is found below.
However there could be thousands of lines.

"No of Items","4",""

I want to modify it using a Script so that it searches through the file and when it sees ZDG123, or any other numbers that I will specify in position 1, that it will take the Quantity showing and divide it by 1000, and then re-write the file with the correct changed data.   For example for line shown above as:  "ZDG123","525012","0",  it will then become:   "ZDG123","525.01","0"

Would this be possible, using a scipt?
Bootstrap 4: Exploring New Features
LVL 12
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

In a VB Script, I can get this line of code to open up my targeted app (assume for illustration purposes that 'app = "C:\Program Files (x86)\SomeAppFolder\SomeApp.exe":

     objShell.ShellExecute app

What's the syntax to add to the above line of code to open the 'app' with a target file (e.g. how to I get 'app' to execute on say  ' f = "C:\Users\MyName\Desktop\testfile.txt" '?

If used different variations such as the following with no success:
     objShell.ShellExecute app, , f, "open"  ' ONLY LOADS the app ... not the app with file 'f' already loaded ready for use

I have a client who has an application which involves a combination of VBScript and Access to download data from an FTP site and then process that data into multiple Access databases. I'm not happy with the way this was implemented but I'm stuck with it.

I received an email this afternoon which indicates that about 15-20 of the files that should have been downloaded and processed on Monday did not make it into the Access databases.

Indications are that something occurred on there servers which affected their authentication service.  Any chance that this would have affected ADO communications between the VBScript and the Access BE databases?  I'm not a huge fan of VBScript or ADO and don't use either often enough to know what will or will not affect them.

Hi Experts,

I have attached a VB Utility being regularly used by me. It is used to prepare some returns, where we input the data and the output is produced in the shape of some encrypted file format for onward submission. But it can also be used to prepare a correction return also. In that case we need to import a Consolidated file and then the return can be amended or extended.

What I presently do
--Download all the conso files

--Import the files one by one in above software.
>>Here we need to Select Form No (24Q / 26Q / 27Q / 27EQ).
>>Type of statement to be prepared is always "Correction".
>>Option to be selected "Import Consolidated File"

--Copy the data from the tabs and paste them in different sheets of Excel (Normally there are 3 Tabs, but data from 1st Tab is never copy pasted. There may be 4 tabs for the 24Q - 4th Quarter of a Financial year in which case the last 3 tabs are copy pasted)

Name of Tabs (from which data to be copied and pasted in Excel) in case of each Form
24Q >  Challan , Annexure I        (in case of 4th Quarter of FY tabs to be Copy pasted are Challan, Annexure I and Annexure II
26Q >  Challan , Annexure I
27Q >  Challan , Annexure I
2EEQ >Challan , Annexure I

Challan Data can be pasted in the same Excel Sheet for All Form Types, whereas for Annexure I and Annexure II, we need separate sheets for Each Form.

I wish some script (or anything like that even if that is in Excel) which can
why doesn't this work.? see attachment

Option Explicit
 Dim WithEvents IE As InternetExplorer

 Private Sub Form_Load()
 Set IE = New InternetExplorer
 IE.Visible = True
 IE.Navigate2 "www.google.com"
 MsgBox ""
 IE.document.getElementById("q").Value = "TEST"
 End Sub
I have a VB script that I want to adapt to remove a desktop link from the currently logged on user's Desktop.  It isn't working and I get no error messages - no nothing.

On Error Resume Next
Dim FSO, WSHShell, Regkey, Username, strFolder, UserPath, objShell

Set WSHShell = CreateObject("WScript.Shell")
RegKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\"
Username = WSHShell.RegRead(RegKey & "LastLoggedOnSAMUser")
Username = Mid(Username,7) 

Set FSO = CreateObject("Scripting.FileSystemObject")
UserPath = "C:\Users\" & Username 
strFile = "C:\Users\" & Username & "\Desktop\CMS Supervisor*.lnk}" 
if FSO.FileExists(strFile) = True then  FSO.DeleteFile DesktopPath & "\CMS Supervisor*.lnk"

Open in new window

I have a setup of 2 PC's connected in Master and Slave configuration through a network cable with Windows 7 OS on both PC's. I need to stop a exe program and do a replace of the corrupted files  in a saved location and restart the exe program through vbscript with progress bar.  Can someone help with a vbscript or guidance? I am not a programmer. The progress should be shown on the master

Thanks in advance,
Im trying to pin standard office 2013 items to the taskbar for a 2012 R2 RDS farm. After some extensive googling Ive managed to do it but the behaviour isn't what I was expecting:

I have a loopback policy in one GP applied and another GP to run the logon script for the user.

I have a logon script as below:

/timeout /t 5 /nobreak

cscript "\\DC1\NETLOGON\RDSTaskbar\pinitem.vbs" /item:"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013\Outlook 2013.lnk" /taskbar

/timeout /t 5 /nobreak

cscript "\\DC1\NETLOGON\RDSTaskbar\pinitem.vbs" /item:"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013\Word 2013.lnk" /taskbar

/timeout /t 5 /nobreak

cscript "\\DC1\NETLOGON\RDSTaskbar\pinitem.vbs" /item:"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013\Excel 2013.lnk" /taskbar

/timeout /t 5 /nobreak

cscript "\\DC1\NETLOGON\RDSTaskbar\pinitem.vbs" /item:"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013\PowerPoint 2013.lnk" /taskbar

/timeout /t 5 /nobreak

cscript "\\DC1\NETLOGON\RDSTaskbar\pinitem.vbs" /item:"C:\Program Files\Internet Explorer\iexplore.exe" /taskbar

Open in new window

which calls this:

' Windows Script Host Sample Script
' ------------------------------------------------------------------------
'               Copyright (C) 2009 Microsoft Corporation
' You have a royalty-free right to use, modify, reproduce and distribute
' the Sample Application Files 

Open in new window

Hi Bill,

You amended some code for me a few weeks ago which worked perfect.. see code below

Option Explicit

' Define files and folders to work with (NO TRAILING BACKSLASH)
Const cBaseDir = "b:\ee\ee29122035\files\[[DATE]]"
Const cControlFile = "b:\ee\ee29122035\list.csv"
Const cDelim = ","

' Text file I/O constants
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

' Declare global variables
Dim objFSO, strBaseDir, strControlFile, strDate
Dim arrControl, strControl, arrFields, i, arrTemp
Dim strOldName, strNewName, strOldPath, strNewPath

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

' Get date in YYYYMMDD format
strDate = Year(Now) & Right("0" & Month(Now), 2) & Right("0" & Day(Now), 2)

' Resolve file paths
strBaseDir = objFSO.GetAbsolutePathname(Replace(cBaseDir, "[[DATE]]", strDate, 1, -1, vbTextCompare))
strControlFile = objFSO.GetAbsolutePathname(cControlFile)

' Make sure base folder exists
If Not objFSO.FolderExists(strBaseDir) Then
    Wscript.Echo Now & " ERROR: Base folder does not exist - " & strBaseDir
End If

' Make sure control file exists
If Not objFSO.FileExists(strControlFile) Then
    Wscript.Echo Now & " ERROR: List file does not exist - " & strControlFile
End If

' Load csv file into array
With objFSO.OpenTextFile(strControlFile, ForReading)
    arrControl = Split(.ReadAll, vbCrLf)
End With

' Loop over each control record and process 

Open in new window

I need help with vbscript that can refresh a web page (  Internet Explorer and Firefox )
 I need to call it as a function whenever I want to refresh a webpage for IE or for Fire Fox
Exploring SQL Server 2016: Fundamentals
LVL 12
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Hi All
I have a simple vb script that opens IE window and navigates to a link:

Set oIE=createobject("internetexplorer.application")
Do While (oIE.Busy)
Wscript.Sleep 250
oIE.navigate "http://MyLink.htm"

Most of the time it works fine but sometimes I am getting "Invalid procedure call or argument" error on  oIE.navigate line
Is there anything I am doing wrong?

Below vbscript code (.VBS)  changes Date format of one of the date column (Date)  from to "mm/dd/yyyy"  to "dd/mm/yyyy" . when saved to Excel.

Row Number|Row Action|Department|Date
123456          |Insert          |Airlines         |05/12/2016
3456              |Update       |Engineering |10/31/2014
234234         |Insert          |Arts                |2015
452435         |Insert          |Design           |2016

' Define constants
Const cExcel7 = 51
Const xlContinuous = 1
Const xlEdgeBottom = 9
Const xlEdgeLeft = 7
Const xlEdgeRight = 10
Const xlEdgeTop = 8

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

' Files to work woth
strInputFile = objFSO.GetAbsolutePathname("C:\Users\sktneer\Desktop\Input.txt")
strInputExcelFile = objFSO.GetAbsolutePathname("C:\Users\sktneer\Desktop\Input.xlsx")
strOutputFile = objFSO.GetAbsolutePathname("C:\Users\sktneer\Desktop\output-23-10.xlsx")

' Read text file into array
With objFSO.OpenTextFile(strInputFile, 1)
    arrInput = Split(.ReadAll, vbNewLine)
End With

' Start Excel, create a new worksheet
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objexcel.Application.SheetsInNewWorkbook = 3
Set dwb = objExcel.Workbooks.Add
Set objSheet = dwb.Worksheets(1)

' Initialize row index
intRow = 0

' Process each line of input file
For Each strInput in arrInput

    ' Skip all blank lines
    If strInput <> "" Then
VBScript changes dates format upon converting .txt data  to .xlsx sheet.  Date format "DD/MM/YYYY" in Input.txt changes to "YYYY/MM/DD"  upon saved in excel sheet .


Row Number|Row Action|Department|DateOfService

123456          |Insert          |Airlines         |12/02/2016
563455          |Insert          |Engineering |24/12/2013
567897          |Insert          |Science         |01/12/2011
356434          |Update       |Airlines         |23/09/2013

Date format of DateOfService  (DD/MM/YYYY) changed to (YYYY/MM/DD) . Could you please help to resolve this issue in VBScript.

i.e DateOfService in output file converted to (YYYY/MM/DD).
I am looking to copy and paste data from one xlsx sheet to a new excel sheet using VBScripts . Could please some one help me using Vb script to paste exact contents from
excel-input.xlsx to a new excel excel-output,xlsx on sheet2   and rename sheet2 to DataSet.

Here is the

Name      age      gender      department      year
don                23      male      computer      2010
ptalakes       24      female      maths              2015
chang      28      male      arts                2016
prag      29      female      science              2018
tom               26      male      arts                      2017
john      27      female      sports              2018
simon      22      male      arts                      2018

Excel-Output.xlsx  (Rename sheet2 as data )
Name      age      gender      department      year
don                23      male      computer      2010
ptalakes       24      female      maths              2015
chang      28      male      arts                2016
prag      29      female      science              2018
tom               26      male      arts                      2017
john      27      female      sports              2018
simon      22      male      arts                      2018
How can I modify this script so that it pulls the BCC emails from a file, a text file for instance?

SubjectDate = InputBox("Date to be added to the subject:", "Enter date")
MailTo = "email1@gmail.com"
From = "mainemail@someprovider.com"
Subject = "This is a test " & SubjectDate
Body = "Hi, This is an VBScript to send email, Regards, User."
Username = "mainemail@someprovider.com"
Password = "passwordhere"
BCC = "email2@gmail.com"

Email MailTo, BCC, From, Subject, Body, Username, Password

Sub Email (MailTo, BCC, From, Subject, Body, Username, Password)
 Set objMessage = CreateObject("CDO.Message")
 With objMessage
  .Subject = Subject
  .From = From
  .To = MailTo
  .BCC = BCC
  .TextBody = Body
 End With
 With objMessage.Configuration.Fields
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.mail.com"
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "mainemail@someprovider.com"
      .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "passwordhere"
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
      End With

Open in new window

Hello everybody.

I've been dealing with a work that, unfortunately, will be in the hands of users with very poor expertise about Excel and pc.

The scenario is as follows. Every morning, before calling a macro (not discussed in this post) that produces a report, an user has to arrange some settings.
I have to "route" the user in the correct settings, exploiting dropdowns where it is possible and building a system of alerts highlighting incoherent choices.

As for me, I set up a VBA code in the sheet "Driver" - where the settings have to be arranged - consisting in a change event calling the macro update_driver at every change in the sheet.
Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("A2:J51")) Is Nothing Then Call update_driver

End Sub

Open in new window

With the help of dropdowns built with Data Validation List, I've taken some steps forward, but there is always something to arrange. So, I was wondering if my way is the right one.

Put in practical terms: in column A the user has to type the city where the brenchs are located, and, like I've written, could modify them every day (also deleting some of them). For every brench in column A, a closed choice YES/NO has to be made in column B and C (of course same row).

In column E the user has to type - or delete if necessary  - the agent's surname, in column F has to type the agent's code, and in column G has to make a closed choice YES/NO.
As you can see in attachment dd2, …
I have googled this one and despite numerous suggestions I have not succeeded and yet it seems so simple.
In visual studio community 2017 edition, I have a vb web application which includes an XML file of program settings which I do not want to embed, I want it to stay as an .xml file so the site's behavior can be altered without recompilation.
When I run the web application in debug , the output folder shows the web app DLL of the compiled web app and no XML file and the program fails to locate it.
The file is set to Copy to Output directory and I have tried Content, Additional Files, None, to no avail, it never copies.  If I copy the XML file to the output folder whilst in debug mode it works so the question is why does my XML file not copy to the output directory.
I have included the xml file at the top level of the project.  
What needs to happen for the web app to copy the XML file to the temporary debug iis express folder so my website can find it and work?
Thank you,
I am trying to post an  xml file to a website that uses https and TSL1.2 with the following vbscript.  I supsect the TSL1.2 requirement is casuing the failure point .  I do get back
error 80072EE6  "the url does use a recognized protocol"  .  The vbs code is as follows:

Dim xmlhttp

Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")

' Indicate that page that will receive the request and the
' type of request being submitted
xmlhttp.Open "POST", " https://xxxxx.xxxx.xxxxx.xxxxx/data.xml", False

' Indicate that the body of the request contains form data
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

' Send the data as name/value pairs
xmlhttp.send "Id=1&S=2"

Set xmlhttp = Nothing

Open in new window

Any thoughts
How to search pdf files for a key word like "Sticky" and report those pdf files with that key word. One example is attached.


PMI ACP® Project Management
LVL 12
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

This is to find out about 100+ Windows Servers in our production. All these servers were joined Windows AD domain.  We wanted to know on each individual server, what is the Windows Server version installed, CPU core and some other hardware information.

Do we need to have the administrative privileges? How about if we don't have the privilege? Would powershell manage to do the job?

Thanks in advance.
what commands in vbs will move files out from one folder to another?
What are the strings of commands in CUTEFTP to download all files found in a specific remote folder?
Either it can override all local files, or it should only download the latest files it finds which are not on the local folder.
I am looking to find out if there are Visual Basic Scripts to pull the last time the group policy was updated in the registry.    I have see an example for this in PowerShell, just not in Visual Basic scripting.
I have converted a java program to VB program.

After converting, When I am trying to run the program, I am getting some errors. Please suggest if any help

Imports java.io.File
Imports java.io.FileNotFoundException
Imports java.io.FileOutputStream
Imports java.io.IOException
Imports java.sql.Connection
Imports java.sql.DriverManager
Imports java.sql.ResultSet
Imports java.sql.ResultSetMetaData
Imports java.sql.SQLException
Imports java.sql.Statement
Imports java.text.SimpleDateFormat
Imports java.util.Calendar
Imports java.util.LinkedHashMap
Imports java.util.Map
Imports java.util.Set
Imports java.util.TimeZone
Imports javax.activation.DataHandler
Imports javax.activation.FileDataSource
Imports java.util.Star
Imports javax.mail.Star
Imports javax.mail.internet.Star
Imports javax.activation.Star
Imports javax.mail.Session
Imports javax.mail.Transport
Imports org.apache.poi.hssf.usermodel.HSSFCell
Imports org.apache.poi.hssf.usermodel.HSSFCellStyle
Imports org.apache.poi.hssf.usermodel.HSSFFont
Imports org.apache.poi.hssf.usermodel.HSSFRow
Imports org.apache.poi.hssf.usermodel.HSSFSheet
Imports org.apache.poi.hssf.usermodel.HSSFWorkbook
Imports org.apache.poi.hssf.util.HSSFColor
Imports org.eclipse.swt.SWT
Imports org.eclipse.swt.ole.win32.OLE
Imports org.eclipse.swt.ole.win32.OleAutomation
Imports org.eclipse.swt.ole.win32.OleClientSite
Imports org.eclipse.swt.ole.win32.OleFrame
Imports org.eclipse.swt.ole.win32.Variant
Imports …
I try to automate some handling on a webpage. I have read all the articles I could find, but it just does not fit.

This is partial the webpage:

Transaction page
This is the HTML beneath:

<div class="rgWrap rgArrPart2">
<a title="Go to Next Page" href="javascript:__doPostBack('ctl00j','')">Volgende</a>
<input type="submit" name="ctl003" value=" " title="Next Page" class="rgPageNext" /> 
<a title="Go to Last Page" href="javascript:__doPostBack('ctl004','')">Laatste</a>
<input type="submit" name="ctl005" value=" " title="Last Page" class="rgPageLast" />

Open in new window

"Volgende" en "Laatste" are Dutch for "Next" and "Last".

The code which I try to build needs to click on the "Volgende" so I get the next page with records.

I have tried the following code:


    GetElementsByTagName() and filter by value:

    Set oInputs = IE.Document.GetElementsByTagName("input")
    For Each elm In oInputs
        If elm.Value = "Go to Next Page" Then
            Exit For
        End If

Open in new window


    For Each elem In IE.Document.GetElementsByClassName("rgPageNext")
        If elem.innerText = "Go to Next Page" Then
        End If

Open in new window

   GetElementsByTagName() and filter by class attribute:

    For Each a In IE.document.getElementsByTagName("a")
        If a.GetAttribute("class") = "rgPageNext" Then
            Exit For
        End If

Open in new window

   GetElementsByTagName() and filter by title attribute:

    For Each a In IE.document.getElementsByTagName("a")
      If a.getAttribute("title") = "Go to Next Page" Then
        Exit For
      End If

Open in new window

The first approach gives this error message:

    Script: K:\temp\TT\mftt.vbs
    Line: 37
    Char: 2
    Error: Object required: 'IE.Document.getElementByID(...)'
    Code: 800A01A8
    Source: Microsoft VBScript runtime error

Open in new window

The other attempts are not giving error messages but also no reaction on the link to click. I'm missing here the OnClick event. With other links in this project the OnClick event was present. I can't change the HTML, so I'm stuck.

UPDATE1: I have added the script file so far. I have not attempt to build the logic. First aim is to read all the fields and click the right buttons. If that is successful I will build the iteration process,
UPDATE2: due to privacy reasons I can't give you access to the site. I have added the DOM from the page and removed any names.

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.