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

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.
Microsoft Azure 2017
LVL 12
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

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
I have a need to schedule a task to occur every four hours, but unbelievably I cannot find any way to do this with the  GPO Task Scheduler in Server 2008. The options for "repeat task every" are 5, 10, 15, 30 minutes and 1 hour...
I can modify the custom repeat time manually in 2008 Server task scheduler but the same isn't possible when doing it on GPO task schedule. I understand and tried changing the repeat interval by editing .XML file but instead GPO tasks schedule change to "5 minutes". Please help its very urgent and important.

Thanks in advance.

 here is the .xml file

<?xml version="1.0" encoding="UTF-8"?>
-<ScheduledTasks clsid="{CC63F200-7309-4ba0-B154-A71CD118DBCC}">-<TaskV2 clsid="{D8896631-B747-47a7-84A6-C155337F3BC8}" removePolicy="0" userContext="0" uid="{E5521DE0-0643-4ED9-AC8E-8EA1DD8FED23}" changed="2019-01-15 16:33:08" image="2" name="Reboot Notification">-<Properties name="Reboot Notification" logonType="InteractiveToken" runAs="%LogonDomain%\%LogonUser%" action="U">-<Task version="1.3">-<RegistrationInfo><Author>TMMCADM\admin152</Author><Description/></RegistrationInfo>-<Principals>-<Principal …
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!
Im looking for a way with VB.NET or something similar to keep a particular webpage refreshing in the users chosen web browser on a timer to basically prevent a timeout where they got logged out and are required to log back in to a web portal from an external provider. Is there a way to tell a web browser application to refresh a tab externally either by the url or the name of the tab ? Im thinking that using a vb app to browse the website wouldn't work because its outside the browsers context where the user authenticated and would not achieve what im after. Any ideas or a completely different approach maybe ?
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.
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.

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
I want to read from the attached excel the sheets "Wells" and "DATABASE" and produce the sheet "Result". I just put in the "Result" some samples and not including all the data.


I'm very familiar with extracting information from register keys using VBScript, but I'm having trouble trying to extract a policy security setting on my machine using VBScript.  I can get to the information I need using gpedit.msc, and navigating to the folder  "Local Computer Policy\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options", but I need to do this via a script that can be run on the laptop of everyone in my organization (to audit a security setting).  I don't want anyone running gpedit.msc on their machines.

I've tried using PowerShell, but I don't want anyone to have to change any settings on their computer (right now the script execution permission on our laptops is "restricted").  I would really like a VBScript that someone can just double-click and have it produce a file that I can then have them send to me.  I've searched the internet for hours and cannot find what I'm looking for.  Can anyone help?
I Writing a batch file to restart a specific window services USING wmic as per below:

service where caption="SERVICE_NAME" call startservice.

But every time execute above i getting a confirmation to select yes or no as per below

->startservice() (Y/N/?)?

How may i add above option "Yes" along the command
Hi, Experts,
I just want to know how the hackers can penetrate my database. I am about to lunch my small project called, Daily Time Record (DTR) but I'm doubt the safety of it. The way I used to save the personnel data into my database is something like the code below. I am using Sql8. Is there anything to add to improve and keep away from hackers? Please give me some ideas.. Thanks!

On Error Resume Next
dim icode,title,iname,famna

icode = request.querystring("a")
title = request.querystring("b")
iname = request.querystring("c")
famna = request.querystring("d")

db = request.querystring("db")
theServer = request.querystring("sr")

Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")

cn.ConnectionString = "driver={SQL Server};server=" & theServer & ";uid=sa;pwd=3388;database=" & db & ""

If Err.Number <> 0 Then
   Response.Write(  Err.Number & "|" & Err.Description )
end if

   cn.execute("Insert into Personnel(theCode,TheTitle,TheName,TheFamilyName) values('" & _
                         icode & "','" & title & "','" & replace(iname, "'","''") & "','" & replace(famna, "'","''") & "')")
	set cn = nothing

   response.write("Successfully enrolled new item!")    				      	
