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 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 …
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.

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 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?
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

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.
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.

I am trying to make a Microsoft word document that allows users not to edit content once the content controls are removed. My plan to do this was by restricting the editing to only filling in forms and then creating a code that removes the content control anywhere that there is text value. I am new to VBA and cant get the code to work properly. I can get it to remove the content controls when they are empty but when I try to remove them with content they do not disappear. I have attached the document that I cant get to work.

If anyone can help me that would be fantastic!


C++ 11 Fundamentals
LVL 12
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.


I can't run a vbs script from SQL.

The vbs script refreshes an excel workbook.

Input: EXEC xp_cmdshell 'CScript "C:\Users\Simon\Desktop\Stadium\Refresh\refresh.vbs"'

Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Users\Simon\Desktop\Stadium\Refresh\refresh.vbs(2, 1) Microsoft VBScript runtime error: Permission denied: 'CreateObject'

vbs script:

Set objExcel = CreateObject("Excel.Application")
 Set objWorkbook = objExcel.Workbooks.Open("C:\Users\Simon\Desktop\Stadium\Audit\Audit.xlsx")

 ' This command refreshes the queries in the excel file

 ' This command allows the query to run long enough, 60 sec, before the 2 commands below run
 WScript.sleep 60000



I'm trying to assign IP address for stations 1-8. I have an HTA script to make a drop down list and based on the choice assign the IP address. I need to leave the gateway and DNS blank.
The code load form with drop list but I get an error when trying to assign the IP address. Please Help
code below for WorkstationID3.HTA :
  <TITLE>Set Workstation Name and IP address</TITLE>
    APPLICATIONNAME="Set Workstation Name and IP address"

Sub Window_OnLoad
      window.resizeTo 400,300
End Sub

Sub btn01_OnClick

Dim strIPAddress
Dim strSubnetMask

Set WshShell = WScript.CreateObject("WScript.Shell")
If WScript.Arguments.Length = 0 Then
  Set ObjShell = CreateObject("Shell.Application")
  ObjShell.ShellExecute "wscript.exe" _
    , """" & WScript.ScriptFullName & """ RunAsAdministrator", , "runas", 1
End if

    oElements = Window.StationID.SelectedIndex
    strProduct = Window.StationID.Options(oElements).Text
    strSubnetMask = ""

    Select Case strProduct
        Case "Station01"
            strIPAddress = ""

        Case "Station02"
            strIPAddress = ""


I have found the following code to render an SSRS via a SSIS script. This script works as it is intended, e.g. saves the rendered report to disk.

But I would like to send the rendered report as an email attachment, without saving it to disk. Please could someone help? I have tried to render it to a memory stream but I can't quite get it to work.

Thanks, Greg

 Protected Sub SaveFile(ByVal url As String, ByVal localpath As String)
        Dim loRequest As System.Net.HttpWebRequest
        Dim loResponse As System.Net.HttpWebResponse
        Dim loResponseStream As System.IO.Stream
        Dim loFileStream As New System.IO.FileStream(localpath, System.IO.FileMode.Create, System.IO.FileAccess.Write)
        Dim laBytes(256) As Byte
        Dim liCount As Integer = 1
            loRequest = CType(System.Net.WebRequest.Create(url), System.Net.HttpWebRequest)
            loRequest.Credentials = System.Net.CredentialCache.DefaultCredentials
            loRequest.Timeout = 600000
            loRequest.Method = "GET"
            loResponse = CType(loRequest.GetResponse, System.Net.HttpWebResponse)
            loResponseStream = loResponse.GetResponseStream
            Do While liCount > 0
                liCount = loResponseStream.Read(laBytes, 0, 256)
                loFileStream.Write(laBytes, 0, liCount)
        Catch ex As Exception
        End Try
    End Sub

Open in new window

hello experts
I have a code for message box pop up, and it work great. but it pops of in middle of screen, how can i change it to pop up on top of screen with bigger font.
Set objArgs = Wscript.Arguments
messageText = objArgs(0)
MsgBox messagetext 

Open in new window

I am looking for simple piece of software, perhaps in GUI form which gives you the option to list jobs, perhaps linked to .exe, bat, or Powershell, vbs files.. and then you can click on a Start button and execute all those jobs in the order of the list.
Something like a 'job control' type software, that is configurable.
Any suggestions?
I need to run an Excel VBA module every 10 minutes from my 2012 R2 server. I am using a VB script to launch it:

Dim eApp
Set eApp = GetObject("\\server.ADdomain\share\dir\exelfile.xlsm")
eApp.Application.Run "exelfile.xlsm!vbaModule"
Set eApp = Nothing

Open in new window

I had a scheduled task starting cscript using this vbs file as an argument. I have now changed the task to run a cmd script so I can log errors. Here is the cmd script:

C:\Windows\System32\cscript.exe C:\temp\vbscript.vbs > c:\temp\taskschlog.txt 2>&1

Open in new window

The scheduled task works properly when it is set to "Run whether user is logged on or not" when the Trigger is set to Daily at a specified time and I log out of the server. However, if I leave everything else the same, except I change the Trigger settings, checking the box for "Repeat task every" and setting its timing drop downs, and then log out of the server, it stops working! The cmd script error log shows:

C:\temp\vbscript.vbs(2, 1) Microsoft VBScript runtime error: Permission denied: 'GetObject'

Open in new window

I've read A LOT on various task scheduler issues, but mostly people have issues getting it to run when the user is not logged in, which is not my issue; it's the "Repeat task every" functionality. How does this setting suddenly create a permission error?

i am trying to run virtualbox to power-up VM on Private Cloud but unable to start the VM with error of shutdown the WIn 10 Guest OS each times when trying to Power-up the Virtualbox VM. Thanks

VB Ver 5.2.22r126460
Win 10 Enter OS => 1803 (OS Build 17134.407)


I have a folder with a bunch of files that come in a set of 2 files (e.g., Name.pdf, NameMD.pdf).  I need to loop through this source folder (call it FOLDER1) and move only each set of files to another folder (call it FOLDER2).   (NOTE: Then, I have another process that compares the contents of each set of PDF files.)

I need to search for a file that has a *MD at the end of the filename, then search for the 2nd file that does NOT have 'MD' at the end of the filename, then move both files to FOLDER2.  Then I have another process that processes files in FOLDER2.  Then repeat the loop in FOLDER1.

What is the code to do this as a vb script, a standalone console C#.Net or C#.Net inside of SSIS?




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

Starting with Angular 5
LVL 12
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

How do I do EagerLoading of this object
Public Class Person 
    Public Overridable Property personId As Integer
    Public Overridable Property nameType As String

   Public Overridable Property Names As IList(Of PersonNameType)

End Class

Public MustInherit Class PersonNameType
    Public Overridable Property personId As Integer
    Public Overridable Property nameId As Integer

    Public Overridable Property Person As Person
    Public Overridable Property Name As Name

End Class

Open in new window

I tried doing this but the navigation properties (Person/Name) of "Person.Names" is not getting filled. I mean when I drill into the Person.Names and one of the collection item the personId/NameId has data but the Person/Name properties has nothing. How do I fill that data in?
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


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.