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

Hello Sirs,

need help on this commaed in below code 'pt.PivotFields("(blank)").Visible = False     : once i run MACRO wherever is "blank"  Pivot filter shd unchecked that

Dim pt As PivotTable
Dim ws As Worksheet


    For Each ws In ActiveWorkbook.Worksheets
  

        For Each pt In ws.PivotTables

                    pt.RefreshTable
    
'pt.PivotFields("(blank)").Visible = False    
       
       Next pt
       
    Next ws 

Open in new window


Thanks
0
Cloud Class® Course: Ruby Fundamentals
LVL 12
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

WHEN I USED THIS CODE
       ElseIf operation = 8 Then
            TextBox1.Text = Math.Cos(fo)

Open in new window

"FO "IS THE FRIST NUMPER TO WRITE
AND THIS ELSE IF IS IN EQUAL BUTTON FUNCTION
AND WHN I WRITE NUMBER 30 AND PRESS ON COS BUTTON IT GIVE ME 0.154251449887584
0



I am testing a previous question I submitted a few weeks ago and just doing some random testings. I need to some help with the script that I have and some of the problem I have found.

Issue 1
' Define files and folders to work with

Const cBaseDir = "D:\iauditor_exports_folder\Audits\"

Is it possible to add datestamp format yyyymmdd to the end of the path..

so it shows Const cBaseDir = "D:\iauditor_exports_folder\Audits\yyyymmdd"

Issue 2

Test output file... The actual data I get is surrounded by double quotes then separated by a comma.
The order number shows the filename of a pdf but the output file doesn't include the extension.pdf

See below

Before
"HD_000006_972956","Plot 50"
After
HD_000006_972956.pdf,Plot 50

This is causing the script not to find any of the filenames in the relevant folder

Issue 3

When it finds the correct file for renaming - can it append the second column to the existing file from the output file

Example

New Filename ="HD_000006_972956_Plot 50.pdf

I hope you understand what I am trying to say
0
What VBScript would I need that will do the following:

*Create a text file with a copy of the windows registry
*Create a text file that lists all standard Excel options on a user's machine

Using this on 64 and 32 bit PC's
0
What VBScript would I need that will do the following:

*Create a text file with a copy of the windows registry
*Create a text file that lists all standard Excel options
0
I would like to use either a vb script or Powershell script to query a list of computers contained in a text file to find the following information:

1. Does the computer have Dropbox or Box installed? If yes, put computer name in first column of .csv file.
2. Put "Dropbox" or "Box" in second column
3. For the computers with Dropbox or Box, show the size of the Dropbox or Box folder
4. For the computers with Dropbox or Box, show the number of shared folders in the Dropbox or Box folder.

I don't need or want to see the names of the shared folders, just the number of shared folders for each computer.

Thanks,
Don
0
hay guys not sure if its able to be done or not but im trying to write a vba or vb 6. that can have the mouse hover over a word and retrieve or pull the word to a textbox on the userform

ive found a pixel picker on the order what i want to do just not sure if there is a way of manipulating it to get a word instead pixels

any help would be greatly appreciated

Private Type POINTAPI
    X As Long
    Y As Long
 
End Type
 
Private Declare Function GetCursorPos Lib "user32" ( _
     lpPoint As POINTAPI) As Long
 
Private Declare Function GetDC Lib "user32" ( _
     ByVal hWnd As Long) As Long
 
Private Declare Function GetPixel Lib "gdi32" ( _
     ByVal hdc As Long, _
     ByVal X As Long, _
     ByVal Y As Long) As Long
 
Private Declare Function ReleaseCapture Lib "user32" () As Long
 
Private Declare Function SetCapture Lib "user32" ( _
     ByVal hWnd As Long) As Long
 
Private Declare Function WindowFromPoint Lib "user32" ( _
     ByVal xPoint As Long, _
     ByVal yPoint As Long) As Long

Option Explicit
 
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    SetCapture Me.hWnd
    Me.Caption = "MouseDown"
End Sub
 
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then Me.Caption = "MouseMove - (" & X & ", " & Y & ")"
End Sub
 
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
 
    ReleaseCapture
    Me.Caption = 

Open in new window

0
What is the command line command to set the Windows time and date according to an internet time server?
0
Software uninstall script,

I am trying to find a way to uninstall two software installed on a computer. I am sure this can be done through VB script. I am looking for a solution the takes care of this two uninstalls with one click. Does anyone know how to do this ?
0
Hi,

  I'm looking for a script that will recall user group membership and the group descriptions in alphabetical order, exported to a text file or word with the person's name.
The purpose is to be able to list access when using an account as a model by.

Name
Group descriptions
Group AD names

Thank you,

Anthony


