# VB Script

37K

Solutions

20K

Contributors

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.

I have built an HTA application with JScript language and VbScript. I am trying to pass the value of JScript variable to VbScript, but I am stuck. Can you please help.  Here is the JScript code: (I need to pass the docNum [ ] and rev [ ] values, as there may be multiples.)

<script type="text/javascript">

var room = 1;
room++;
var objTo = document.getElementById('room_fileds')
var divtest = document.createElement("div");
divtest.innerHTML = '<div class="content"><span>Document Number: <input type="text" style="width:150px;" name="docNum[]" value="" /></span><span>Rev: <input type="text" style="rev:20px;" name="rev[]" value="" /></div>';

objTo.appendChild(divtest)

}

</script>

<script language="VBScript">
Option Explicit

Sub ProcessInfo_OnClick

End Sub
</script>
Thank you
0
Hi all

I am trying to write a script to produce signatures for users
i found one here that works well https://www.experts-exchange.com/articles/11911/Standardized-Outlook-signatures-using-Active-Directory-and-Word-Template.html but i want to add the users photo from active directory to the script and can not seem to get it to work
i know the attribute i need to call (thumbnailPhoto) but cant seem to get it to insert into the signature

has anyone done this and can help me here ?
1
I would like to modify a CSV file found at ..

C:\users\user\Desktop\file.csv
A sample of the data is found below.
However there could be thousands of lines.

"Data1","Qty1","Qty2"
"ABC1234","0","0"
"ZDG123","525012","0"
"JKL432","0","0"
"TYI00121-1","0","0".
"No of Items","4",""

I want to modify it using a Script so that it searches through the file and when it sees ZDG123, or any other numbers that I will specify in position 1, that it will take the Quantity showing and divide it by 1000, and then re-write the file with the correct changed data.   For example for line shown above as:  "ZDG123","525012","0",  it will then become:   "ZDG123","525.01","0"

Would this be possible, using a scipt?
1
I need a copy of msflxgrd.ocx verion 6.1.98.6.   I have msflxgrd.ocx version 6.1.97.82 but my Security Vulnerability Check states that I need version 6.1.98.6.
This is a 32 bit version.

The required MS updates state that I need VB 6.0 installed.
0
Good Afternoon,

I am looking for a script that re-write a file contents and put it in a new order..

See example file attached.

File Contents

"Inspection on","Document No.","Client / Site / Job Number"
"19 November 2018 09:25 AM","IN_000007_1191310","Company 1 | Site 1 | Job Number: 1912"
"19 November 2018 10:15 AM","IN_000008_1191310","Company 2 | Site 2 | Job Number: 1871"
"19 November 2018 11:45 AM","IN_000009_1191310","Company 3 | Site 3 | Job Number: 1810"

I would like to put the data in a different order..

"Inspection on","Client / Site / Job Number","Document No.
"19 November 2018 09:25 AM","Company 1 | Site 1 | Job Number: 1912","IN_000007_1191310"
"19 November 2018 10:15 AM","Company 2 | Site 2 | Job Number: 1871","IN_000008_1191310"
"19 November 2018 11:45 AM","Company 3 | Site 3 | Job Number: 1810","IN_000009_1191310"

Any ideas?
0
I have a client who has an application which involves a combination of VBScript and Access to download data from an FTP site and then process that data into multiple Access databases. I'm not happy with the way this was implemented but I'm stuck with it.

I received an email this afternoon which indicates that about 15-20 of the files that should have been downloaded and processed on Monday did not make it into the Access databases.

Indications are that something occurred on there servers which affected their authentication service.  Any chance that this would have affected ADO communications between the VBScript and the Access BE databases?  I'm not a huge fan of VBScript or ADO and don't use either often enough to know what will or will not affect them.

Dale
0
Hi

I was supplied a script from an extremely patient and helpful member and I tried adding to it but now I  keep getting an error as below when on line 5

LINE 5
CHAR 1
CODE 800A003A