On Error GoTo 0

Open in new window

I am going to be detailed as possible.  I am looking for a CSV that can list the file contents of a directory of my choosing (with the ability to specify how many sub-directories to also parse)

Let's Pretend I have the following



I would need a CSV that has the following:

Row 1 Column A would only list the relative directory name for the file. In this example it would be FolderAA
Row 1 Column B would be the full target path without the filename.  In this example that would be C:\FolderA\FolderAA
Row 1 Column C would be the file name without extension. In this example it would be filea1
Row 1 Column D would be the file name with the extension.  In this example it would be filea1.txt
Row 1 Column E would be the file name and extension with the full target path.  In this example that would be C:\FolderA\FolderAA\filea1.txt

Row 2 Column A would only list the relative directory name for the file. In this example it would be FolderAA
Row 2 Column B would be the full target path without the filename.  In this example that would be C:\FolderA\FolderAA
Row 2 Column C would be the file name without extension. In this example it would be filea2
Row 2 Column D would be the file name with the extension.  In this example it would be filea2.pdf
Row 2 Column E would be the file name and …
Hi Experts,
This is in reference of my previous question.
I have now the following code
Public Function ListRecords(sFolder As String, sFile As String, sCriteria As String, sNewFile As String)
    Const ForReading = 1
    Dim objRegEx As Object, objFSO As Object, objFile As Object
    Set objRegEx = CreateObject("VBScript.RegExp")
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set newFile = objFSO.CreateTextFile(sNewFile, True)
    objRegEx.Pattern = sCriteria
    sDir = sFolder & "\"
    StrFile = Dir(sDir & "*" & sFile & "*")
    Do While Len(StrFile) > 0
        Set objFile = objFSO.OpenTextFile(sDir & StrFile, ForReading)
        Do Until objFile.AtEndOfStream
            strSearchString = objFile.ReadLine
            Set colMatches = objRegEx.Execute(strSearchString)
            If colMatches.Count > 0 Then
                For Each strMatch In colMatches
                    '' Write strSearchString
                    newFile.Write strSearchString
            End If
        'Debug.Print objFile.DateCreated

        StrFile = Dir

End Function

Open in new window

Would like to add the below
1- function should have another param for field name, one for field name and one for criteria.
2- should auto allocate the field position in order to find the matching criteria.
3- if possible to add date/time of file created of each file into the output file.

Hi Experts,

I'm looking for a function that would do the following.

Loop thru all files of a given folder.
Search for files containing some wording in their name "PatMed" for example.
All files are ".txt"
and look for PatientID = 123.

Function should return the entire record
If found more than one, should return all
This should be in order of file created.
If possible, to include in each row, the date/time of file created.

So function should Receive 4 parameters (FolderName, FileName, FieldName, Criteria)
and should either create a file with results, or just return a text delimited string.

Sample of file attached.

PS. Would prefer VBA function.

Greeting Experts -

I need help creating a PowerShell script to pull a list of user names from Active Directory using each client/users First, Middle, and Last names to find each user in AD.  I don't know how difficult this may be, but if somebody can help with this issue, I would appreciate it.
CompTIA Security+
LVL 12
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

Help coming up with a standard way to name files.   I often read through help documents and see different ways in which people notate the system in name files.

is there a standard way to notate file names that i can look at.  

Example of what i am trying to accomplish.

Every month we have a  file that comes in and we store it for archiving.  People name the files differently sometimes.
A billing file comes in from an outside agency.  the parameters are date of bill, agency issued etc..

Agency Name - Route24
Billing Date - Dec 30 2017

I would name the file    Dec302017_Route24.txt    here comes my problem.   What is a standard way to notate this in an instruction book for my users.  
Currently i would write something like this.    [Date]"_"[Agency].txt       which would then allow the user to come up with Dec302017_Route24.txt

i would like a standard that is exact and a standard that is written on a wiki page or something official... lol