Dim arrNames()
intSize = 0

On Error Resume Next
Const ForWriting = 2

UserName = InputBox("Enter Username","Enter Username")

Set objUser = GetObject("LDAP://" & SearchDistinguishedName(UserName))
For Each strGroup in objUser.memberOf
    Set objGroup = GetObject("LDAP://" & strGroup)
    Report = Report & objGroup.CN & vbCrLf
    ReDim Preserve arrNames(intSize)
    arrNames(intSize) = objGroup.CN
    intSize = intSize + 1
Next

For Each strName in arrNames

For i = (UBound(arrNames) - 1) to 0 Step -1
    For j= 0 to i
        If UCase(arrNames(j)) > UCase(arrNames(j+1)) Then
            strHolder = arrNames(j+1)
            arrNames(j+1) = arrNames(j)
            arrNames(j) = strHolder
        End If
    Next
Next
    
Next

Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.CreateTextFile (UserName & "GroupMembership.txt", ForWriting)
ts.Write Report
WScript.Echo "Done"


Public Function SearchDistinguishedName(ByVal vSAN)
    ' Function:     SearchDistinguishedName
    ' Description:  Searches the DistinguishedName for a given SamAccountName
    ' Parameters:   ByVal vSAN - The SamAccountName to search
    ' Returns:      

Open in new window

0
Cloud Class® Course: Certified Penetration Testing
LVL 12
Cloud Class® Course: Certified Penetration Testing

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.

Dear All


              I have below vbscript created and run in window task manager, and it works well for a week, and start from yesterday i,m getting "microsoft VBScript runtime error: File already exist" , any idea ?


With CreateObject("Scripting.FileSystemObject")
.MoveFile "\\10.154.105.100\Upload from OC\*.*", "\\10.141.101.60\test"
End With



Keith
0
I using the below vbs and js from MS Access to insert a signature block and text box on the first page (0). How can I insert the signature block and text box on all pdf pages?

Path = "U:\mail.pdf"
Set APP = CreateObject("Acroexch.app")
APP.show
Set AVDoc = CreateObject("AcroExch.AVDoc")
Set AForm = CreateObject("AFormAut.App") 'from AFormAPI

If AVDoc.Open(Path, "") Then
'//write JS-Code on a variable ---- add signature and text box

js = " var name = ""sigField""; " & vbLf _
& " var type = ""signature"" " & vbLf _
& " var page = 0;" & vbLf _
& "var mySigRect =   [72,720,216,684]; " & vbLf _
& "var sf = this.addField(name, type, page,mySigRect);" & vbLf _
& "f = this.addField(""Text1"", ""text"", 0, [0,792,126,770]);" & vbLf _
    & "f.value = None; " & vbLf _
    & "f.flatten"
    
    '//execute the js code
    AForm.Fields.ExecuteThisJavaScript js



MsgBox ("Done")
End If


Set AForm = Nothing
Set AVDoc = Nothing
Set APP = Nothing

Open in new window

0
I'm trying to pull the length of an mp4 file then adjust the transition of a powerpoint slide to match it.
However, my code seems to pull the word "length" instead of the actual attribute value

Where am I going wrong?

Function GetVideoLength(VideoFilePath)
Dim fso As New FileSystemObject

VideoFolderPath = fso.GetParentFolderName(VideoFilePath)
VideoFileName = fso.GetFileName(VideoFilePath)


With CreateObject("Shell.Application").Namespace(VideoFolderPath)
    strTime = .GetDetailsOf(.ParseName(VideoFileName), 27)
    intTimeInSeconds = DateDiff("s", 0, strTime)
End With
  
GetVideoLength = intTimeInSeconds

End Function

Open in new window

0
Hi I was using VB Script to create Oracle backup every day and I was using windows server 2003,  Now I have been switched to windows server 2008 then I tried to run same vb script to create backups but it's not working, Please show below script, Do i need to replace it with other command. please help, I am using Oracle 11G database.
**************************************************************************************************************
 Public systemuser
 Public systempwd
 Public DumpFile
 Public LogFile	
 Public FolderName
 public tnsname
 Public Str1
 Public Str2
 Public Str3

 Dim retval
 Dim objWShell
 
 


 
 systemuser = "system"
 systempwd = "XXXXXX"
 tnsname = "Database1" 
 DumpFile = "DB1"
 LogFile = "DB1Log"	
 FolderName = "H:\Archive7\Dumps"


' INI file search containt *****************************

   Set objWShell = CreateObject("WScript.Shell")
  ' FilePath = objWShell.CurrentDirectory

   Set fso = CreateObject("Scripting.FileSystemObject")
 Dim myDateString
	myDateString=NOW
	myDate=replace(replace(replace(myDateString," ","_"),":","_"),"/","-")
    
