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

I have a script in outlook 2016/2019, that popup a dialog box to choose a folder in which the mail should be saved after I send the email.
This works good.

I have additional settings in the outlook that makes me "save the reply in the same folder".
save the reply in the same folder
Now I want that the dialog box (as per the script) should popup, only when I am not replying to a mail from a folder. (except inbox)
 i.e the dialog box to choose folder should popup, only when I am composing a new email or when I am replying to email from inbox.




http://www.outlookcode.com/article.aspx?id=48
Code source

Private Sub Application_ItemSend(ByVal Item As Object, _
                                 Cancel As Boolean)
    Dim objNS As NameSpace
    Dim objFolder As MAPIFolder
    On Error Resume Next
    Set objNS = Application.Session
    If Item.Class = olMail Then
        Set objFolder = objNS.PickFolder
        If Not objFolder Is Nothing And _
          IsInDefaultStore(objFolder) And _
          objFolder.DefaultItemType = olmailitem Then
            Set Item.SaveSentMessageFolder = objFolder
        Else
            Set objFolder = _
              objNS.GetDefaultFolder(olFolderSentMail)
            Set Item.SaveSentMessageFolder = objFolder
        End If
    End If
    Set objFolder = Nothing
    Set objNS = Nothing
End Sub

Public Function IsInDefaultStore(objOL As Object) As Boolean
    Dim objApp As 

Open in new window

0
Exploring ASP.NET Core: Fundamentals
LVL 13
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Looking for an alternate to CDO.Message for sending email in a VBScript on Windows Server Core.

NOTE: While we also use PowerShell scripts to send email, we have several substantial legacy VBScripts that carry out tasks and send mail, so fully rewriting these in PowerShell will be a longer term objective. In the interim, we're in need of a workaround to the VBScript issue. Thanks.
1
I work for a small company and have been tasked with building a database application to help with some of our industry-specific tracking needs.  I am NOT a database developer or VB coder.  My experience is limited to industrial PLC programming and the occasional small Python script.  

The project includes a Form that executes an OnCurrent event which calls a Class Module (which I did not write the code for).  The purpose of the code is to acquire the Width and Height dimensions (in pixels) of an on-disk image file.  The code executes correctly if the record includes a valid image path.  However, if there is no valid path, I get the following error:
error_91.PNGat this line of code in my Form:
als315_Mod_Error.PNGHere is the code for the ImageDimensions class module:
Option Compare Database
Option Explicit

Private pPixelWidth As Long
Private pPixelHeight As Long
Private pImageFullPath As String

Public Property Get ImageFullPath() As String
  ImageFullPath = pImageFullPath
End Property
Public Property Let ImageFullPath(fullPath As String)
  pImageFullPath = fullPath
  Dim dimensionsText As String

  dimensionsText = GetImageDimensions(fullPath)
  pPixelWidth = Left$(dimensionsText, InStr(dimensionsText, ",") - 1)
  pPixelHeight = Mid$(dimensionsText, InStr(dimensionsText, ",") + 1)
End Property

Public Property Get PixelWidth() As Long
  PixelWidth = pPixelWidth
End Property
Private Property Let PixelWidth(value As Long)
  pPixelWidth = value

Open in new window

0
Hi Experts,
I am looking for a function that will read a csv file containing employees schedule date & time and identify all the overlapping records.
Below is an example of what the file looks like and what would be considered an overlapping schedule.
UnitCostCenter,EmployeeCode,EmployeeName,StartDate,StartTime,EndTime,Lunch,TotalHours,OnCallFlag,CallBackFlag,ChargeFlag
,A1236       ,J A               ,4/26/2019,3:00:00 AM,11:00:00 AM,1,7,,,
,A1236       ,J A               ,4/25/2019,3:00:00 PM,7:00:00 AM,2,14,,,

"It's because those two TS in the spreadsheet for 4/25/ and 4/26 are overlapped (just put them in correct order - TS 4/25 ends next day at 7AM ):"
Thanks
0
Hello Experts

At the moment we are running a batch file on every computer to empty the downloads folder every week, but it deletes only the files but not the folders.
could you be able to help me by creating a new batch file that clears all the contents of the downloads folder for all the user's profiles on the PCs?
we would like to know as well if we can add this on the group policy and it can deploy to all the users in the company.

Here is the one we are using which we are running from a scheduled task list.

forfiles /p "C:\Users\PofileName\Downloads" /s /m *.* /c "cmd /c Del @path" /D -0

Thank you very much.
0
Need some help with deciphering this vbscript... this script first runs a dsquery to grab all users and DN's into a file.

Basically line 12, I'm looking to grab the DN where it builds a strNullset variable to determine if @Domain or @Domain2.org - is there a way to do this in powershell without dumping out all of the users in a file, then append later in the script?

