[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

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
Build an E-Commerce Site with Angular 5
LVL 12
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

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
0
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
Google-Seach-Box-via-vb-ie-control.jpg
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\"
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

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

Using VB studio I am playing with Azure ARM templates. I have it all working but have one question.
When using a blank project, I chose resources of two VMs and one Availability set all within the same new resource group.

I deployed the project and all got created, but, I had expected the two VMs that I had in my project to get added to the Availability Set that was also part of the new resource group. Instead, I got the resource group with the VMs and AV-set, but the VMs were not joined. Is there any way of these being added at deployment? Perhaps I just don't understand, and these have to be added afterwards?

Can someone please let me know.
Thank you.
Jay
0
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,
Vicki
1
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

0
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 ForReading = 1
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
With objFSO.OpenTextFile(strControlFile, ForReading)
    arrControl = Split(.ReadAll, vbCrLf)
    .Close
End With

' Loop over each control record and process 

Open in new window

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
          bresult=xmlDoc.loadxml(xmlhttp.responsetext)
       
       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		        
		        ' 

Open in new window

0
Hi

I have the following  C:\DOWNLOADS\DOWNLOAD of which holds more individual files

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
I need help with vbscript that can refresh a web page (  Internet Explorer and Firefox )
 I need to call it as a function whenever I want to refresh a webpage for IE or for Fire Fox
1
Introduction to R
LVL 12
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Hello experts,

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

2018-10-30_11h04_42.png
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
aaaa:1111 google-public-dns-a.google.com
dddd:FC-FC-48-11-22-33-44 -55 Apple/Mac

Thanks!
-rich
0
Hi All
I have a simple vb script that opens IE window and navigates to a link:

Set oIE=createobject("internetexplorer.application")
Do While (oIE.Busy)
Wscript.Sleep 250
Loop
oIE.navigate "http://MyLink.htm"

Most of the time it works fine but sometimes I am getting "Invalid procedure call or argument" error on  oIE.navigate line
Is there anything I am doing wrong?

Thanks
0
Below vbscript code (.VBS)  changes Date format of one of the date column (Date)  from to "mm/dd/yyyy"  to "dd/mm/yyyy" . when saved to Excel.


Row Number|Row Action|Department|Date
123456          |Insert          |Airlines         |05/12/2016
3456              |Update       |Engineering |10/31/2014
234234         |Insert          |Arts                |2015
452435         |Insert          |Design           |2016


' Define constants
Const cExcel7 = 51
Const xlContinuous = 1
Const xlEdgeBottom = 9
Const xlEdgeLeft = 7
Const xlEdgeRight = 10
Const xlEdgeTop = 8

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

' Files to work woth
strInputFile = objFSO.GetAbsolutePathname("C:\Users\sktneer\Desktop\Input.txt")
strInputExcelFile = objFSO.GetAbsolutePathname("C:\Users\sktneer\Desktop\Input.xlsx")
strOutputFile = objFSO.GetAbsolutePathname("C:\Users\sktneer\Desktop\output-23-10.xlsx")

' Read text file into array
With objFSO.OpenTextFile(strInputFile, 1)
    arrInput = Split(.ReadAll, vbNewLine)
End With

' Start Excel, create a new worksheet
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objexcel.Application.SheetsInNewWorkbook = 3
Set dwb = objExcel.Workbooks.Add
Set objSheet = dwb.Worksheets(1)

' Initialize row index
intRow = 0

' Process each line of input file
For Each strInput in arrInput

    ' Skip all blank lines
    If strInput <> "" Then
        …
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

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.