does anyone have a link to a good document standardizing the basic notation on how to name a file?
I am interested more in the insturctions part... ie... when to use brackets, when to use apostrophe's etc...
i am printing barcode label on lpt3 is working fine. now I have TSC TE-244 barcode  USB printer.  Normally in VB 6 application
i make batch file

copy c:\barcdprn.prn Lpt3

this is working fine on lpt barcode printer.

now i have change batch file as

copy c:\barcdprn.prn usb003  (bar-code printer is on USB003) . It is not working.

what could be possible solution.

Thanks in advance.
I have a text file being created nightly in a network shared folder. That file has many lines including 3 duplicates. The line duplicated 3 times is:

ACCNT	Accounts Receivable - MU	OCASSET

Open in new window

What I need to do is, from within an Access function, delete the 2nd and 3rd dupe, leaving the first one intact.

Why the dupes exist is a rabbit hole that I don't right now have time to fix even though yes, that is the correct way to really fix this problem. But, if I can just have Access code which will delete the 2nd and 3rd entry of that line, it will suffice as a solution for now.

Thank you very much for any input.
I have a zip file containing tab-delimited text files that are exported from a modeling software. Rather than opening each file individually in Excel to change the data and then exporting each file to a .txt file and then zipping the whole collection up again, I would like to program a macro to do the following (using MacPro Excel):

1) In an Excel workbook with a macro that opens (from a specified location on my computer) all the files in the zip file and puts each .txt file in a separate sheet in the workbook. The name of each worksheet corresponds to each .txt file name in the zipped file. For instance, File1.txt and File2.txt

2) In the same workbook, have another macro that saves all the worksheets by their original file names and creates a zip file at a specified location on my computer with a specified name.

Both the number of files in the zip file and the number of fields in each .txt file will vary depending on the version of the model so the macro needs to open all the files in the zip file.

Accompanying is a sample zip file
We have an Exchange 2013 server on-premesis, and we are trying to write a script to email out with authentication.  We have one script already working on one user, but we need to get another set of credentials working for another purpose, but are using the same script as the first to test.

So, basically, the user with the following details works:

Server: mail.clientdomain.com (maps to internal IP
Port: 587
Username: user1
Password: password1

(Details obfuscated to protect client identity)

This user works just fine.

However, the user with the following details:

Server: mail.clientdomain.com (maps to internal IP
Port: 587
Username: user2
Password: password2

Fails with the error "5.7.1 Client was not authenticated":

2018-12-18T21:47:01.898Z,MYSERVERNAME\Client Frontend MYSERVERNAME,08D6608980A971FE,25,,,*,Tarpit for '0.00:00:05' due to '535 5.7.3 Authentication unsuccessful',
2018-12-18T21:47:06.914Z,MYSERVERNAME\Client Frontend MYSERVERNAME,08D6608980A971FE,26,,,>,535 5.7.3 Authentication unsuccessful,
2018-12-18T21:47:06.914Z,MYSERVERNAME\Client Frontend MYSERVERNAME,08D6608980A971FE,27,,,<,MAIL FROM:<usersemail@clientdomain.com>,
2018-12-18T21:47:06.914Z,MYSERVERNAME\Client Frontend MYSERVERNAME,08D6608980A971FE,28,,,*,Tarpit for '0.00:00:05' due to '530 5.7.1 lient was not authenticated',
I have an excel spreadsheet with a Macro.  The file lives on a NAS.  I've verified we have full permissions to that folder.  I can create a folder, create a file, and delete them.  When I click the button for the Macro, it should save a file in the same location of the spreadsheet.  Instead, I get Run-time Error 52 bad file name or number.  If I debug, It errors out on this line:
If Dir(strDir, vbDirectory) = "" Then
        Shell ("cmd /c mkdir """ & strDir & """")

I've checked Trust Center settings in Excel and all of that is good.  The file does not open in protected view.  The same file does work for all other users.

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.