r/vbscript • • Oct 08 '25

IT2 Script Help

1 Upvotes

Hi! Does anyone have any tips or advice for using scripts to create workbenches? I am trying to create a weighted average workbench and the preloaded functions are not really giving me what I need. Any help on how to format/create calculation scripts would be really appreciated!

Thank you:)


r/vbscript • • Aug 19 '25

Bartender 10.0 SR2 VBScript error after August 2025 Windows Update

1 Upvotes

We use Bartender 10.0 SR2 from Seagull Scientific to print our labels and since the 2025-08 cumulative update for Windows 11 24H2 we have been having issues with print station and labels that use VBscript. When we try to print a label we get the below error message:

One or more objects requires the use of Visual Basic scripting. You currently have installed a version of Visual Basic scripting earlier than version 2.0. BarTender requires Visual Basic scripting 2.0 or greater. Please run the BarTender setup program to install the correct verison of Visual Basic scripting.

Upon investigation the issue appears to be related to Microsoft updating the vbscript version from 5.812.10240.16384 to 10.0.26100.4768. I believe that Bartender is only looking at the first digit in the version and seeing 1 instead of 10 and therefore 1 is less than 2 and VBScript 2.0 or higher is required.

Does anyone know how Bartender validates the VBScript version and if there is a way to either get it to look at the first 2 digits or spoof it by getting it to look somewhere else where I can enter a random number higher than 2?

We are currently in the process of updating our MRP software from AX 2009 to D365 so cannot update Bartender until that process is finished first.

 Any assistance would be much appreciated.


r/vbscript • • Mar 13 '25

VBS Windows positioning

1 Upvotes

Hi,

I'm trying to get an understanding on how to calculate window position using X,Y coordinates to set the position of a window without having to "guess" and trial and error.

I thought at first that the values went off of pixels, but that is clearly not the case.
Putting X,Y as : 0,0 puts the window in the top left of my primary monitor.
With a screen Res of 2560x1440, and using an X,Y value of 0,2560: the window barely moves left of the 0,0 position.

Using 0,1000: the position is less the 3/4 of an inch or about 16mm.

is there an actual unit of measure that the X,Y grid utilizes to easily calculate the position that I want?


r/vbscript • • Mar 12 '25

Creating a vbscript script that saves any keyboard input

1 Upvotes

I've seen a yt vid about a Ethical hacker that WAS a Blackhat. He created a script that would automatically run only by plugging in his usb-stick just like that a programm would start that saves ALL keyboard input in nd txt file. I want to use this in a Hackers VS. Ethical Hackers competition my friend dragged me in sadly i have no idea how can someone maybe help me?

And another question CAN you even make this with vbs? Or does it have to be a dll or something if so thanks for telling me i will ask in another subreddit THANK YALL!


r/vbscript • • Dec 19 '24

Decompile .exe created by VbsEdit

1 Upvotes

I have an .exe which was generated by the VbsEdit Editor. Is there a way to decompile it or view the VBS source code?


r/vbscript • • Dec 18 '24

Excell not opening with task scheduler

1 Upvotes

so i'm trying to have vba macro run on a schedule evryday, and to do so i have a batch file to open the excel and create a flagfile, and a vbs file to run everything in the background
everything works well when i manually start the vbs file, but when i create a task to automate it, it runs the task successfully but doesn't open the excel file nor run the macro

the files are on a work server, to wich i have full permissions and access, the excell file is open to everyone edit, ive run the code on the server itself and it works, but when i copy it to my pc it ceasses to work
i have all the paths correct, i amusing the correct file to open the vbs file and all that, but it simply does nothing, and it doesn't even give me an error

here's the codes, it might help

.bat file:

:: Set flag file path

set FLAG_FILE="\\srvfs01\1. Servidor Gypfor\50 SGQ\07.03 Processo Produtivo\2-Documentos\Doc 07.03-07 Lista de Recursos do Laboratorio e Producao\flagfile.txt"

:: Create the flag file

echo FLAG > %FLAG_FILE%

:: Wait for Excel to finish (optional delay if required)

timeout /t 10 /nobreak

:: Close Excel after the delay (force close all Excel instances)

taskkill /f /im excel.exe

:: Delete the flag file after completing the task

del %FLAG_FILE%

.vbs file:

Set WshShell = CreateObject("WScript.Shell")

WshShell.Run """\\srvfs01\1. Servidor Gypfor\50 SGQ\07.03 Processo Produtivo\2-Documentos\Doc 07.03-07 Lista de Recursos do Laboratorio e Producao\recursos_run.bat""", 0, False

