[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

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.

Share tech news, updates, or what's on your mind.

Sign up to Post

Greeting Experts -  

I need help creating a PowerShell script to pull text document from a list of computers (1000+) using Domain Admin Credentials. The text document in question will have the same name (i.e., pc1.txt, pc2.txt, pc3.txt) as pc located in the C:\drive (i.e., C:\pc1.txt). The script needs remotely pull the text document from each pc "with the same name as the pc" and copy it to a network shared drive....  Can somebody help me with this task.....
0
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.

Hi Experts,

I have this question after resolving the following

https://www.experts-exchange.com/questions/29127578/script-to-convert-all-characters-in-excel-sheet-to-A.html?headerLink=workspace_answered_questions

How to modify the script in order to accomplish

1- Select which columns to get obfuscated.
2- letters should be changed with a logic, A should become B, B should become C and so on...Z should become A.
3- Same to numbers, 1 should become 2, 2 should become 3 and so on, then 9 should become 0.

Thanks
0
Hello,

I'm trying to parse out some text from a string using the Len, Right, and InStrRev function.  I just can't get it right and am asking for help.  The string would be something like this:

"My Printer Redirected (123)"

I'm trying to capture "(123)".  This line always changes.  The only text that is the same every time is the text "Redirected".  So in this case:

"blah blah blah Redirected (99)"

I would need to capture the "(99)" this time.  I basically need to capture all text on the right side of "Redirected".

Thanks for your help,
Joel
0
Hello Experts,
I there a way to send messages to WhatsApp from my vb net app?
Regards
0
Hello,

I have an Outlook custom form that uses VB Script to print a label.  This works fine.  IT has since migrated Office to a virtual server.  Because of this, the issue is that every time you log on to the server, the printer name changes dynamically, like "DYMO (redirected 99)".  The "99" is the part that changes.

Is it possible to call out a printer that contains the name "DYMO" in it?  Here is the code that I use.

Sub CommandButtonShipLabelUSPS_Click()

On Error Resume Next

Dim strCurrentPrinter

      Set objDoc2 = GetWordDocLabel("\\fireglass.com\drawing$\Jobs\Task_Templates\Ship-Ship Label USPS.dot")
          Call FillFieldsShipLabel(objDoc2)
          objDoc2.Application.Options.PrintBackground = False
          objDoc2.Application.DisplayAlerts = False
          'objDoc2.Application.ActiveDocument.AttachedTemplate = "Normal"
          'objDoc2.Application.ActiveDocument.PageSetup.Orientation = 1

if Item.UserProperties("PrintHold") = True then
        Set objDoc2 = Nothing
        Set strCurrentPrinter = Nothing
        Set objWord2 = Nothing
      Exit Sub
end if

          strCurrentPrinter = objDoc2.Application.ActivePrinter ' store the current active printer
          objDoc2.Application.ActivePrinter = "DYMO" ' change to another printer

bjDoc2.PrintOut ' print the active sheet
objDoc2.Application.ActivePrinter = strCurrentPrinter

      objDoc2.Application.DisplayAlerts = True
          objDoc2.Application.Options.PrintBackground = True

objDoc2.Close wdDoNotSaveChanges
objWord2.Quit …
0
Hello,

I have an Excel spreadsheet that has a date in column A and employee name in column I.  I'd like to get a macro that will identify and delete duplicates if there is a match.  For example, there are two rows on 09/01/2018 for John Doe so the first occurrence would be deleted.

Thanks
0
How to move files from sub folders to a single folder?
0
Hi

Please can you help me convert a file call distlistcontacts.xlsx to distlistcontacts.csv located in c:\o365update\ via command prompt.  I have tried a scripts on the web and cant get them to run. Excel is not installed on the pc where the batch file will be scheduled to run from .

Regards


Simon
0
add function to classic asp page with vb script.
Is it possible to save a file temporarily and then attach it to an email in vbscript ?

If I split the code below into two distinct pages, both functions work. I can create the Vcard file and it opens to the user.  Or I can create the email.
But I want to add the vcard file to the email.  Is this possible ?
<% 
if (cStr(Request("SubmitHere")) <> "") Then

	Dim DTSTART, DTEND, SUMMARY, LOCATION, EVENT_DESCRIPTION, PRIORITY, UID, CalendarEvent
	
	DTSTART = DateAdd("h",+5, (rsSaleCallDataNewID.Fields.Item("FollowupDate").Value))
	DTEND = DateAdd("h",+5, (rsSaleCallDataNewID.Fields.Item("FollowupDate").Value))
		
	DTSTART = 	Right("0000" & Year(DTSTART), 4) & _
				Right("00" & Month(DTSTART), 2) & _
				Right("00" & Day(DTSTART), 2) & _
				"T13000" & _
				"Z"
	
	DTEND = 	Right("0000" & Year(DTEND), 4) & _
				Right("00" & Month(DTEND), 2) & _
				Right("00" & Day(DTEND), 2) & _
				"T130000" & _
				"Z"
 
	SUMMARY = (rsSaleCallDataNewID.Fields.Item("VisitType").Value)
	LOCATION = (rsSaleCallDataNewID.Fields.Item("Company").Value)
	EVENT_DESCRIPTION = (rsSaleCallDataNewID.Fields.Item("Comments").Value)
	PRIORITY = "0"
	UID = (rsSaleCallDataNewID.Fields.Item("ID").Value)
	
	CalendarEvent = "BEGIN:VCALENDAR" & vbCrlf & _
	"VERSION:1.0" & vbCrlf & _
	"BEGIN:VEVENT" & vbCrlf & _
	"DTSTART:" & DTSTART  & vbCrlf & _
	"DTEND:" & DTEND  & vbCrlf & _
	"SUMMARY;ENCODING=QUOTED-PRINTABLE:" & SUMMARY & vbCrlf & _
	

Open in new window

0
I'm having trouble using double quotes in vbscript within asp web page.  I get various errors but I'm sure it's my syntax on the quote marks:

objCDO.AttachFile "ContactManagementActivityEditVCal.asp?<%= Server.HTMLEncode(MM_keepNone) & MM_joinChar(MM_keepNone) & "varVcal=yes&" & "var_SaleCall_ID=" &  rsSaleCallDataNewID.Fields.Item("ID").Value %>"
0
Learn SQL Server Core 2016
LVL 12
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Hi Experts,

I'm looking to create a VBA function that will accept a file name as a string parameter, then rename a file as follows.
if parameter is "Skilled_Nursing_Visit_Note" then will look at given folder for file starting with that name for example "Skilled_Nursing_Visit_Note_2018-Nov-26_1901.csv"
and rename that file to just "Skilled_Nursing_Visit_Note.csv", in other words, remove the date/time and sequence timestamp from that file name.

Thanks
0
Hi,

I have this c# sub that I want to convert to vb. The main idea is to take the file contained in the filename and write it to the stream in chunks. It works fine in C# but I can't get it to work in vb.net. This is the version in c#:
 public void WriteFile(Stream stream, string filename)
        {
            using (FileStream readIn = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                readIn.Seek(0, SeekOrigin.Begin); // move to the start of the file
                byte[] fileData = new byte[BufferSize];
                int bytes;
                while ((bytes = readIn.Read(fileData, 0, BufferSize)) > 0)
                {
                    // read the file data and send a chunk at a time
                    stream.Write(fileData, 0, bytes);
                }
            }
        }

Open in new window

And this is two versions I've tried in vb without success. In the first the code jumps over the while loop and doesn't write to the stream and in the second it complains that I can't close before all the bytes are read.

 Public Sub WriteFile(ByRef stream As Stream, ByVal filename As String)
            Using readIn As FileStream = New FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
                readIn.Seek(0, SeekOrigin.Begin)
                Dim fileData As Byte() = New Byte(BufferSize - 1) {}

                Using rdr As New BinaryReader(readIn)
                    'Read BufferSize bytes from the file
                    Dim bytes(BufferSize) As Byte
                    'Dim bytesRead As Integer = rdr.Read(bytes, 0, BufferSize)
                    Dim bytesRead As Integer = 0

                    While ((bytesRead = rdr.Read(bytes, 0, BufferSize)) > 0)
                        stream.Write(bytes, 0, bytesRead)
                    End While
                End Using
            End Using
        End Sub

Open in new window


 Public Sub WriteFile(ByRef stream As Stream, ByVal filename As String)
            Using readIn As New FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
                readIn.Seek(0, SeekOrigin.Begin)
                Using rdr As New BinaryReader(readIn)

                    Using wtr As New BinaryWriter(stream)
                        ' read all bytes
                        Dim bytes() As Byte = rdr.ReadBytes(readIn.Length)
                        ' write all bytes
                        wtr.Write(bytes)

                    End Using

                    rdr.Close()
                End Using

            End Using
        End Sub

Open in new window


If someone can help me get it right I would be grateful.

Peter
0
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;
            function add_fields() {
                  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"

Open in new window


Any Ideas?

Thanks


Option Explicit
Dim fso 
 
Set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFolder "C:\Users\g\Downloads\sunday\DownLoad\*.*", "C:\Users\g\Desktop\test"

' 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
    

Open in new window

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

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

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
Copyright (C) Microsoft Corporation. All rights reserved.

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
Copyright (C) Microsoft Corporation. All rights reserved.

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
strBaseDir = "X:\DOWNLOADS"
strDestDir = "X:\DOWNLOADS\SPLIT"

' 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)

Open in new window

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
More Info
Read me
Read First
Readme
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
Thank you for your help
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
0

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.