If (fso.FolderExists(FolderName )) Then
else
set fol=fso.CreateFolder(FolderName )
End If
'msgbox myDateString
'msgbox myDate

Str1 = "exp " & systemuser & "/" & systempwd & "@" & tnsname &" file=" & DumpFile & ".dmp  log=" & LogFile & ".log full=Y"
'msgbox Str1

	On Error Resume Next
	Dim oShell
	Set oShell = CreateObject("WScript.Shell")
	retval = oShell.Run( Str1, 1, True)
	Set oShell = Nothing

Open in new window

0
]I need help please with vb code which will look at a file location path and for each folder/sub folder extract the details from each file  creating an excel row for every file it encounters. The folder location would need to be a variable (as this is going to be run for a number of different locations). Each row would contain the following info (columns)

Full path name; Filename; File type;  Date created; Date modified; Last saved by

So for example if a top level folder had 4 sub folders, and each sub folder had another sub folder nested under that, and each of these folders (including top folder) had two files in them, the total number of rows created would be 18, each row having the details of each file encountered and the full path name
0
We are using Epicor customization tools and need some help with passing a variable.  We know how to do it in VB but not C#   In the example below we are working on the private void epiButtonC1_Click(object sender, System.EventArgs args) event and will copycat to the other button click events once we find a solution.  There is a box on the screen where we are trying to get the information from it using the GUID and then pass it to the form we are opening.  The MessageBox in there is to check and see if the value shows up but that is not right either as it just shows "MyJob"


// **************************************************
// Custom code for MainController
// Created: 05/09/2018 2:44:06 PM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Epicor.Mfg.BO;
using Epicor.Mfg.UI;
using Epicor.Mfg.UI.Adapters;
using Epicor.Mfg.UI.Customization;
using Epicor.Mfg.UI.ExtendedProps;
using Epicor.Mfg.UI.FormFunctions;
using Epicor.Mfg.UI.FrameWork;
using Epicor.Mfg.UI.Searches;

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **
	private EpiTextBox MyJob;

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do 

Open in new window

0
Hello Experts ,
is there a batch or VB script to copy a specified DLL from a local machine to a remote machine and register it with psexec ?
if the remote machine name could be given by the user who will run the script will be great ( strinput )
also if the script can be ran without the need to enter credentials , the user who will run the script have enough access .
very appricated .
0
I have a lot of disabled users in AD.
I want to run a VBscript or PowerShell command to move the profiles and home drive data of these user to another area so that it's still available (just in case i need to restore that user) but it's not adding to my backup and filling up my data drive.

So the script need to search through all users in AD, find the home and profile directories (if they exist), ensure we have permission on the profile folder, them move the directories.
Any ideas?
0
I am trying to get information from our print server using an HTA script that lists the printers by name, then I would like it so that the administrator can select a printer then hit the next button and it will then list in a new window: Printer Location, Printer Comment, Printer Status, Printer IP and Printer Detected Error State.  Pasted below is what I have so far which is an older script found on these forums, I've tried everything I can think of to get the next button to do what I want but I am at a road block at the moment.

 
<head>
<title>Printer Information</title>
<HTA:APPLICATION 
	APPLICATIONNAME="Printer Information"
	BORDER="THIN"
	SCROLL="NO"
	SINGLEINSTANCE="NO"
	WINDOWSTATE="NORMAL"
	MAXIMIZEBUTTON="NO"
	MINIMIZEBUTTON="NO"
	ID="oHTA"
>
<APPLICATION:HTA>
</head>
<script language="VBScript">
Dim arrPrintServers
arrPrintServers = array("servername here")
'If you have more than one print server, seperate by commas i.e. arrPrintServers = array("Server1","Server2","Server3")

Sub Window_Onload()
	CALL CenterWindow(520,275)
	CALL FillMultiListbox()
End Sub
    
Sub CenterWindow(widthX,heightY)
	self.ResizeTo widthX, heightY 
	self.MoveTo (screen.Width - widthX)/2, (screen.Height - heightY)/2
End Sub

Sub FillMultiListbox()
	'Clear out the list box
	For Each objOption in MultiListbox.Options
		objOption.RemoveNode
	Next
	
	for each strPrintServer in arrPrintServers
		Set objWMIService = GetObject("winmgmts:\\" & strPrintServer & "\root\cimv2")
		Set colItems

Open in new window

0
Cloud Class® Course: Microsoft Exchange Server
LVL 12
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

I have an excel file that contains 2 worksheets called SheetA and SheetB

these worksheets contain several 1,000 records.