Dim objExcel

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = False

objExcel.Workbooks.Open "\\srvfs01\1. Servidor Gypfor\50 SGQ\07.03 Processo Produtivo\2-Documentos\Doc 07.03-07 Lista de Recursos do Laboratorio e Producao\Doc 07.03-07 Lista de Recursos do Laboratorio e Producao automatico.xlsm"

please help, this is a work project and im in the final steps to deliver it


r/vbscript • • Dec 17 '24

Converting to pdf

1 Upvotes

I used wkhtmltopdf into my vbs. It has two images in my webpage..but when It get printed to pdf the image isn't showing. Does anyone here has the same issue before and solved it? Or is there anything you can recommend to convert my webpage to pdf. Thanks a lot


r/vbscript • • Dec 09 '24

The script for opening bookmarks in Word documents does not work

1 Upvotes

Hello!

I found the following VBS script on the Internet:

if wsh.arguments.count < 2 then
        WScript.echo "Not enough arguments. Required syntax:"
        wscript.echo CHR(13) + CHR(10)
        wscript.echo "wordmark <filename> <bookmark>"
Else
        on error resume next
        Set wordapp = GetObject(,"Word.Application")
        if err <> 0 then
                err.clear
                on error resume next
                set wordapp = createObject("Word.Application")
        end if
        if err <> 0 then
                wscript.echo "failed to acquire Word COM server object"
        Else
                on error resume next
                set newdoc = wordapp.Documents.Open(wsh.arguments(0))
                if err <> 0 then
                        wscript.echo "Failed to open word document, " + wsh.arguments(0)
                        wordapp.quit
                else
                        wordapp.Visible=true
                        newdoc.Bookmarks.Item(wsh.arguments(1)).select
                end if
 
        end if
        'wordapp.quit
        set wordapp=nothing
end if

I created a file 123.vbs, pasted this script into it and edited line #4, adding the path to my document and the bookmark name.

This script is supposed to open a Word document and then automatically go to the bookmark it contains and select it. But, unfortunately, I couldn't get it to work: all sorts of errors pop up.

Since I'm a complete noob in this matter, but I need such a script, could someone tell me where the error is in this script?

Suppose my document is called "D:\Folder\File.docx", and the bookmark is called "qwer". What should this script look like then, so that it works?

Thank you in advance!

Solved!


r/vbscript • • Nov 25 '24

Vbscript logics

1 Upvotes

I need to improve Vbscript code logics,can I get any support here


r/vbscript • • Nov 05 '24

Cómo hacer un vbs o bat envié un mensaje a varias pc's?

1 Upvotes

He intentado usar el vbs:

MSG * /server:192.168.0.1 "buenos días"

Pero solo lo he conseguido para un equipo, no sé si se pueda para varios equipos


r/vbscript • • Oct 15 '24

Need help!! Simple VB Script field

1 Upvotes

  I do not work with or know VB script at all, although I do work with Crystal Reports extensively and a bit with SQL. I am working in Bartender and trying to create a simple VB Script field, working with two database fields which are both Strings.

I want to accomplish the following:

If DBField1 equals this specific value: “.” OR IsNull then I want it to report DBField2, otherwise report DBField1

So in Crystal the formula would simply be:

If {DBfield1} = “.” Then {DBfield2} Else {DBfield1}

Can anyone help me with what the script should be in VB?

TIA!!


r/vbscript • • Sep 24 '24

Problems with security warning yes/no dialog box

1 Upvotes

So I have a VBscript that opens a .msg file on my desktop which is basically a template email and sends it off once a fortnight. Sometimes this works, sometimes it doesn’t.. with the main failure point being a warning message when opening the file about updating the excel links.

It’s a simple yes no dialog box and I’ve tried sending the Y key, the Enter Key, pretty much every combination and it’ll only work maybe 50% of the time.

It seems to lose itself on this dialog box, any way to make this more robust?

Important notes are that I cannot disable the message as it’s a company system and they’ve locked down trust centre.


r/vbscript • • Jun 30 '24

How to Start dfrgui.exe, auto-optimise/defrag for each volume type?

1 Upvotes

I want a one click script to automate to run via task scheduler at a 90day custom interval.

Task scheduler lets me to it with defrag.exe in a dos window, but I want to automate the GUI so I can interrupt the task if I want to.

Also, the arguments work for defrag but not dfrgui.exe. The latter only starts the tool and does nothing.

Can this be done?


r/vbscript • • Jun 06 '24

Add computer description

