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

Hello Experts,

I have about separate 10 web pages for users. Instead of sending them the URL each time a new person needs access to the page, I’d like to set it up as so:

I have an app that will open each of the web pages when you select it. I’d like some way to authenticate the user so it’ll only go to the page for them.

So let’s say Tom needs access to FINANCE and GRANTS pages, but should not see the rest. I would want to add Tom to the FINACE and GRANTS group so when he opens the app below, his only options would be HRD.html and Finance.html pages.

I suppose I could do some case statements in the script and a prompt to validate hard coded user names but I’d rather not put user names in the script.

Could I use a prompt to authenticate to a file/group before opening the page?  Any ideas? Thanks!

   Application ID = "Test"
<script language="vbScript">

Sub Window_onLoad
window.resizeTo 680,470
End Sub

Sub GetURL
thisURL = urldrop.value
document.getElementById("noiwin").innerHTML = "<iframe width='800' height='500' src='" & thisURL & "'></iframe>"
End Sub

<select name="urldrop" style="width: 200px" onchange="GetURL">
<option value="AppSelect.html">Select Application</option>

<option value="Finance.html">FINANCE</option> - If username in 

Open in new window

I have a ASP.NET website that we use for our client portal.  It is written in VB.  I created a DirectoryInfo link that works great and gives the users the ability to see a directory listing and download the file.  I have to make sure that the files in the directory do not have spaces or the link gives an error.  Is there any way to change the code to retrieve the file that has a space in it  Below is an example of my code.  Any help would be appreciated.

  Protected Sub Label11_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label9.Load

        Dim strFileSize As String = ""
        Dim di As New IO.DirectoryInfo("e:\printed statements\" & Label7.Text & "familyoffice\" & "2019\" & "february\" & "monthly_reports\")
        Dim aryFi As IO.FileInfo() = di.GetFiles
        Dim fi As IO.FileInfo

        For Each fi In aryFi
            strFileSize = (Math.Round(fi.Length / 1024)).ToString()
            Label11.Text += "<a href=https://www.brandytrust.net\Clientfiles\" & Label7.Text & "familyoffice\" & "2019\" & "february\" & "monthly_reports\" + fi.Name + ">" + fi.Name + "</a><br /> "


Open in new window

Hi Experts,

I had the following code working perfectly fine on my pc.

   sDir = "E:\AppDev\FTP\Caspio"

    StrFile = Dir(sDir & "*" & sFileStr & "*")
    Do While Len(StrFile) > 0 And Not IsFileOpen(sDir & StrFile)

Open in new window

However when placing it into the server it always returning an empty string.

Folder above contains many files (on that server).
Good Afternoon,

I have this VBS script for sending emails but I want to add a section to the script where it looks for a particular file and adds it as attachment.

' Constants
Const cSmtpUser = "Username"                                ' *** MAKE CHANGES HERE ***
Const cSmtpPassword = "Password"                            ' *** MAKE CHANGES HERE ***
Const cSmtpServer = "smtp.test.net"                          ' *** MAKE CHANGES HERE ***
Const cSmtpPort = 25                                       ' *** MAKE CHANGES HERE *** (25, 465, 587 common)
Const cFromEmail = "admin@test.uk"                      ' *** MAKE CHANGES HERE ***
Const cToEmail = "nick@test.uk"                        ' *** MAKE CHANGES HERE ***
Const cSubject = "Daily Worksheet - Operatives Missing"                     ' *** MAKE CHANGES HERE ***

' CDO Constants needed to send email
Const cCdoSendUsingPickup = 1   'Send message using the local SMTP service pickup directory.
Const cCdoSendUsingPort = 2     'Send the message using the network (SMTP over the network).
Const cCdoAnonymous = 0         'Do not authenticate
Const cCdoBasic = 1             'basic (clear-text) authentication
Const cCdoNTLM = 2              'NTLM
Const cCdoSendUsingMethod        = "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cCdoSMTPServer             = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cCdoSMTPServerPort         = 

Open in new window

Good Afternoon,


I am looking for a straight forward script that can re-sort the attached text file.

Source File

"Date:","PPE No."
"07 February 2019 07:06 AM","PPE_000018_1067414"

I would like to move PPE No to the 1st the column and it looks like the below

"PPE No.","Date:"
"PPE_000018_1067414","07 February 2019 07:06 AM"

Thank you
Dear All

I have a spread sheet which I am trying to remove the data from.  I have a large spread sheet that I wish to use as a mail merge source so I can contact everyone and tell them I don't have their contact details.
So I need to delete all the rows that have an email address in it.  

Please help


Hi Experts,
I have some (Access) code that is supposed to be running all the time.
Would like to get an email notification in case the code stops executing for whatever reason.
What is the best way to accomplish that?
Hi Experts,

I have the following code running that suppose to process all files in a folder, and deletes each of those files upon completion.

Public Sub CallImportDataToCaspio()
   Dim StrFile As String, strTable As String, sFileStr As String
   Dim sDir As String
   Dim l As Long, s As String, i As Long
   Dim db As Database
   Set db = CurrentDb
   sDir = "H:\FTP\test\"
    'StrFile = Dir(sDir & "*PatChanges*")
    StrFile = Dir(sDir & "*" & sFileStr & "*")
    Do While Len(StrFile) > 0 And Not IsFileOpen(sDir & StrFile)
''        Do While IsFileOpen(sDir & StrFile)
''            ' do nothing
''        Loop
        If InStr(1, StrFile, "Full") = 0 And InStr(1, StrFile, "Part") = 0 Then
            i = CountOfRecords(sDir, StrFile)
            If i > 1 Then
                'Debug.Print StrFile & " - " & CountOfRecords(sDir, StrFile)
                If InStr(1, StrFile, "PatChanges") > 0 Then
                    strTable = "Patients"
                    l = ImportDataToCaspio(strTable, sDir & StrFile, i)
                ElseIf InStr(1, StrFile, "SchChanges") Then
                    strTable = "Schedule"
                    l = ImportDataToCaspio(strTable, sDir & StrFile, i)
                ElseIf InStr(1, StrFile, "CGChanges") Then
                    strTable = "Caregivers"
                    l = ImportDataToCaspio(strTable, sDir & StrFile, i)
                ElseIf InStr(1, StrFile, "PatMedProfileChanges") Then
                    strTable = 

Open in new window

I am setting up  Google Mapping of our properties (nearly 1000 addresses) for my office and need to do a lot of filtering of Excel data. The multiple clicks to filter is driving me crazy. I am looking for a way to get the result of the Filter on the Address column the same way as the built-in one but with an input box. So far my VBA Macro search has netted more problems than I have time for!

I want to be able to type in either the Number or the street name and get a filter of all the fuzzy matching results. And hooking it to a macro to automate it. I have run the Record Macro so many times my fingers hurt!

Sample Data file attached. Not worried about the other columns as long as they stay in the array.

Any help?  Thanks!
Hey All,

How can I get the output from the following commands please.

562       Set wsh = New WshShell
572       strCom = Chr(34) & _
                 "C:\Apps\PSCodeRunner\RunCode.cmd" & _
582       lngErrorCode = wsh.Run(strCom, _
                           WindowStyle:=0, _

I have a powershell being executed in that file as follows:

C:\windows\sysnative\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command "cd \; [console]::Title='RC PS Processor'; [IntPtr]::Size; c:\apps\PSCodeRunner\PSScript.ps1; Exit"

I have tried piping in clip such as | clip but the only kind of output I get is:

WARNING: The names of some imported commands from the module 'tmp_hsh4edta.1jr' include unapproved verbs that might
make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the
Verbose parameter. For a list of approved verbs, type Get-Verb.

ModuleType Version    Name                                ExportedCommands                                            
---------- -------    ----                                ----------------                                            
Script     1.0        tmp_hsh4edta.1jr                    {Add-AvailabilityAddressSpace, Add-DistributionGroupMember...

And what I want is the actual output you get from the PS ISE etc... or PS generally.

Please advise

Many thanks

Hi All

Hope your well,

We need to run a housekeeping script for contact objects in a number of users local outlook. The contacts that need to be deleted have a specific attribute set in the "Mileage" attribute. Is it possible to create a script that would identify the contacts that match this condition and then proceed with deleting them without touching any other contact objects that do not match this condition. When trying to this centrally through exchange "Mileage" was not searchable attribute which is why im exploring options with VB locally on the PCs themselves.

I require a batch file/PS script to sort thousands of .txt files into specific folders.  i have some production machines that create reports in the form of .txt files and these are all put into 1 folder.  Ideally it would create any sub folders required automatically so i don't need to manage them.
I need to sort these in a number of ways.

firstly i need to check the content of the file to look for specific text. and then sort into a number of sub folders using the contents of the file name.

an example would be files named

the content will contain a specific string  in this case LINE 2

the folder structure is as follows:#

Line 1
      -> Year
           -> Month
                 -> Day
Line 2
      -> Year
           -> Month
                 -> Day
Line 3
      -> Year
           -> Month
                 -> Day

and so on.

i have 8 lines in total and each of these reports come off anywhere from several times a day to several times an hour.  

i plan to run a script overnight to sort any new files created.  the problem is i cannot alter the file structure for a few reasons and currently i am having to sort these manually which is very time consuming.
Hello experts,

Hello experts,
I am looking for a vbscript in order to check in a specific folder if csv files which have the following prefix "Import" are older than 30 minutes if not report in a log file located in the same script folder with datestamp YYYYMMDD_HHMMSS: no files with the prefix "Import" are older than 30 minutes based on execution script date if so report YYYYMMDD_HHMMSS: WARNING files "Files names" are older  than 30 minutes based on execution script date.

Check requirements:
If reported folder exist if not exit sub and report information in log file.

If you have questions, please contact me.

Thank you very much for your help.
ASPX .NET - 4.5 VB
I  am calling a popup window using JavaScript from a button embedded into a master page, gridview footer template.

All is well until on the popup, I select the employee id I want to go back down and populate the field in the gridview footer template in the parent.
I have tried several different scenarios, and I am missing something. In the code behind of the child page, I am properly getting the employee id value but
now stumped on how to get it to auto populate.

the attaching has more detail
Greeting Experts -    

I need help updating a PowerShell script below…The purpose of the script is to scan a list of files in Windows SMB shares and look for keywords in the file names (i.e., password, payroll, Human Resources, HR, and other keywords). Currently, I am only able to scan a network directory using one keyword at a time. I want to modify the script to scan for multiple keywords listed in a text file instead of doing one keyword at a time… Is there somebody out there can help me with this script.

Get-ChildItem -Path \\Server\fileshare -Filter  *password*.*  -Recurse -ErrorAction SilentlyContinue -Force

Open in new window

Need help with overcoming Microsoft Access pop-up security messages.  My intention is run the following .vbs script below.  It already works within Microsoft Access - but I need it to work as a .vbs script to run before.  Thus when I convert it over to VBS one of the issues I face is it's GoTo statements it uses to overcome error messages.  

Obviously when I run it I get a syntax error on line 21 where there happens to be the first GoTo statement:

How would you rewrite the following below to overcome such?  If I have someone do one - then I could do the rest but was hoping for a rewrite of some of the statements to get me going?   Much appreciation for any comments.

Call AddTrustedLocation("C:\Apps\ETS")
Call AddTrustedLocation("\\americas.shell.com\americas\E & P\SEPCO Woodcreek\PROJ_07\Onshore Asset\ETS & MAPPING\Project Tracking")


Private Function AddTrustedLocation(strPath)

 Dim intLocns
 Dim i
 Dim intNotUsed
 Dim strLnKey
 Dim reg
 Dim strTitle

 strTitle = "Add Trusted Location"
 Set reg = CreateObject("wscript.shell")
 'Specify the registry trusted locations path for the version of Access used
 strLnKey = "HKEY_CURRENT_USER\Software\Microsoft\Office\" & Format(Application.Version, "##,##0.0") & "\Access\Security\Trusted Locations\Location"
 On Error GoTo err_proc0
   'find top of range of trusted locations references in registry
   For i = 999 To 0 Step -1
       reg.RegRead strLnKey & i & "\Path"
       GoTo chckRegPths        

Open in new window

Hi Experts,

I am working a long time on a VBA function that will constantly be reading (txt data) files in a loop and transfer data to a web hosted software using API calls.

Would like to know if you can spot any serious bugs before releasing it.

Attaching the full code.

Thanks in Advance.
vb code to write kml files
I had this question after viewing Populate Text Box From Dropdown List.

The code below (as gotten from question I posted above) works to populate drop down lists independently. I'd like to modify the code to be dependent drop down lists.

So let's say I have a table called CODES, which contains the following:

Year  | Code_Number
1999 | 1001-10
1999 | 1002-10
2000 | 2002-05

I’d like two drop downs. One drop down has the year, which when selected will filter the second drop down of the Code_Number. So in the example above, if I select 1999 from the first drop down, 1001-10 and 1002-10 will fill in the second drop down.

Additionally, I’d like both selections in text box/drop down to be stored in a text file. While I do have a sub routine for that, I keep getting undefined errors.

The table has hundreds of thousands of entries and takes a few seconds to load when I run the query so I'm wondering if the table can be loaded with perhaps just the years (or maybe a text box to enter the year) and then fetch the Code_Number only for that year so it'll load faster?

  <title>SQL DropDown Demo</title>
	 icon="http://www.iconarchive.com/download/i62658/ampeross/qetto-2/search.ico" >
  <script type="text/vbscript">

Option Explicit

Sub Window_OnLoad


' Also add some extra values 

Open in new window

I have a text file in 2 columns where column 1 is date in dd/mm/yyyy while column 2 is a user's name.

11/12/2018         aaron
28/12/2018         amber
5/1/2019              ben
2/11/2018            barney
2/1/2019              carl
. . .

Need a Windows batch script (not PowerShell) that when I run today (say it's 18 Jan 2019 today), would lik eto
extract out a list of users where the date in the file is more than 31 days from today's date.  So output will be:

11/12/2018         aaron
2/11/2018            barney
How to extract NTFS Disk Security user list which was added in a disk using command prompt

I'm using Excel 365 and looking for a macro that will do the following:

Column L = ID (number)
Column W = Step No. (number ranging from 1 - 10)
Column AG = Result of Macro

If a duplicate ID is found in column L, go to column W and locate the row with the last step.  When found enter the text "Match" on the same row in column AG.

For example, in the attached file there is a matching ID on rows L4:L5.  For that ID, the last step in column W is on row 5 (2).  As a result, the text "Match" appears on row AG5.

Any assistance would be greatly appreciated.  Thanks!
Building off of https://www.experts-exchange.com/questions/29131838/Search-CIDR-subnet-ranges-with-powershell.html
I'd like to have a second file with known entries be searched first, then search the CIDR.csv failing a result on the main fields. I'd like to search on the main fields, IP, Host and User
IP_Address(s), Hostname, User, Notes, Workstation003, Jane Doe, HR Admin, Workstation001, John Doe, IT Analyst, Workstation007, James Bond, Janitor, WorkstationNiner, Tommy Boy, Sales, Workstation002, John Doe, IT Analyst

Open in new window

In the above, searching based on User "John Doe" should have two results (on two lines)
.\finddetails "John Doe" (maybe switches are needed? Like -i = ip, -h=host, -u=user?)
IP_Address(s), Hostname, User, Notes, Subnet
-------------- -------------- -------------- --------------, Workstation001, John Doe, IT Analyst (Production, unknown), Workstation002, John Doe, IT Analyst

Open in new window

IP_Address(s), Hostname, User, Notes, Subnet
-------------- -------------- -------------- --------------, ???, ???, Telco,

Open in new window

Something to that effect if that makes sense? If the IP doesn't match anything, then some nice error :)
Let me know if you have questions on the details, thanks!
I'd like to be able to search for an IP's within CIDR ranges/list, and output the information around that IP's CIDR file.
Very similar to this EE question https://www.experts-exchange.com/questions/29127048/Excel-CIDR-IP-Address-Overlap-Formula-Check-for-CIDR-IP-Address-Overlap.html

This is what I envision...
CIDR, Subnet_Name, Guest Network, Production, Telco, BoomChickaWowWow

Open in new window

    Found: - Guest Network

   Found: - Telco
   Found: - BoomChickaWowWow
   Not Found:

FindIp would look inside the cidr.csv and then expand the CIDR's and seqrch for matches within.
I have the below/attached employee table in an access database.  I need a query to find all the direct reports and indirect reports of a particular employee

EmpID      Fname      Lname      MngID
1      Fred      Flinstone      
2      Linda      Thompson      1
3      Sam      Adams      1
4      Jason      Williams      1
5      Michael       Jordan      2
6      Katey      Perry      5

If I wanted to find all the direct and indirect reports of EmpID 2,  it should return michael and Katey,   Excel or access should be ok

This is what I want to do but in access SQL Query to find all the subordinates of a superior

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.