in SheetA i have a range called DUBO that contains 6 Columns,off which Column B and C are made empty
the other columns are occupied with info I need.
SheetB has a range called CAT18,this range contains all info of the specific records

i need to merge info between these 2 worksheets;

basically, i need a macro (or excel function) to do the following

for the range DUBO -SheetA
read column A, if the value is found in SheetB, also column A - then copy the values from Column B and Column C from SheetB to the empty column B and C from Sheet A for that record

the value off column A SheetA might not be found in SheetB columnA,that is ok,move on the next row from range DUBO
the value off column A SheetA might be found in column A SheetB, but column B & C might be empty, that is also possible, just move to the next row

this might be possible using a excel function or macro. but have no idea how this function might be called
0
I have a challenge on uploading an excel file using UFT visual basic script  to ALM resources .  I get below error message and the script I ran to upload the excel file is below the error message. Any assistance on what I am doing wrong will be appreciated.

=========================The error I got ==================================================
The test run cannot continue due to an unrecoverable error.

Type mismatch: 'oCurrentResources.Item'
Line (542): "Set oNewResource = oCurrentResources.Item(QcResourceName)".

===========================================================================



'======================================== The script  To Upload a file from Hard Drive to ALM resource ============================================

QcResourceName = "Temp Suite"
fileNameToSave = "Temp Suite.xls"
fileToSavePath = "C:\Framework\WorkArea"
Set qcConn = QCUtil.QCConnection
Set oResource = qcConn.QCResourceFactory
Set oCurrentResources =oResource.NewList("")

 
resourceCount = oCurrentResources.Count

For iNowResourceNum = 1 To resourceCount
nowResource = oCurrentResources.Item(iNowResourceNum).Name
   if UCase(nowResource) = UCase(QcResourceName) then
   Set oNewResource = oCurrentResources.Item(iNowResourceNum)
    resourceFound = "True"
    Exit For
   end if
Next

If resourceFound = "True" Then
Set oNewResource = oCurrentResources.Item(QcResourceName)
oNewResource.Filename = fileNameToSave
 oNewResource.ResourceType = "Data table"…
0
Hi Experts,
I'm looking to modify the code below to obtain all values of given Caspio table and insert them into my Access table.
Function GetDataFromCASPIO()
    Dim objHTTP As New WinHttp.WinHttpRequest
    Dim docXML As MSXML2.DOMDocument
    Dim ResponseText As String
    Dim curNode As IXMLDOMNode
    Dim oNodeList As IXMLDOMSelection

    Set docXML = New MSXML2.DOMDocument

    Set objHTTP = New WinHttp.WinHttpRequest

    URL = "https://MyAccount.caspio.com/oauth/token"
    objHTTP.Open "POST", URL, False
    objHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"

    objHTTP.Send "grant_type=client_credentials&client_id=MyClientID&client_secret=MySecret"
    ResponseText = Right(objHTTP.ResponseText, Len(objHTTP.ResponseText) - 17)
    access_token = Left(ResponseText, InStr(ResponseText, """") - 1)
    'Debug.Print access_token


    Set objHTTP = New WinHttp.WinHttpRequest
    'objHTTP.setRequestHeader "Content-Type", "application/json"
    URL = "https:// MyAccount.caspio.com /rest/v1/tables/MyTable "
    objHTTP.Open "GET", URL, False
    objHTTP.SetRequestHeader "Accept", "application/xml"
    objHTTP.SetRequestHeader "Content-Type", "application/json"
    objHTTP.SetRequestHeader "Authorization", "Bearer " + access_token
    objHTTP.Send
    'Debug.Print objHTTP.Status
    'Debug.Print objHTTP.ResponseText
    docXML.loadXML (objHTTP.ResponseText)

    strXPathQuery = "Caspio/Row"
    Set oNodeList = 

Open in new window

0
We have some upgraded going on some of our web severs.
Till that time we need check many urls manually daily.

I want to write a vb script to check urls if it is up or not and send us status report through mail.

urls address start with https:// and we need to use F5 Token and disable proxy setting to connect those server.

we don't have power shell access as well.

could somebody please help me to write a vbscript or bat script to automate these stuff.
0
I WANT TO COUNT THE NO OF INSERTS DONE IN TARGET TABLE FROM FLAT FILE SRC USING SCRIPT TASK IN FOR EACH LOOP CONTAINER DYNAMICALLY.
CAN ANY ONE PROVIDE ME THE c# OR vb SCRIPT TO COUNT THE NO OF ROWS INSERTED AND ALSO SEND THE MAIL AFTER COMPLETING THE INSERTION AND NO OF ROWS INSERTED.
0
I need a VBScript that will send all text files in a specified folder to the default printer.  Once each document is printed, I need that document moved to a "processed" folder.
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.