Also looking for what line 24 actually does with the "2", and also what line 29 does... ?




Set objArgs = WScript.Arguments

If objArgs.Count < 1 Then
	Wscript.Quit -1
End If
Const ADS_PROPERTY_APPEND = 3
strUserDN = objArgs(0)

Set objUser = GetObject("LDAP://" & strUserDN)
If UCase(objUser.AccountDisabled) = "FALSE" Then 
	strNullSet = objUser.sAMAccountName & "@Domain.org" 
	If InStr(UCase(strUserDN),"Domain2") Then   
		strNullSet = objUser.sAMAccountName & "@Domain2.org"
		End If
	If objUser.mail = "" Then                             
		If objUser.userPrincipalName = strNullSet Then 
		Else
			objUser.put "userPrincipalName", strNullSet    
			WScript.Echo objUser.sAMAccountName & "," & strNullSet & "," & objUser.userPrincipalName & "," & "Null"
		End If
	Else
		If objUser.userPrincipalName = objUser.mail Then  
			strO365Alias = "smtp:" & objUser.sAMAccountName & "@cchs.mail.onmicrosoft.com"
			If objUser.mailNickname = objUser.sAMAccountName & "2" Then
				strO365Alias = "smtp:" & objUser.sAMAccountName & "2@mail"
			End If
			objUser.PutEx ADS_PROPERTY_APPEND, "proxyAddresses", 

Open in new window

0
Hello experts,
I am looking for a script to :
-Upload file to an url
-Download specific and last modified file from a url
To access to this url I need to report credentials. User and password.
I heard about cUrl application however if this is possible through a build-in language such as powershell or vbscript I a prefer this approach.
As regards the upload and the download the script should manage success and error actions in a log file.
Thank you in advance for your feedback.
0
This is in addition to another question I asked earlier. The previous question I need data looked up on one tab and copied over the updated status on the other tab. Martin Liss created a nice Macro for me.

https://www.experts-exchange.com/questions/29145206/How-do-I-update-Excel-data-in-a-column-with-a-Macro-or-VB-Script.html

What I need with this is, if the machine does not exist on the SCCM DATA TAB then copy the whole row from Raw Data over to the SCCM DATA tab. Everything from Column A thru H has to be copied to SCCM DATA Tab.
0
we have some remote PCs that contain users outlook pst files.

is there any script (powershell, wmic, vbs, etc) to get for each user in that remote PC , the path of the pst files mounted in Outlook (2010, 2013, 2016)?
0
I have a spreadsheet that has 2 TABS, SCCM DATA and RAW DATA, both have Source Computer (Column A) and Migration Status (Column F), everyday I copy the raw data over from SCCM to RAW DATA, after I copy the raw data from SCCM, I would like a Macro to compare the Source computer info on RAW DATA with SCCM DATA, if the Migration Status is different, then copy the updated Migration Status to SCCM DATA.

For Example: SCCM DATA                                                  For Example: RAW DATA
Source Computer     Migration Status                             Source Computer             Migration Status
Xhostname                 Not Started                                      xhostname                       completed

so what I need is the macro to do is update the migration status of SCCM DATA with the RAW DATA Migration Status. If there is no change then do nothing.

Thank you in advance.
0
Build an E-Commerce Site with Angular 5
LVL 13
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.

I am looking for a batch, VB or Powershell script that can parse a file name for a date, and then delete that file if the Date is older than 90 days. Files will be in subfolders, so the script would need to be able to drill down into the subfolders.
Here example of file names:

2019-01-02T080219~queue~520118152~+520118152~311242d8-10ea-49ae-869c-81a43434d40b.WAV
2018-05-10T112639~call~1004~605191811~c97043a6-2bfe-44c8-bde4-b0c3596ede60.WAV
2018-05-02T144725~call~1005~151981173112~a272d339-d85e-4742-a6d0-a988ba6594ea.WAV
2018-10-23T144526~call~2411~18189199~6774130d-a249-4c18-8700-8c629bdf3841.WAV
1
Hello experts,

I am looking for a batch, powershell or vbscript to cover the following requirement:

-Loop a reported folder with drill down
-Check the various files and folder
-Replace SourceString by TargetString
-SourceString and TargetString should be reported as parameter

-Example:
BaseDir= C:\Test
SourceString= “_”
TargetString “-“

-Various files and folders which contains source string “_” should be replaced by target  “-“.

If you have questions, please contact me.
Thank you.
1
Hello experts,

I am looking for a batch, powershell or vbscript to cover the following requirement:

Loop a reported folder (no drill down needed):
-Rename the various files with reported folder name and add a numbering based on modified date from oldest to newest
-Example:
BaseDir= “C:\toto” contains filea.csv filea.xls fileb.csv
Expected result is the following:
toto-1.csv, toto-2.xls, toto-3.csv