fso.MoveFolder "C:\Users\g\Downloads\sunday\DownLoad\*.*", "C:\Users\g\Desktop\test"


Any Ideas?

Thanks

Option Explicit
Dim fso

Set fso = CreateObject("Scripting.FileSystemObject")

' Global variables
Dim strBaseDir, strDestDir
Dim objFSO, objFile
Dim arrFiles(), i
Dim lngFolderSize, intFolderNumber, strNextDir, intMoveFile

' Define paths to work with
strBaseDir = "C:\Users\g\Desktop\test"
strDestDir = "C:\Users\g\Desktop\split"
strPlayer = "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe"

' Set maximum size of new folders
Const cMaxFolderSize = 4294967296

' Define class that will hold file information
Class File
Public lngSize
Public strPath
End Class

' Create file system object
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")

' Fully resolve paths
strBaseDir = objFSO.GetAbsolutePathname(strBaseDir)
strDestDir = objFSO.GetAbsolutePathname(strDestDir)
strPlayer = objFSO.GetAbsolutePathname(strPlayer)

' Make sure the folders exists, exit if not
If Not objFSO.FolderExists(strBaseDir) Then
WScript.Echo "*ERROR* Folder does not exist: """ & strBaseDir & """."
WScript.Quit
End If
If Not objFSO.FolderExists(strDestDir) Then


0
why doesn't this work.? see attachment

Option Explicit
Dim WithEvents IE As InternetExplorer

Set IE = New InternetExplorer
IE.Visible = True
MsgBox ""
IE.document.getElementById("q").Value = "TEST"

End Sub
0
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\"

Set FSO = CreateObject("Scripting.FileSystemObject")
strFile = "C:\Users\" & Username & "\Desktop\CMS Supervisor*.lnk}"
if FSO.FileExists(strFile) = True then  FSO.DeleteFile DesktopPath & "\CMS Supervisor*.lnk"

1
Nagios Core 4.3.4   running on Ubuntu 17.4
Nsclient 4.3
Windows 2012 R2
SQL 2012 and 2014

I have a Nagios plugin check_sqldbsize.vbs that checks the size of my sql databases.

On my SQL 2012 server I have one instance and the check works fine from the server and from Nagios.

On my SQL 2014 server I have three (3) instances I have 1 of the three working the other two give me this error CINT

/usr/local/nagios/etc/objects/windowsservers# /usr/lib/nagios/plugins/check_nrpe -t 50 -H 'SERV014-N1' -c check_sqldbsize -a 'SERV014-N1-SQLC\ORF 8000 5000'
C:\Program Files\NSClient++\scripts\check_sqldbsize.vbs(25, 15)

/usr/local/nagios/etc/objects/windowsservers# /usr/lib/nagios/plugins/check_nrpe -t 50 -H 'SERV014-N1' -c check_sqldbsize -a 'SERV014-N1-SQLS\WSS_Content 8000 5000'

C:\Program Files\NSClient++\scripts\check_sqldbsize.vbs(25, 15) Microsoft VBScript runtime error: Type mismatch: 'cint'

from the server I ran the command against both instances and it works fine.

C:\Program Files\NSClient++\scripts>cscript check_sqldbsize.vbs SERV014-N1-SQLC ORF 6000 9000
Microsoft (R) Windows Script Host Version 5.8

OK: ORF database size is 3 MB.

C:\Program Files\NSClient++\scripts>cscript check_sqldbsize.vbs SERV014-N1-SQLS WSS_Content 6000 9000
Microsoft (R) Windows Script Host Version 5.8

OK: WSS_CONTENT database size is 45 MB.…
0
Nagios Coe 4.3.4  runs on Ubuntu 14
Windows 2012 R2
SQL 2014 Enterprise Clustered 2 Nodes  3 instances

I found this check

:/usr/local/nagios/etc/objects# /usr/lib/nagios/plugins/check_nrpe -t 50 -H SERV014-N1 -c check_sqldbsize -a 'SERV014-N1-SQLW\wrestling wrestlinghistory 8000 5000'

C:\Program Files\NSClient++\scripts\check_sqldbsize.vbs(33, 1) Microsoft OLE DB Provider for SQL Server: Login failed for user 'MYDOM\SERV014-N1$' When I run the vbs script from my sql server it works C:\Program Files\NSClient++\scripts>cscript check_sqldbsize.vbs serv014-n1-sqlw\wrestling wrestlinghistory 5000 9000 Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved. OK: WRESTLINGHISTORY database size is 3 MB. . I have another SQL 2012 Server running not clustered and it works fine from cmd prompt and from my Nagios server. The "Login failed for user 'MYDOM\SERV014-N1$'" is the problem

1. I do not know why when running this on the Nagios server it is trying to use that account.

2. On the SQL Server the SQL Logs show this
Login failed for user mydom\serv014-n1$reason Could not find a login matching the name provided client 10.2.88.28 I can not add serv014-n1$ to the logins on the sql server.

Any ideas?

Thank you

Tom
0
I have the script below that was expertely done by Bill on here but I have other issues that I need to add to it if poss.

What I need to do is after they all split into the file sizes I need them moved from X:\DOWNLOADS\SPLIT to C:\DOWNLOADS and then if poss every new folder that  was created  I need it to add a .exe file called "player.exe" .

Is that possible.
Option Explicit

' Global variables
Dim strBaseDir, strDestDir
Dim objFSO, objFile
Dim arrFiles(), i
Dim lngFolderSize, intFolderNumber, strNextDir, intMoveFile

' Define paths to work with

' Global variables
Dim strBaseDir, strDestDir
Dim objFSO, objFile
Dim arrFiles(), i
Dim lngFolderSize, intFolderNumber, strNextDir, intMoveFile

' Define paths to work with
strBaseDir = "B:\EE\EE29124343\base"
strDestDir = "B:\EE\EE29124343\dest"

' Set maximum size of new folders
Const cMaxFolderSize = 500000000

' Define class that will hold file information
Class File
Public lngSize
Public strPath
End Class

' Create file system object
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")

' Fully resolve paths
strBaseDir = objFSO.GetAbsolutePathname(strBaseDir)
strDestDir = objFSO.GetAbsolutePathname(strDestDir)

' Make sure the folders exists, exit if not
If Not objFSO.FolderExists(strBaseDir) Then
WScript.Echo "*ERROR* Folder does not exist: """ & strBaseDir & """."
WScript.Quit
End If
If Not objFSO.FolderExists(strDestDir)

0
Is there a way to reprogram a shortcut icon so users cannot pin it to the taskbar on Windows 7?  I found this link where you can disable pinning for a certain string, but I don't want to include that in the name of the shortcut.  Anyway of doing something in Powershell or VB?

https://docs.microsoft.com/en-us/windows/desktop/shell/appids

If any of the following strings, regardless of case, are included in the shortcut name, the program is not pinnable and is not displayed in the most frequently used list:

Documentation
Help
Install
Remove
Setup
Support
What's New
1
Hi Experts,
On my classic ASP page I'm displaying a record like this:
<%=rs("UserID")%>

UserID always has to be 6 characters, e.g. 123456
When it's less than 6 characters I would like to display zeroes in front of it, e.g. when UserID is 23456 I would like to display it as 023456
0
I have a folder which has multiple other sub folders inside it and in each of those sub folders there are different files and only one htm file.

the htm file contains table and text.

Currently, i am manually opening these hundreds of htm files and searching the words and then i put them manually in an excel file

Please see attached example file of Excel .

Product231
Product575
Product7867
Plastic
Rubber
Iron
PVC
Pipe
Liquid
Shell
Stone
Brick
Book2.xlsm
1
Hi Experts,
I'm looking for either a VB function, script or DOS command that should do the following
remove all spaces from the all column names of a given excel sheet (or CSV file).
this should combine two words into one like "visit date" column should become VisitDate.
Thanks
0
Hi All

I have a really hard script that I need desperate help on. If anyone can help so that I can schedule to run over night, every night? PS my scripting knowledge is as good as a hamster.

I need help creating a powershell script and or VB scripts for Exchange online to automatically add contacts and add them to a mail enabled group (not public folder or tradition distribution list).

Step one
convert a xlsx file in to a csv files (this xlsx file is created every night probably with a different file name every night).  The cloumns in the cvs will be first name , last name, ExternalEmailAddress, OrganizationUnit.  I will probably have a batch file run to delete any other excel or csv files in this folder before the new xlsx file is created

step two
To be able to run a scheduled powershell to automatically connect to exchange online without any interaction

I got as far as this but it keeps prompting for username and password:

Set-ExecutionPolicy RemoteSigned -Scope Currentuser
$credential = get-credential Import-Module MSOnline Connect-MsolService -Credential$credential
$ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential$credential -Authentication "Basic" -AllowRedirection
Import-PSSession \$ExchangeSession

step three
Delete all of my contacts in exchange on line

Step four
Using the converted CSV file automatically import contacts to a exchange …
0
Hi Bill,

You amended some code for me a few weeks ago which worked perfect.. see code below

Option Explicit

' Define files and folders to work with (NO TRAILING BACKSLASH)
Const cBaseDir = "b:\ee\ee29122035\files\[[DATE]]"
Const cControlFile = "b:\ee\ee29122035\list.csv"
Const cDelim = ","

' Text file I/O constants
Const ForWriting = 2
Const ForAppending = 8

' Declare global variables
Dim objFSO, strBaseDir, strControlFile, strDate
Dim arrControl, strControl, arrFields, i, arrTemp
Dim strOldName, strNewName, strOldPath, strNewPath

' Create file system object
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")

' Get date in YYYYMMDD format
strDate = Year(Now) & Right("0" & Month(Now), 2) & Right("0" & Day(Now), 2)

' Resolve file paths
strBaseDir = objFSO.GetAbsolutePathname(Replace(cBaseDir, "[[DATE]]", strDate, 1, -1, vbTextCompare))
strControlFile = objFSO.GetAbsolutePathname(cControlFile)

' Make sure base folder exists
If Not objFSO.FolderExists(strBaseDir) Then
Wscript.Echo Now & " ERROR: Base folder does not exist - " & strBaseDir
Wscript.Quit
End If

' Make sure control file exists
If Not objFSO.FileExists(strControlFile) Then
Wscript.Echo Now & " ERROR: List file does not exist - " & strControlFile
Wscript.Quit
End If

' Load csv file into array
.Close
End With

' Loop over each control record and process

0
I need to be able to separate child nodes and apply logic

my XML Source: https://vpic.nhtsa.dot.gov/api/vehicles/decodevin/ZPBUA1ZLXKLA00941?format=xml

For some reason the text values are concatenating but I want them to be broken out by the Node name and value.  I put notes in the code.  The Code DOES work just not how I need it.


<%

url = "https://vpic.nhtsa.dot.gov/api/vehicles/decodevin/ZPBUA1ZLXKLA00941?format=xml"

' add a BASE HREF tag
Dim xmldoc
dim xmlhttp

Response.write "<BASE HREF='" & url & "'><P>" & url  & "<P>"

set xmlhttp = CreateObject("Microsoft.XMLHTTP")
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlhttp.open "GET", url, false
xmlhttp.send ""
'response.write xmlhttp.responsetext

xmlDoc.async = False

State = ""
' WORKS ...Set NodeList = xmlDoc.getElementsByTagName("*")
'Set NodeList = xmlDoc.documentElement.selectNodes("/Response/*")
'Set NodeList = xmlDoc.documentElement.selectNodes("/Response/Results/*")
Set NodeList = xmlDoc.documentElement.selectNodes("/Response/Results/DecodedVariable")
'Set NodeList = xmlDoc.documentElement.selectNodes("/Response/Results/DecodedVariable/*")

For Each Node in NodeList

'I NEED SOME SORT OF LOGIC HERE
If Node.tagName = "VariableId" Then
'

0
Hi

Im trying to find someway that I can get it to look through the sub folder DOWNLOAD and then merge the individual files into another sub folder 1,2,3, etc and are all up to 4 gb in size.

I.E
lets say in sub folder DOWNLOAD I have files that are  1gb , 500mb , 200 mb,  300 mb, 2gb ,2.5 gb , 3gb,  3.5 gb,  and what I need to do is to make up to 4gb so merge  files 1gb , 500mb , 200 mb,  300 mb, 2gb  into a new folder called no 1 and then carry on through naming the new folders no2 onwards  again all upto 4 gb in size.

If I have a file thats 2 gb and then next one is 3.5 gb I DO NOT want part of the 3.5 gb file split but just to add to a new folder.

The type of files that I want to merge are video files.

Can I do this and hope it not too confusing.

Thanks
0
Hello experts,

I am looking for a script in order to get the process view of task manager in a csv file.

The various values should be displayed as they are displayed in taskmanager: CPU %, Memory MB etc;;.

If you have already a script that output automatically this type of information could you please share with me?

Thank you again for your help.
0
I'm running a Robocopy using vbs, on a machine using Win 10 Professional.  When I run it using Task Scheduler I get
Error 3 Accessing Source Directory

When I run it from a cmd window, not as an administrator, it runs with no problems.

Task Scheduler is set to run as a user that has administrator rights

What am I doing wrong
1
I have a script from: https://www.experts-exchange.com/questions/29123692/PowerShell-script-to-format-data-in-Clipboard.html#a42719419
I'd like to take additional actions on certain fields such as IP Address, we'll use aaaa for that
INPUT
aaaa:8.8.8.8
bbbb:80
cccc:3333
dddd:FC-FC-48-11-22-33-44 -55
eeee:443
fffffff:66666

Not only do I want to eliminate the cccc and fffffff lines like in the previous question, I want to do an NSLookup on the data after the aaaa:
and if the IP resolves, append the response. If eeee: exists, look up in a csvfile what port 443, HTTPS if not listed in csv, output Unknown. Same for Mac address (dddd: in this case), look up in a CSV what the first 3 octets correspond to (FC-FC-48, Apple/Mac)

I'd like it to be easy to do more actions like that with the data that might exist after the keys. I think I can figure it out with a few examples.

Output would now be:
eeee:443 HTTPS
dddd:FC-FC-48-11-22-33-44 -55 Apple/Mac

Thanks!
-rich
0
I need vba script that will run in msaccess that opens a power point presentation, update the links and saves the presentation
(office 2016)

presentation name: f:\test.pptx

I am a newbe so I would appreciate it if the script contains all code to execute.

Thanks,

WillieCg
0
I'd like to have a PowerShell script that reads the contents of my clipboard, parses and formats the data, then re-writes the clipboard so I can paste it in formatted.
The entire process is, copy data to clipboard, press hot-key shortcut to the script (ctrl+alt+q for example), script re-writes the clipboard, then I paste clipboard to destination.

I have data like this:
---------------
INPUT:
User Name: Grace Jones
Domain: Forrest-1
OU: Sales and Engineering
Department: Sales
Manager: Gus Fring
Location: ABQ
Computer Name: AsdfNiner5er
---------------
The output I'd like only certain fields, in a certain order, not all fields are present with each copy, sometimes Mac-Address: isn't there, or IP: isn't populated. Basically you can not assume that any one of the lines above will be present and or not populated. "IP: x.x.x.x" may be missing entirely, or "Mac-Address: " might not be populated after the colon. When they are not present, and or not populated, I don't want to see them in the output either.
Output:
IP: 10.10.10.10
User Name: Grace Jones
-----------
There are dozen's more input fields , and a few more the output, but that's the basic's. I figure "get-clipboard" and "set-clipboard" will do the trick nicely, I just have no idea about the parsing/formating.
Thanks!
-rich
1

# VB Script

37K

Solutions

20K

Contributors

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.