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 currently have a VPS with RDP at my provider CWH, but my domains are with GoDaddy with A-Records pointing to CWH; and Emails with Microsoft Exchange.  Whenever I need to create a subdomain, I first log into GoDaddy create a new A-Record, then log into Plesk at CWH and create my sub domain there.  

As I’m releasing anew service, I’m hoping to automate this, so I had the following questions.

1.      Can I host my own DNS on my VPS? I

a)      If yes, could I use an API or SDK to create and delete A-Records?

b)      If no, do you know if GoDaddy or another provider has such interface?

2.      Within Plesk, or IIS directly, how can I Create/Suspend/Delete subdomains… again by code? Plesk is PHP-based, so there must be a way.

Obvoiusly my VPS is IIS, but can get Linux.

Any advice would be appreciated.
Upgrade your Question Security!
LVL 12
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Can we export an excel sheet with VBA (i.e, xslm sheet) to sharepoints?

If yes how to export the macro enabled sheets to sharepoint , and how to run from sharepoints?  Can you explain?
Thanks in advance..
Where can I find a good third party tool to write cgi, asp, vb, c sharp scripts?
Please disregard.. Didn't know how to remove a question.
Excel / Macro VB

Have this code it works fine on Excel 2010    (opens runs saves and closes)   upgraded to Excel 2016 and it opens runs and closes but leaves a save dialogue behind which is annoying as it's a scheduled job.  Not sure what I need to add on the newer version of Excel.

Sub Macro1()

' Macro1 Macro
'Refresh Jet
    Application.Run "JetReports.xlam!JetMenu", "Refresh"
    Application.DisplayAlerts = False
    Columns("A:A").ColumnWidth = 4.14
    Rows("1:1").RowHeight = 25.5
    ActiveCell.FormulaR1C1 = " "
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlUp
        ActiveWorkbook.SaveAs Filename:="G:\IT\Trimit\Elastic\Feeds\Rab\inventory.csv", _
        FileFormat:=xlCSVMSDOS, CreateBackup:=False
    ActiveWindow.WindowState = xlMinimized
End Sub
Hi all,

I had a previous question where I needed to search a single folder for the 3 latest files in that folder then copy those 3 files to a new folder - this question got answered and the thread can be found here:


The next issue I have now is:

1) I have a main folder with 20 sub-folders

2) Everyday around 7AM, a new csv extract is added to each sub-folder

2) I need to search through each individual sub-folder and find the latest (the current days) file added to that sub-folder

3) I then need to copy each individual file from its respective sub-folder and place ALL the files in ONE folder - there's no chance of the filenames ever being the same

I found 2 solutions that work in their own way, but I need to "combine" the solutions.

Solution 1: This one will copy ALL files found in a single directory based on the current date to a separate folder

Option Explicit

Dim FolderToCheck, FolderDestination, FileExt, mostRecent, noFiles, fso, fileList, file, filecounter, oShell, strHomeFolder

' Enumerate current user's home path - we will use that by default later if nothing specified in commandline
Set oShell = CreateObject("WScript.Shell")
strHomeFolder = oShell.ExpandEnvironmentStrings("%USERPROFILE%")

'Variables -----
folderToCheck = strHomeFolder & "\Desktop\Terminations"           ' Folder Source to check for recent files to 

Open in new window

I'm writing an HTA file to monitor two specific services on my local computer.  I'd like to add one process to it, but I don't think I can monitor process status with HTA.  That's a problem for later.  Right now, with my current code, everything works except the Start, Stop, and Restart buttons I have.  I would appreciate any ideas on how to get them working.  I changed to names of the monitored services in my code to Spooler and Fax for compatibility in case anyone wants to test it on their machine.  

<title>Server Services</title>
    APPLICATIONNAME="Server Services"