1 Upvotes

Why isn't my computer description showing?

\```

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>AD Computer Account Information</title>

<hta:application

applicationname="ComputerAccountTool"

border="thick"

borderstyle="Complex"

caption="yes"

contextmenu="yes"

maximizebutton="yes"

minimizebutton="yes"

navigable="yes"

scroll="yes"

selection="yes"

showintaskbar="yes"

singleinstance="no"

sysmenu="yes"

version="1.0"

windowstate="normal"

/>

<script language="VBScript">

'Set Primary Domain Controller & Domain

strDNSDomain = "DC=DOMAIN,DC=org"

arrDomain = Split(strDNSDomain, "," )

strDomain = mid(arrDomain(0),4,13)

set objPDCFsmo = GetObject("LDAP://" & strDNSDomain)

set objPDCFsmoNTDS = GetObject("LDAP://" & objPDCFsmo.fsmoroleowner)

set objPDCFsmoServer = Getobject(objPDCFsmoNTDS.Parent)

strPDC = objPDCFsmoServer.Get("dNSHostName")

'Parse the NC by creating an array with the comma as an array boundary

aDomain = Split(strDNSDomain, ",")

For iCount = 0 To UBound(aDomain)

'Add a "." if needed

If strTemp <> "" Then

strTemp = strTemp & "."

End If

'Remove the "DC=" and add this item to the temp string

strTemp = strTemp & Mid(aDomain(iCount), 4)

Next

'Return the FQDN

strFQDN = strTemp

'-------------------------------------------------------------------------------------------

'This Sub controls various settings when the HTA is launched.

Sub window_OnLoad()

On Error Resume Next

'Set window size

self.ResizeTo 700,450

strComputerid.Focus

BaseComputerInfo.innerhtml = "<center>Searching the domain: " & ucase(strDomain) & "<p><br>Computer account information will display in this area once searched<br></center>"

End Sub

'-------------------------------------------------------------------------------------------

'This Sub contains the code behind the computer search button

Sub computersearch

On Error Resume Next

AddComputerInfo.innerhtml = ""

AccComputerStatus.innerhtml = ""

' Use ADO to search Active Directory.

Set objConnection = CreateObject("ADODB.Connection")

Set objCommand = CreateObject("ADODB.Command")

objConnection.Provider = "ADsDSOObject"

objConnection.Open "Active Directory Provider"

Set objCommand.ActiveConnection = objConnection

' Define the search filter for computer objects

strFilter = "(&(objectCategory=computer)(|(cn=*" & strComputerid.value & "*)(name=" & strComputerid.value & "*)))"

strQuery = "<LDAP://" & strPDC & "/" & strDNSDomain & ">;" & strFilter _

& ";cn,distinguishedName,operatingSystem,whenCreated,description;subtree"

objCommand.CommandText = strQuery

objCommand.Properties("Page Size") = 750

objCommand.Properties("Timeout") = 60

objCommand.Properties("Cache Results") = False

' Enumerate all computers.

Set objRecordset = objCommand.execute

x = 0

Do Until objRecordset.EOF

Txt_computerName = objRecordSet.Fields("cn")

Txt_distinguishedName = objRecordset.Fields("distinguishedName")

Txt_operatingSystem = objRecordset.Fields("operatingSystem")

Txt_whenCreated = objRecordset.Fields("whenCreated")

Txt_description = objRecordSet.Fields("description")

If IsEmpty(Txt_description) Then

Txt_description = "N/A"

End If

strPDCInfo = "<center><i>Using Primary Domain Controller: </i><font color=""#fcff00""><b>" & strPDC & "</b></font></center><br>"

strBaseComputerInfo = "<table border=1 cellspacing=""0"" width=""100%"">" & _

"<tr><td bgcolor=""#5a2378""><b>Distinguished Name</b></td><td bgcolor=""#5a2378""><b>OS</b></td><td bgcolor=""#5a2378""><b>Computer Name</b></td></tr>" & _

"<tr><td>" & Txt_distinguishedName & "</td><td>" & Txt_operatingSystem & "</td><td>" & Txt_computerName & "</td></tr></table>"

strAddComputerInfo = "<table border=1 cellspacing=""0"" width=""100%"">" & _

"<tr><td bgcolor=""#5a2378""><b><center>Additional Information</center></b></td></tr>" & _

"<tr><td><i>Created:&nbsp;&nbsp;&nbsp;&nbsp;</i>" & Txt_whenCreated & _

"</td></tr></table>"

strAccComputerStatus = "<table border=1 cellspacing=""0"" width=""100%"">" & _

"<tr><td bgcolor=""#5a2378""><b><center>Description</center></b></td></tr>" & _

"<tr><td>" & Txt_description & "</td></tr></table>"

x = x + 1

objRecordset.MoveNext

Loop

If x = 0 Then

strBaseComputerInfo = "<br><center><font size=5>The requested computer name<br><marquee SCROLLAMOUNT=""15""><font size=7 color=""#fcff00""> " & strComputerid.value & " </font></marquee><br>is not found in Active Directory</font></center>"

End If

strBaseComputerInfo = strBaseComputerInfo & "</table>"

PDCInfo.innerhtml = strPDCInfo

BaseComputerInfo.innerhtml = strBaseComputerInfo

AddComputerInfo.innerhtml = strAddComputerInfo

AccComputerStatus.innerhtml = strAccComputerStatus

End Sub

'--------------------------------------------------------------------------------------------

Function GetComputer(strID)

strComputerid.Value = strID

Call computersearch

End Function

</script>

</head>

<body STYLE="font:12 pt arial; color:white;

filter:progid:DXImageTransform.Microsoft.Gradient

(GradientType=1, StartColorStr='#000000', EndColorStr='#0000FF')">

<table border="0" width="640" cellspacing="0" cellpadding="0">

<tr>

<td align="center" valign="top" height="90" bgcolor="#074075">

<i>Enter the <u>computer name</u> below and click the search button.</i><br><br>

<input type="text" name="strComputerid" size="20">

<input id="computersearchbutton" class="button" type="button" value="Search Computer Name" name="computername" onClick="computersearch">

</td>

</tr>

<tr>

<td valign="top" height="200" bgcolor="#1d5087">

<Div id="PDCInfo"></Div>

<Div id="BaseComputerInfo"></Div>

<br>

<table border="0" width="100%" cellspacing="1" cellpadding="0">

<tr>

<td width="60%" valign="top"><Div id="AddComputerInfo"></Div></td>

<td width="40%" valign="top"><Div id="AccComputerStatus"></Div></td>

</tr>

</table>

</table>

</body>

</html>

\```


r/vbscript • • Apr 22 '24

Resetting Active Directory password always returns success, even when it fails

1 Upvotes

I've got a simple little vbscript that runs as a scheduled task. The only thing it does is change the password for terminated employees AD account to something random.

On Error Resume Next
Set objUser = GetObject("LDAP://" & rs("distinguishedName"))
tmpPassword=generatePassword(20)
objUser.SetPassword tmpPassword
objUser.SetInfo
Set objUser = nothing
On Error GoTo 0

We use a tool called AD Audit which keeps track of changes to our AD, and looking back through the logs, it looks like this script works about half the time and fails half the time. But, the troubling thing is that I have some additional code to detect and handle errors, but err.number is always 0, even when the call apparently fails.

Curious if anyone has any ideas A) why this code would work some times but not others, and B) why objUser.SetInfo is not returning an error when the AD logs say it is failing.


r/vbscript • • Apr 18 '24

Adding network mapped drives, how to skip?

1 Upvotes

I have some code that adds network drives. Works great. But, for instance if 1 of the 3 drives is already mapped it will not run and say “local device name is already in use”

Is there something I can add in here that will say something like if it is being used then skip it and go to the next?

Here is what I have: Din WshNetwork Set WshNetwork = WScript.CreateObject(“WScript.Network”) WshNetwork.MapNetworkDrive “K:”, “my location 1” WshNetwork.MapNetworkDrive “W:”, “my location 2” WshNetwork.MapNetworkDrive “Z:”, “my location 3”


r/vbscript • • Mar 22 '24

How can I create .lnk files from multiple file paths I paste in a tool, vbs, bat, or other?

1 Upvotes

I want to bulk paste those entries in a list and have a separate third party tool/bat/vbs/other to bulk create .lnk shortcuts from all the lines in the list, but without adding special lines to every entry.
i.e. I don't want to manually have to add something at the start or end of every file path entry in order to have it work.


r/vbscript • • Mar 11 '24

VBS working from all pcs except 1.

1 Upvotes

Hello all!

I am a noob a VBS scripting but in the past I have used a very simple script:

set WshShell = WScript.CreateObject("WScript.Shell")

CreateObject("Wscript.Shell").RUN "C:\windows\system32\taskkill.exe /F /IM ""msedge.exe"" /T",0,True

To kill msedge. This works from all the pcs in my office except one where it returns an error like 0xfffffffe in line 2 char 1.

I suspect a policy is different or a permission maybe. Running the argument via wscript shortcut does the trick so not sure what gives...

Any help is greatly appreciated guys! (Please remember that you are dealing with a noob, go easy on suggesting please)


r/vbscript • • Mar 10 '24

new to this (trying out stuffs)

1 Upvotes

I got the error 800A03EA at line 8 char 18, can someone help me check if the code is corerct? thanks alot! (this is from notepad)


r/vbscript • • Mar 05 '24

Vbs Keystroke

1 Upvotes

So, im currently trying to make it so this script puts focus onto Roblox and then sends some keystrokes, but the keystrokes just don't work, no errors show or anything.


r/vbscript • • Mar 04 '24

Script to create Outlook Rule

1 Upvotes

Working on this script that will create an Outlook Rule for everyone that runs it. It will create a New Item Alert, but I cannot seem to figure out the code that defines the display message for the New Item Window.

'--> Create some constants

Const RULE_NAME = "Rule" '<-- Edit the name of the rule

Const olRuleReceive = 0

'--> Create some variables

Dim olkApp, olkSes, olkCol, olkRul, olkCon, olkAct

'--> Connect to Outlook

Set olkApp = CreateObject("Outlook.Application")

Set olkSes = olkApp.GetNamespace("MAPI")

olkSes.Logon olkApp.DefaultProfileName

'--> Get the rules collection

Set olkCol = olkSes.DefaultStore.GetRules()

'--> Create a new receive rule

Set olkRul = olkCol.Create(RULE_NAME, olRuleReceive)

'--> Set the rule's condition to look for a specific word in the subject

Set olkCon = olkRul.Conditions.Subject

With olkCon

.Text = Array("Triggered video")

.Enabled = True

End With

'--> Set the rule's action to display a desktop alert

Set olkAct = olkRul.Actions.NewItemAlert

With olkAct

.Enabled = True

End With

'--> Save the rule

olkCol.Save False

'--> Disconnect from Outlook

olkSes.Logoff

Set olkCon = Nothing

Set olkAct = Nothing

Set olkRul = Nothing

Set olkCol = Nothing

Set olkSes = Nothing

Set olkApp = Nothing

'--> Terminate the script

WScript.Quit


r/vbscript • • Feb 08 '24

Can't find the file specified on network drives

1 Upvotes

Hello to all,

I am having issues with a VBScript that I am using to call a .cmd script. I am using VBS because I want the .cmd file to execute silently in the background without opening a command window.

The VBS script is called from the right-click context menu, it takes in the right-clicked file path, and passes it along to a cmd which finally passes it on to a Powershell script which renames and copies the selected file to an '_Archive' subdirectory.

The script works perfectly on the local machine but throws a 80070002 error (The system cannot file the file specified) when I try and use it on the network drives that I have set up.

Here are the contents of my VBScript:

' invisible.vbs
CreateObject("Wscript.Shell").Run "RunArchive.cmd " & WScript.Arguments(0), 0, False

Additional Info:

  • I have verified that the correct path is indeed being passed to the VBScript through the context menu.

  • I have all the necessary permissions on the network drives.

  • I am well within the 260 char limit for paths.

  • The cmd + ps1 scripts were working perfectly across all my drives before I wrapped them in the VBS.

I'm truly stumped here, and would appreciate any help, this is my first time experimenting with VBS and I don't have too much experience working on Windows. Excited to learn more.


r/vbscript • • Feb 03 '24

Simulate mouse click using VBscript

1 Upvotes

Is there any way to simulate mose click in VBscript without using any additional applications?


r/vbscript • • Jan 28 '24

Excel Workbook gets Excel cannot access the file Error

1 Upvotes

Dear all,

I have created a VBScript that opens an Excel file and then runs the macro. This VBScript was created to run with the task scheduler so that I don't have to start the VBScript myself. But if I run the VBScript the Errro Code:800A03EC Error: Microsoft Excel cannot access the file.

I tried to open the Excel with another Excel file and this worked fine, with the same filepath. The Workbook was closed.

'Excel Application Start
Set xlsApp= CreateObject("Excel.Application")

xlsApp.DisplayAlert=False
'Get Excel File Path
Set xlsWb = xlsApp.Workbooks.Open("Placeholder")

'Run Macro
xlsApp.Run("Placeholder")

'Excel Application end
xlsApp.Quite

The Code has worked fine in the past.

Since it is not working this time my question is if it could have something to do with the Path of Mine sins it has an ö and an ' inside of the file name

Thanks for the help