If you have questions, please contact me.
Thank you.
0
I am experiencing an SQL 2014 Job Package that is not connecting to MS Access when the package is either scheduled or manually running it. The package connects and runs fine when I developed it in VBS with no errors. The package dtsx was deployed to SSIS in the Integration Services Catalog SSISB.

Connection String value:  Data Source=\\xxxx\xxxx\xxxx\Databases\Mmaster.mdb;Provider=Microsoft.Jet.OLEDB.4.0;
Server Name:  \\xxxx\xxxx\xxxx\Databases\Mmaster.mdb
UserName: admin
Password: [left blank as there is no mdw and the mdb is not password protected]
InitialCatalog: NULL
RetainSameConnection: False

These are the Connections available through the Connection Manager, once I select the OLEDB, then I selected the Microsoft Jet 4.0 OLE DB Provider. It tests and connects with VBS, just not in the SSIS Server Agent Jobs.
Connections-1.jpg Connections-2.jpg
0
Hello Experts,

I'd like to create a list of available dates for employees in excel. We're working on a project and I'm trying to group departments together on the dates they'll be in the office.

I've attached a spreadsheet with an example but need the formula to put it all in place - if not a formula maybe it needs VB code to get it to work as desired?

- I have the dates employees will NOT be available (Unavailable Dates in attached spreadsheet)
- I have a Holidays tab to list Holidays where no one will be available
- I have a weekday calendar that lists all the days of the week

The available dates (Available Dates tab in the spreadsheet) will be produced by looking at the weekday calendar and excluding Dates Unavailable and Holidays. At least that's what I need it to do. Once I get that part working, I can do a pivot table to group the departments on their available dates.

 I hope it all makes sense, thanks!
Available_Project_Dates.xls
0
Hi guys

I'm trying to come up with an effective way of creating a budget planning system that gives myself and the directors an idea of where we are on the project in comparison with the percentage of the budget spent.

Let's say we have signed off £100,000 for a project. We start the project and by the time 20% of the project is completed, we have burned through 50% of the budget already which, which could well be a disaster.

So two things I'm asking is:

a. Is there a way that you could apply a weighting system which would in turn give you an idea of how much of the project is done? Basically, a way of measuring the percentage of the project that has been completed/incomplete through entering data in necessary fields/excel sheets.

b. Is there a way of using the budget given to do some sort of comparison with the percentage of project completed, so that you could get an idea of what percentage of the budget we have gone through in comparison to the percentage completion of budget.

All of this would ideally be done in Excel.

Does this make sense? If it does, any input would be great. Perhaps you do it a different way and it has helped you and that input may help a lot too.

Thanks for helping
Yash
0
Hello,

We currently have a scheduled task that runs a script daily. This script is used to synchronise multiple AD security groups with the Adobe cloud. At the moment we have multiple security groups such as Adobe_Photoshop, Adobe_Indesign, etc. When a member of staff is added anyone of these security groups they are allocated a licence the next time the sync occurs. Obviously we can run this hourly but we don't want to run the script that often as it takes time.

Does anyone know how we could monitor security groups for a change and when a change occurs kick off a script? This was we can ensure that we allocate licences to our team without delay.
0
Hello experts,
I have the following vbscript that help me to move files based on extension.
I got an out of memory error message when I launch the script and one of the reported folder doesn't exist.
I think the makedir function needed to be adjusted but I don't know how to proceed.
' ==============================================================================
' C O N S T A N T S   &   V A R I A B L E S
' ==============================================================================

' Define needed constants
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const TriStateUseDefault = -2

' Specify path to folder of files to process, default destination, and log file
strScriptDir = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
strBaseDir = strScriptDir
strLogFile = strScriptDir & "\log-file.log"

' ==============================================================================
' I N I T I A L I Z A T I O N
' ==============================================================================

' Create filesystem object
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Open log file (append)
Set objLogFile = objFSO.OpenTextFile(strLogFile, ForWriting, True)