body {
    background-color: black;
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 25px;
table {
    width: 100%;
    border-color: firebrick;
    background-color: black;
    color: khaki;
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 12px;
th {
    border-color: firebrick;
    background-color: black;
    color: khaki;
td {
    border-color: firebrick;


<script language="VBScript">

Sub Resize()
    Window.ResizeTo 380,200
End Sub
Sub Window_OnLoad
    ' Populate table with list of services
    Window.ResizeTo 380,200
End Sub
Sub ListServices(sComputer)
    Set oTable = Document.All("list_servicenames")

    ' Delete any existing data rows

Open in new window

Hello, I'm attempting to write my first HTA script and in doing research I came across this thread:


I'm no programming or scripting expert by any means.. normally I can figure out what I need to do by researching and looking at examples I see on the internet.  So please excuse me if I say anything ignorant.  Now the HTA script I'm writing is incredibly similar to what the user "rejoinder" posted in the above mentioned thread.  So I copied the code and tried to run it on my computer so I can see exactly how it works to try and get an idea of how to make mine work, but all it did was launch the Windows MSI Installer.  I know it is something related to the CLSID in the object in the <BODY> section.  Removing the CLSID from the object will make the script run but it doesn't do anything.  I put the same CLSID into my HTA script I'm writing and that made it launch the Windows Installer also.  I don't know what I'm missing.  Any help in getting this script to work for me would be greatly appreciated.  Thanks in advance!
Experts, I am working within my Access DB and using VB to sum up the Cycle Times of a days worth of machine processes.  My DB records the finish time (long date) each time my CNC completes a job through the day, which I can use as the cycle time (ie. the difference between finish times of two adjacent job records).  However within my VB calculation I need to check if the cycle time included the employee's break or lunch and remove that duration from the cycle time.

For example, I have a two finish times as "12/1/2017 9:47:03 AM" and "12/1/2017 10:33:29 AM".  This calculates for 46.43 minutes, however it included a break time that occured from 10:00 am until 10:20 am which needs to be detected and removed from this particular cycle time.  Is there an easy way to check for the break time duration between a the cycle time?
My company has recently re-branded and I have created new PowerPoint, Excel and Word templates.
In Office I have created my colour palettes which are very useful, but these dont go across with the PowerPoint/Excel/Word files.

Ive been looking into it and it create an XML file on the machine with all the colours within that palette.
C:\Users\user\AppData\Roaming\Microsoft\Templates\Document Themes\Theme Colors\Name.xml

I would like an easy way for everyone else in the company to copy this XML onto their computer.

Can this be done with a batch script??

Any advice?

The 14th Annual Expert Award Winners
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

When I try to run the following command within Power Shell on a Windows 10 Pro OS I get the following error message.

What do I need to do to fix this so I will be able to successfully run this PowerShell command?

PS C:\support> Get-ChildItem "C:\Users\dstroble\AppData\Local\Temp\" | Get-NTFSAccessInheritance

Get-NTFSAccessInheritance : The term 'Get-NTFSAccessInheritance' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:57
+ ... m "C:\Users\dstroble\AppData\Local\Temp\" | Get-NTFSAccessInheritance
+                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-NTFSAccessInheritance:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\support>
Hello Experts,

I have a root folder which contains multiple .jar files. Those files are located in subdirectories folders.
I would like to set up a batch or a vbscript in which you report the name of the .jar file in a csv file and a result.csv file should be generated with the following attributes:

Example of result.csv

Reference root can be reported directly in the script.

Thank you very much for your help.
i need the vba code to edit the data in a row  by highlighted cells
plz look into the attachment all details are given
Hi we have a project written in VB which creates a database and database user in SQL server 2005, this has been working for years, but now we want to move our services to a SQL 2017 database and for some reason the code is no longer creating a user for the database. This leads to us not being able to log in to the program we are trying to move to a SQL Server 2017 server. I have replaced the necessary files and updated the compatibility version as required for the software to run and it does, at this point it seems like only the database user is not being created.

Here is an example of the script being used to create the user:

/****** Object:  Login [VetMasterUser]    Script Date: 03/13/2008 17:17:10 ******/
/* For security reasons the login is created disabled and with a random password. */
/****** Object:  Login [VetMasterUser]    Script Date: 03/13/2008 17:17:10 ******/
EXEC sys.sp_addsrvrolemember @loginame = N'VetMasterUser', @rolename = N'sysadmin'

Open in new window

At this point I am lost to what the reason is that the user is not being created,

Any help would be appreciated.
Hello Experts,

I would like to launch a cmd or a vbscript in order to break or remove lock in a file
Example. I want to remove a csv file and I am not able to remove it because it is used by another user.
I would like to break the lock in order to be able to remove file.

How should I proceed?

Thank you very much for your help.
I'm trying to find a script that will allow me to join about 30 PC to the domain with powershell or other methods.
I try two different power shell scripts and I get this error ps1 cannot be loaded because running scripts is disabled on this system.
I try to add on the beginning of the script the following line but that did not help. Set-ExecutionPolicy Unrestricted.
I also use Kaseya to push scripts and I found a few scripts on txt format but they need to be under XML format so I convert a txt file to a xml file online but that did not work eider.
Any suggestion how I can achieve that by pushing a script to all PC's.
The script can be push and execute it by Kaseya VSA as long as the script works.
I do not know scripting, so-
Have looked at many samples people online have provided and finally have a sript that gives me what I am trying to collect and write to a db.
Need HKCU\Network subkeys and  stringvalueName RemotePath and its' value. For example what I want would be   L:  and \\servername\path(share)
The attached has more code probably than needed, but it does give me a drive letter and the path. I did not write this but used  what I could find to get to this point.
 Problem is the second part of the script where it needs to write to the db.   It either writes one line of data or only one part of.  
I do not know what needs to be entered  as I will also get invalid data type.
Also, instead of getting all of the mapped drives ( which it does get and echo so I am sure), it also appears I am only getting the last.
The part to write to the db is fairly standard :

'Create Inventory data block. Here assumption is that the data class with below guid is already configured on server
dim objDCInstance
set objDCInstance = nse.AddDataClass ("{e30cf469-1720-4452-b3bc-7248d42a861a}")

dim objDataClass
set objDataClass = nse.AddDataBlock (objDCInstance)

'Add a new row
dim objDataRow
set objDataRow = objDataClass.AddRow
'Set columns
objDataRow.SetField 0,  what is the data that goes here?  Name?    

objDataRow.SetField 1,  what is the data that goes here? Name?  

For example. another custom inventory that is working uses
I need to have an automated routine which looks in a MySQL table for any missing records by date field. The table should have multiple records from every single day, but something is causing some days to not get any records inserted at all. I need to be notified of these missing dates so I can investigate. Id rather do this in VB so I could set up a Windows scheduled task to run it once every 24 hours, but if need be I could do it in php and put it on our web server under a cron job. I'd highly prefer the VB route though.
I have two sheets. On sheet 1, cell L4 is a value that can be changed by user input. This value is the ID. On sheet 2 is an array of data for everything associated to that ID (name, date, location etc).
What I am looking for is a macro so that Exel takes the ID code entered in sheet 1 cell l4, then looks for it in column I on sheet 2. Once each row with the ID is located, it. Should fill these rows with the letter x. Instead of the old data.

Can anyone help? All input is appreciated!!!!
Train for your Pen Testing Engineer Certification
LVL 12
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Hi Experts,
pls help me out on this. bit tricky one :)

1. Have a file similar to ".ini" format header and its sections. e.g. schema.ddl
2. Another file with list of keywords on each line. e.g table_list.txt
3. Need to read each line from table_list.txt and search it in schema.ddl and remove the entire table section and its associated index section as well.

Have attached both the files for your quick reference. pls unzip schema.zip file.

"S_PARTY" is the first keyword from the table_list.txt
table section can be found in schema.ddl between line # 317941 and 317960
associated section can be found between 317962 and 318029

basically for each keyword (table name) we need to repeat the process and remove relative entries using windows batch or powershell or vbscript reason,  this will be executed on a windows machine. if any util that doesnt require installation and would easy this. we can use that util as well.

pls help and thx in advance.

I would like to create a VB script to automatically clears the folders on a shared drive older than 7 days. I tried different codes but nothing deletes the folder all i can do is delete the files.
But i have multiple folder lying on the share path older than 7 days. Any suggestion on  this?

thanks in advance
What VBA code would I need to auto accept digital certificates. At the link below it looks like someone possibly found a way to skip digital certificates all together in VBScript. I didn't know if there was a way to do the same in VBA. If this isn't possible, I am also interested in a way to automatically identify any certificate window that opens and somehow navigate it using VBA. (i.e., in effect automatically accepting it.)

New to VB script here. I have a form that I created in Excel with a start and stop date. I have added the VB script to expand the start and stop date on my raw data sheet. I need some script to copy the rest of my form with the date expansion.  Please help me out!
The form cells are C4-E4. Raw data page has the code pasted into Cell D based on the last available cell. Here is the code I have so far.
Sub GenerateDates()

Dim FirstDate As Date
Dim LastDate As Date
Dim NextDate As Date
Dim LRow As Long

FirstDate = Worksheets("Form").Range("F4").Value
LastDate = Worksheets("FORM").Range("G4").Value

Worksheets("Raw Data Sheet").Select
LRow = Cells(Rows.Count, 4).End(xlUp).Row
NextDate = FirstDate
'selection of columns within one row
Do Until NextDate > LastDate

ActiveCell.Value = NextDate
    ActiveCell.Offset(1, 0).Select
    NextDate = NextDate + 1



End Sub
Hi!  I'm trying to create a batch file that opens an Excel file (successfully created in an earlier section of the batch) and Saves As a new dynamic name with the current date so that it doesn't get overwritten the next day.

I can get the file to open and close, but it's not executing the Save As. Any feedback would be greatly appreciated

set ObjExcel = CreateObject("Excel.Application")
set ObjWorkbook = ObjExcel.Workbooks.Open("\\FILELOCATION\FILENAME_.xlsx")
objExcel.Application.Visible = True

objWorkbook.SaveAs "FILELOCATION\FILENAME_" & Format(Date, "yyyymmdd") & ".xlsx"


set ObjExcel = nothing
set ObjWorkbook = nothing

I am creating query tables in VBA. (See a sample from Ejgil below.) Nonetheless, the query table asks for a .textfileplatform. Basically this is one of 152 code page identifiers installed in Windows. Sometimes Windows may or may not have the one you are looking for. Example 1252 below is a 'Western European' Code page identifier, which for whatever reason may/may not be installed on a machine in Canada etc., What VBA would I use to validate a code page identifier exists?

 With Selection.QueryTables(1)
        .Connection = "TEXT;" & CsvFileName
        .TextFilePlatform = 1252
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = False
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = True
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 3, 3)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With

More on Code Page Identifiers is at this link ---> https://msdn.microsoft.com/en-us/library/windows/desktop/dd317756(v=vs.85).aspx

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.