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 am new to C# core and I come from a VB forms background.  I have been working on a web application project using the latest asp core.  

All i am trying to do at the moment is have a page where you enter a serial number then on leaving that serial number it comes back and displays some additional information from a stored procedure in a grid on the page or it displays an error from the stored procedure.  Then there is another button that will fire another stored procedure that will insert data into a database or return an error on error checks.   If not an error the whole page resets and ready for the next one.

The problem I have been having is that i cannot work out how to fire the stored procedure and return the data after leaving the text box and display an error if needed.  To simply it I have added a button so I enter the serial number then press the button rather than get the on leave event from the text box.

My problem is the data is binded before the page loads with some default data.  I do not know how to do it part of the way through or how to pass a parameter (serial number to it).  I have the ajax to call a function that displays the data from before, but i do not know how to change the lookup to be based on that serial number.  Or in the case of being an error display an error.

My code is below:
Model class:
public class OperationsData
    {

       public string Job { get; set; }
       public string Item { get; set; }
       public string…
0
Exploring SharePoint 2016
LVL 13
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Hello experts,

The VB Script reported bellow allows me to append multiple files into a single file:

I would like to simplify  and take into account the following requirement:
1-Instead of move csv files into Archive folder, I would like to move to YYYYMMDD_HHMMSS Archive sub folder
2-Add in last available columns of appended csv name and creation date of each file involved by the append process
3-Generate appended file into a Result folder and log file into Log folder instead of InputFolder
4-Generate appended file with YYYYMMDD_HHMMSS date stamp instead of YYYYMMDD to avoid error message when execution is performed the same day

If you have questions, please contact me.

Thank you for your help.

'Create the file system object for creating folders:
Set objFSO = CreateObject("Scripting.FileSystemObject")


' Text file I/O constants
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const TristateTrue = -1
Const TristateFalse = 0
Const TristateUseDefault = -2

' Define folders and files to work with

strScriptName = Replace(WScript.ScriptName, ".vbs", "", 1, -1, vbTextCompare)
strScriptDir = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
cInputFolder = strScriptDir & "\Input"
cArchiveFolder = strScriptDir & "\Archive"
cMergedFile = strScriptDir  & "\Input\[[STAMP]]_Reported_Name.csv"
cHeaderFile = strScriptDir & "Header.csv"
cLogFile = strScriptDir  & "\Input\[[STAMP]]_[[SCRIPTNAME]].log"
cHeaderLines =1
cDelim = ";"



' Get date 

Open in new window

0
I am attempting to hack together a VBScript that will:

- get last logged on user
- copy a .lnk file to the logged on user's dektop.

I've got the last logged on user but I'm having trouble with the simple file copy.

 Dim filesys, FSO, WSHShell, Regkey, Username, strFile, 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")
DesktopPath = "C:\Users\" & Username & "Desktop"

Set objShell = WScript.CreateObject("WScript.Shell")
currentFolder = objShell.CurrentDirectory
Set filesys = CreateObject("Scripting.FileSystemObject")
filesys.CopyFile currentFolder & "\IRM Training Landing Page.lnk", strDesktop, true 'boolOverwrite

Open in new window

0
Hi All,

Hope your well,

I have a VB script which is nearly there but just a small part missing.

The script is being configured to delete certain contacts with a particular attribute set. Within that subset of contacts with this particular attribute im also adding some additional logic to not delete all of them e.g.

as an example: I look for contacts with extensionattribute1 set with "SPECIALATTRIBUTE", I then say, if email address 2 is populated DO NOT DELETE, move on to the next. My aim is to delete all of these contacts without an email address 2 set. The bit where im stuck is that I'm also trying not to delete contacts that have a certain domain e.g outlook.com but im not sure on the contains context. My ultimate goal is to look for contacts with a particular attribute, keep the ones that have an Email2address set and if their email1address contains outlook.com and then delkete the rest that do not match these conditions.


Set objRecord = objItem.Find("[Extensionattribute1] = ""SPECIALATTRIBUTE""")

While Not objRecord Is Nothing
     
      If objRecord.Email2Address = "" And objRecord.Email1Address <> "*OUTLOOK.com" Then objRecord.Delete

      Set objRecord = objItem.FindNext

Many Thanks.
0
Hi All,

Hope your well,

I have a VB script which is nearly there but just a small part missing.

The script is being configured to delete certain contacts with a particular attribute set. Within that subset of contacts with this particular attribute im also adding some additional logic to not delete all of them e.g.

as an example: I look for contacts with extensionattribute1 set with "SPECIALATTRIBUTE", I then say, if email address 2 is populated DO NOT DELETE, move on to the next. My aim is to delete all of these contacts without an email address 2 set. The bit where im stuck is that I'm also trying not to delete contacts that have a certain domain e.g outlook.com but im not sure on the contains context. My ultimate goal is to look for contacts with a particular attribute, keep the ones that have an Email2address set and if their email1address contains outlook.com and then delkete the rest that do not match these conditions.


Set objRecord = objItem.Find("[Extensionattribute1] = ""SPECIALATTRIBUTE""")

While Not objRecord Is Nothing
      
      If objRecord.Email2Address = "" And objRecord.Email1Address <> "*OUTLOOK.com" Then objRecord.Delete

      Set objRecord = objItem.FindNext

Many Thanks.
0
Working on a VB Macro for our ERP system and wanted to get some inputs. After searching through countless threads I came up with this code.
So after the user saves the form it triggers the macro. The macro then check to see if any parts on the order line either either part # 43810 or 80355. If it matches prompt the user for a serial number. It then records that Packlist ID, Packlist Line No, and Serial Number to table. So that part is working awesome. Now the next level to this is I we want it to check the
database to make sure there is no duplicate. When they enter in a duplicate now it throws a SQL error and closes out the pop up box.

I think to solve this I need to add in another IF than where it runs a query

"select serial_number from RIP_ODMSERIALNO where serial_number = " & _ (key)

if it does not return any record then proceed with the insert but if it does  Then respond with a message box "Duplicate Serial Number Detected, Please Verify Serial Number"



User Prompt
10-14-2019-2-52-23-PM.png

Dim strCnn
Dim SQL
Dim rs

Dim strServerName
Dim strDatabase
Dim strUserName
Dim strPassword


'*****************************
'SQL Server DB Connection info
'*****************************
strServerName="Server"
strDatabase="DB"
strUserName="USer"
strPassword="Pass"


strcnn="Driver={SQL Server};Server=" & strServerName & ";Database=" & strDatabase & ";Uid=" & strUsername & ";Pwd=" & strPassword & ";"
Set Conn = …
0
Hi Experts,

I've been working on this powershell script and need some help with a couple of things.  The script will be called from this vbscript to pass the computername or listofcomputers variables.

What I'd like expertise or help with is:

1. I've tested calling this from the VBScript Code in top comments section, but didn't get the computername variable to pass down.  (this would be done from the vbscript above, but wanted just a test wrapper to test).  EDIT:  If this is too difficult, I'd like to set it up to pull from a list of computers.

2. I'm first running "Test-MyConnection" (if) the computer is online, I'm then calling a executable.exe.  This is the part I'm having issues with - I don't necessarily want to run a .exe here, but call an SCCM advert (pasted below from client center), or, I also have a vbscript that runs the advert I could call out to.  This advert would exist locally on every computer.  The part I'm unsure about, or how to code is having this advert run on each computer in the list of variables


SCCM Advert Code:
 get-wmiobject -query "SELECT * FROM CCM_Scheduler_ScheduledMessage WHERE ScheduledMessageID='SCCM00001-SCCM00002-5D2960FE'" -namespace "ROOT\ccm\policy\machine\actualconfig"
 

Open in new window

0
Trying to accomplish the following, oBdA provided me with the process script, but I'd like to build on it.  If anyone can help, it would be greatly appreciated!

Have a powershell script that can be called from a vbscript and pass the parameter defined in the vbscript to the powershell script. In vbscript, I can call with this code, but not sure how to pass the parameter (computer) for example defined in vbscript...
'Set objShell = CreateObject("Wscript.Shell")
'Objshell.Run("powershell.exe -noexit .\test.ps1")

Open in new window

Powershell Script I'd like to do a few things:
• Check if the computer is online or offline.
• if computer is is offline, exit and send an email
• if the computer is online, run the below script that will check for running processes.
• if the below has anything other than return code 0 (meaning process is still running), have send email
• if the below has a return code of 0 (meaning no processing running), run an executable and invoke some SCCM commands.
 $computerName = 'RemoteMachine' ## Set to $null to run locally
$processList = @'
    "Name",             "Expected",     "Running"
    "cmd",              "1",            "0"
    "powershell",       "1",            "0"
    "OfficeClickToRun", "2",            "0"
'@ | ConvertFrom-Csv | ForEach-Object {$_.Expected = [int]$_.Expected; $_}

$splat = @{}
If ($computerName) {
    $splat['ComputerName'] = $computerName
    Write-Host "Testing processes on $($computerName)" -ForegroundColor Yellow

Open in new window

0
Hi Experts,

I've a batch script for pinging multipal ip's, now i want convert this batch script to C# Windows Forms App (.NET Framework) & run ping with start button.

Please Suggest ?
COLO.txt
COLOPINGLOOP.txt
0
I created a code for my database to open a recordset and view, edit and update the table, I can't get the code to open the table...

Option Compare Database
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String

Private Sub CustomersRecordset()

    strSql = "Select * FROM tblCustomers;"
   
Set db = CurrentDb
Set rs = db.OpenRecordset("tblCustomers")

End Sub
0
CompTIA Network+
LVL 13
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Hi

I am finding a script to update email signature when a user login our network.

The mechanism is simply copy a pre-created signature in server to their signature folder (%userprofile%\AppData\Roaming\Microsoft\Signatures\)

For example
Copy server\%username%\*.*     %userprofile%\AppData\Roaming\Microsoft\Signatures\  
Copy server\%username%\user1_files     %userprofile%\AppData\Roaming\Microsoft\Signatures\

This is to copy all files by *.* and the folder name "user1_files"

But I cannot find the VBScript. For DOS, it can only copy files. I don’t want to create a folder method because I may use Excel to generate the script if using DOS.

Anyone can help?
0
I need to implement Google reCaptcha on an old ASP.NET VB Webforms platform and I need a complete code that would help me do that.

I haven't done VB before and have done some webforms development long time ago.

I have followed the instructions of the following link but can't seem to get it right.  I have added the Assembly Recaptcha.dll on the frontend code with the associated VB code inside a <script runat=server> tag just like the guide and after recompiling and replacing the compiled code on the site, it doesn't seem to be able to load the Assembly and pops out the following error message,

Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: Could not load file or assembly 'Recaptcha, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)

Source Error: 

Line 1:  <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="register.aspx.vb" Inherits="Website.Members.clsRegister_Page" %>
Line 2:  
Line 3:  <%@ Register TagPrefix="uc1" TagName="ucMessageBox" Src="../controls/ucMessageBox.ascx" %>

Open in new window


All in all if you could help with with the exact implementation code, I would really appreciated it.
0
Anyone know how to get S.M.A.R.T. drive info from vb.net?

https://code.msdn.microsoft.com/Working-with-Windows-d2509544
https://www.thewindowsclub.com/hard-disk-drive-health

i.e. id like to call a function and have it return if the drive is OK or having issues. Being as smart is enabled and we can query WMIC, id think this is possible. Anyone know how i could modify the above code examples to get that?

Thanks!
0
I have a large file that I need to separate out based on information contained on certain lines contained within that file.  I got a great answer on a similar question previously.  The difference is that the file(s) that I am working with now are RTF files.  I have posted an example below.  

{\rtf1\ansi\deff9{\fonttbl{\f9\fnil\fcharset0\fprq2 Arial;}{\f8\fnil\fcharset0\fprq2 Lucida Console;}}{\colortbl;\red0\green0\blue0\;\red255\green0\blue0\;red0\green127\blue0; red0\green0\blue255;}\pard{\f9\fs18\par \b0 Patient Name Test haley\par \b0 Encounter Date: Dec  2 2003  9:11AM\par \b0Location Name: GCPeds}

This is the first part of the file.

Basically what I need is for the file to separate into smaller files, naming the file with what it finds after the "Patient NAme" and "Encounter Date" using those values to name the new files.  There is quite a bit of data following this section that would be contained in the individual files.

Thanks.
'
0
Hello,

Is there an AutoHotkey script/command that will enter data from a spreadsheet or CSV file into webpage fields?

For example, suppose a website page has the following three fields followed by a Submit button:

Field 1: First Name
Field 2: Last Name
Field 3: Date of Birth
[Submit] button


And suppose you have a spreadsheet (or csv file) which contains several hundred records (rows), each with the following three column headings: First, Last, & DOB, respectively.

Is there an AutoHotkey script which will populate the webpage fields so that the data from the spreadsheet does not have to be entered manually?

I realize the most efficient method would be to upload the full file to the website. However, suppose this particular website does not have that capability (to accept the full file). In other words, suppose the only way to move the data to the website is to populate each field for a single record, then click the Submit button, then repeat that process for each subsequent record.

I can do the above by using a looped script which Copy/Pastes each field as it bounces back and forth between the spreadsheet window and the website (shown here as code and a screenshot with comments):

Loop, 99				
	{			
		Loop, 3		
			{	
				WinActivate, [spreadsheet name]
				Send ^c
				Send {Tab}
				
				WinActivate, [website name]
				Send ^v
				Send {Tab}
			}	
		Click, [xPos], [yPos]		
				
		WinActivate, [spreadsheet name]		
		

Open in new window

0
Invalid_use_of_Null:_'cdate',

I am getting above ASP 500 internal server error when i try to hit below code. But i am unalbe to find cdate in code.

count.asp, chkShowCriteria=on&cboProduct=ALL%7CALL&cboWorkOp=ALL%7CALL&RefreshRate=10&txtPast=5&txtFuture=5&chkShowDay=on&chkShowProcess=on&chkShowConfirm=on&chkShowCollate=on&chkShowAudit=on&chkShowDelay=on&chkShowPend=on&txtIsSubmitted=true|19|800a005e|Invalid_use_of_Null:_'cdate',


Date are used like below
<input type="text" id="txtPast" name="txtPast" size=1 maxlength="2" value="<%=server.htmlencode(txtPast)%>">&nbsp;Number of PAST days to display.<br>
                                                                                    
                                    <input type="text" id="txtFuture" name="txtFuture" size=1 maxlength="2" value="<%=server.htmlencode(txtFuture)%>">&nbsp;Number of FUTURE days to display.<br>
0
Hello, We are trying to create a recurring mailing using Outlook 2010. When we try to use the following code from Microsoft we can't get it to work:     Sub Item_PropertyChange(ByVal Name)    Select Case Name     Case "Status"             if Item.Status = 2 then '2 = Completed                     Set NewItem = Application.CreateItem(0)                    NewItem.To = "myemailaddress@myisp.com"                    NewItem.Recipients.ResolveAll                    NewItem.Subject = "This is the message subject text"                    NewItem.Body = "This is text that will appear in the body of the message."                    NewItem.Display             End IF     End Select     End Sub

Is there a VB or Powershell script that would enable us to do this?
0
I want to create a desktop shortcut to place on the desktops of my teammates that gives them access to the 500+ other employees of the City. There are times that they know the DEPARTMENT , or the FIRST NAME, OR the LAST NAME OR the TITLE of the person they are trying to contact.

I would like to create an MsAccess query that when the shortcut executes it give the team member a list to select the type of query they wish to use based on their knowledge of the person they are trying to contact. Once the criteria (Department, First Name, Last Name, of Title) is selected as parameter Query is run to compete the search and present the contact information the the use.

I can use a query, VB Code, or a Macro, I am jut not sure how to present the selection criteria to the user. I have a query built that allows them to select the department and then present a list of contacts that includes the individuals in the department. But I would like to refine it so that the teammate can pull up just the name and phone number of their contact quickly and efficiently. I also want the shortcut to "stay on top" and be visible to the user regardless of what program or browser they are working in. An Access Data Documenter file is attached to my post that shows the data definition of the two files and my present parameter query.

Thank you in advance for considering my project.
Object-Definition.pdf
0
We have normal win10 users without the permission to install apps. What id like to do is to have them run my VB app when they login and have it still be able to have elevated permissions to do software installs.

I.e. it would launch non-elevated but maybe a GPO could allow that specific app elevated admin permissions?

Is this possible?
0
Become a Certified Penetration Testing Engineer
LVL 13
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Greeting Experts,

I have been attempting to create a PowerShell script to zip up a folder in Windows Machine but due to a current process running the script stops. when it starts to archive that file in the desired windows Folder (i.e.  C:\users\username\Documents\outlook\archive.pst).  I am hoping somebody can help me create a script to first, look at the files (example: .pst files) and stop the process using that file. second, zip up the file directory (i.e. C:\users\usernames\Documents\*) in question and complete.  

Any help would be appreciated
0
We are getting an error running a SOAP request on a particular machine:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

Opening the URL up in a browser the page appears fine - it provides the usual wsdl definitions of the service.

URL: https://myswebservice/MembershipWebService.asmx?wsdl

The code is actually some VB script

set ws = CreateObject("MSSOAP.SoapClient30")
url = "https://myswebservice/MembershipWebService.asmx?wsdl"
ws.MSSoapInit(url)

Open in new window


I've run Wireshark on it to see if it gave any clue as to what the issue is - the same script works fine on other machines, there is clearly something about this setup that - I've attached the Wireshark results, I'm no network expert so I didn't get much from the report but maybe someone will be able to help?
0
An Excel workbook contains Sheet1.xls, and Sheet2.xls.
On Sheet1.xls starting from A2,
Data exists all separated by commas.

For example
07/11/2019,Description,Size,11:06AM

I would like to take the data which is only in A2, in Sheet1 which is separated by commas and transpose that data into each corresponding line and column,
in Sheet2.xls

For example, in Sheet2,xls
A2 would contain data 07/11/2019
B2 would contain data Description
C2 would contain data Size
D2 would contain data 11:06AM


Is there a script which can be run so that when data appears in A2, in Sheet1.xls
it will parse the data and enter it into the corresponding line and by column in Sheet2.xls?

Keeping in mind that once data also appears in A3 in Sheet1.xls, that the data would be copied into
Sheet2.xls, however starting from A3, and then into B3, C3, D4 ..

Whenever data appears in the A column in Sheet1.xls that it will be parsed and copied into the corresponding line in Sheet2.xls

Can this be achieved with script or a macro, and be automated?

Thanks for your help.
0
I have a website on windows server 2016 host with IIS. And the using of MSSOAP30 is not working.

I tried to register the dll MSSOAP30.dll in module in IIS but it did not change anything. Below is the line of code wich is not working.

Dim soapClient

Set soapClient = CreateObject("MSSOAP.soapClient30")

Open in new window


The error message below

Microsoft VBScript Runtime Error '800a01ad' Error

An ActiveX component can not create an object: 'MSSOAP.soapClient30'

Open in new window

0
We have a client using Sage 100 v2016 Standard and it uses links to call VBscripts that essentially extracts data out of sage and creates a file in a certain network path (e.g., U:\sage\folder).

They recently set up a new server (Windows Server 2016 Standard) and migrated the application and files over. Now we are getting an error in the VBscript itself stating the following:

MSScript Link error
OLE Error Number: 76
Description: path not found
Language: VBScript

The exact language of the line of code reads as follows: Set objLogFile = objFSO.CreateTextFile("U:\sage\folder\)" & sLoadFileName, ForWriting, True)

The strange thing is there is 1 workstation and an RDS host it does not work on but there are two other workstations it DOES work on (RDS host running Windows Server 2012 R2 and workstations are Windows 10 Pro). Secondly, we have verified the path is accessible on that computer and permissions seem to be set properly (currently logged on user has modify writes to target folder). Also both workstations (one that works and one that doesn't) both have Windows firewall on and server has exceptions in AV for that folder.

Any ideas as to what might be going on?
0
Hi, I have main form work order which contains  continuous subform workorderpayitem...this means each workorder will have many workorderpayitemsID
Now i added new field called rownum in workoderpayitem table
this row num should display row numbers in the subform but it should display rownumbers as per workorder not numbers as per workorderpayitem form
to be more precise,, say i have workorder1 which has 5xworkorderpayitems so now that row number should display 1,2,3,4,5 in that bound textbox rownum only for that workorderpayitems which are there in workorder
for this i have created function Public Function ShowRecordNumber() As Integer

Me.RecordsetClone.Bookmark = Me.Bookmark

ShowRecordNumber = (Me.RecordsetClone.AbsolutePosition + 1)

End Function
and i am calling that function in rownum before update event
me.rownum.value = ShowRecordNumber()
but it's not displaying any value in the text box
so i tried to call that function in sql query ---ShowRecordNumber() as rownum
but it's throwing up error  undefined function
FYI i place this function in subform vb code at the top

apart from this i also used DCount("*","WorkOrderPayItem","WorkOrderPayItemID<=" & [WorkOrderPayItem].[WorkOrderPayItemID]) as rownum in sql query but it's showing rownumber considering all values in subform ..not based on particular workorder
also in subform user may delete some records so that means it must auto change that value(say if record 3 is selected then rownum 3 must point to…
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.