' Make sure base directory exists
If Not objFSO.FolderExists(strBaseDir) Then
    objLogFile.WriteLine Now() & " *ERROR* Base directory does not exist """ & strBaseDir & """"
    Wscript.Quit()
End If

' Create a dictionary to hold the list of extensions to move, and destination 

Open in new window

0
Hello experts,
I have .txt file (sub-procedures) in which I reported the various sub procedures that I use in my personal macro.
I listed the various procedures names in .csv file (procedures-listing)
I need a script that:
-Create the various txt files reported in csv file column b group
-Transfer procedure sub till end sub text based on the group related
-Create a txt files with the following name “Unknown-group” and transfer sub till end sub for procedures which are not reported in csv file with a related group
-Dummy files attached.
If you have questions, please contact me.
Thank you very much for your help.
sub-procedures.txt
procedures-listing.csv
0
Expert Spotlight: Joe Anderson (DatabaseMX)
LVL 13
Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

In my application Splash Screen loads at the same time with my startup form. I don't know what is causing that my splash screen vb code like below. And also i took and screenshot from application settings.

Option Explicit On
Option Strict On

Public NotInheritable Class SplashScreen1

    'TODO: This form can easily be set as the splash screen for the application by going to the "Application" tab
    '  of the Project Designer ("Properties" under the "Project" menu).


    Private Sub frmSplashScreen_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Set up the dialog text at runtime according to the application's assembly information.  

        'TODO: Customize the application's assembly information in the "Application" pane of the project 
        '  properties dialog (under the "Project" menu).

        'Application title
        If My.Application.Info.Title <> "" Then
            ApplicationTitle.Text = My.Application.Info.Title
        Else
            'If the application title is missing, use the application name, without the extension
            ApplicationTitle.Text = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
        End If

        'Format the version information using the text set into the Version control at design time as the
        '  formatting string.  This allows for effective localization if desired.
        '  Build and revision information could be included by using the following 

Open in new window

0
Good Day,
Can you please help,
I'm searching for a script (batch, Vbs, PowerShell), to login to a remote ftp, (User Name & Pwd)
delete ,bak files older than XXX days.

I Don't have access to run any scripts on the remote ftp server.
I need to run the script from my computer.

Your help is greatly appreciated.
0
Most PCs/laptops (they're old models of Dell & Thinkpad X and T series) we have do not have BIOS password set:
is there a way to remotely set the BIOS password (for the 1st time) without physically accessing the PCs/laptops?

We have Desktop Central that could spawn a command prompt (owned by SYSTEM) to all PCs/laptops or get a
GUI login (Desktop Central agent on endpoints) but we've removed PowerShell from the PCs/laptops.

VBscript can still run (though I ack VB is a vulnerability too).
0
I want to modify the Macro script to remove any value from my "Final" in the Excel file attached.
SDGM.xlsm
0
I simply created a stored procedure that inserts data from an ASP page. I keep getting an error message "Failed to convert parameter value from a string to a boolean".
 
My Stored Procedure is
ALTER PROCEDURE [Merch].[MyStoredProcedure]
	@Suppint Varchar(50),
	@VendorCode Varchar(10),
	@classgroupAllocID Varchar(10),
	@Season Varchar(4),
	@quarter Varchar(50),
	@Month Varchar(50),
	@DateAllocated Date,
	@StyleCreated Varchar(5),
	@EDIT BIT,
	@Category VARCHAR(50)
	
AS
BEGIN
	SET NOCOUNT ON;
	DECLARE @POID INT;
	INSERT INTO [Merch].[PurchasOrder] (Suppint,VendorCode,classgroupAllocID,Season,[quarter],CreateDate)
	VALUES (@Suppint,@VendorCode,@classgroupAllocID,@Season,@quarter,GETDATE());
	Select @POID = SCOPE_IDENTITY();
	
	INSERT INTO [Merch].[purchasOrder2](POID,[Month],DateAllocated,StyleCreated,EDIT,Category,CreatDate) VALUES (@POID,@Month,@DateAllocated,@StyleCreated,@EDIT,@Category);

Open in new window


My vb code to take my web page objects into my sql server is the following.
        Dim strConnString As String = ConfigurationManager.ConnectionStrings("MerchData").ConnectionString
        Dim con As New SqlConnection(strConnString)
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "[Merch].[MyStoredProcedure]"
        cmd.Parameters.Add("@Suppint", SqlDbType.VarChar).Value = ddlSupplier.Text.Trim()
        cmd.Parameters.Add("@VendorCode", SqlDbType.VarChar).Value = tbsuppliercode.Text.Trim()
 

Open in new window

0
I have a the following dir structure

..\area\year\month\PDFFILE

not all areas have the same years inside
not all years have the same months (some months have no data so no month dir is created for those)
if there is a month directory it means it contains a pdf inside it


sample dir:

ford\2018
ford\2019\Jan\chart.pdf
ford\2019\Feb\chart.pdf
chevy\2017
chevy\2018
chevy\2019
chevy\2019\Jan\chart.pdf
toyota\
.
.
I need a script batch,vb or powershell or python whatever
that will help me create the following HTML TABLE


                   2019
     ford   chevy   toyota
Jan   x       x
Feb   x
Mar

The X should be an html link to the PDF, but I can do this with search / replace for the X so the main objective is to generate the table code.

I cannot change the directory structure
If you have a solution using csv file with excel and pivot tables it is also acceptable (so i can then use some text manipulating functions to get my desired html)

I have tried with some dir to html utils but they are very
limited and I end up with many tables that then I have to manually stitch together

Please Help
1

VB Script

37K

Solutions

20K

Contributors

VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.