Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x

VB Script

36K

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,

Please I need a script "vbscript" to export the following attribute from two "OU" in active directory,
After to run the script we obtein a output file .csv (encode in UTF-8 )

I want to display in the output file the following fields:
"Account","Disabled","First Name","Last Name","Mail"

*Disable = True or False
"""ou=Accounts,ou=Sales,ou=USA,dc=Dom,dc=local"",""DC1Serv.dom.local"""
"""ou=Accounts,ou=Marketing,ou=USA,dc=Dom,dc=local"",""DC1Serv.dom.local"""

Best regards,
0
[Webinar On Demand] Database Backup and Recovery
LVL 11
[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Hi,

Please I need a script (vbscript or Powershell)  to export the following attribute from two "OU" in active directory,
After to run the script we obtein a output file .csv (encode in UTF-8 )

I want to display in the output file the following fields:
"Account","Disabled","First Name","Last Name","Mail"

*Disable = True or False
"""ou=Accounts,ou=Sales,ou=USA,dc=Dom,dc=local"",""DC1Serv.dom.local"""
"""ou=Accounts,ou=Marketing,ou=USA,dc=Dom,dc=local"",""DC1Serv.dom.local"""

Best regards,
0
Is there a script out there (.bat or .vbs ) that verify the Meltdn/Spectr  patches are successfully applied (including that registry key is added) & the health of Windows after patching?   I don't want Powershell script.
0
VBScript macros based approach has been discussed previously. It worked perfectly fine by changing one line to work with .docx (office365).
I need help to run the VBScript from command line on windows machine. cscript of wscript are throwing error for declaration for FileSystemObject, String, Revision...

Please share steps to rewrite or adapt the previous solution to be able to run from command line on windows machine.
0
I'm using the createobject("vbscript.regexp") object in a VBA environment.  I'm getting an extra, unexpected, match that I'd like to eliminate or understand.

pattern: (.*?)($|(?:&#\d+;))
string: Now 15 & $42.0 the time;  for all good# "men" -2 pet the dog cat horse 1,234.56

I'm getting the expected matches (submatch tuples):
("Now 15 & $42.0 the time;  for all good# ", """)
("men", """)
(" -2 pet the dog cat horse 1,234.56", "")

as well as this unexpected match:
("", "")

Why is this happening and is there a better pattern that will eliminate this extra match?
0
Dear Experts,
Good day,

I am working on Reservation system, where i wrote a code if that record date gets equal to current date ... then
Just insert the same record one more time in DB, code is written below but i have a general question ....

It works fine if i stay on that page, but what if the page is not open and i would like to generate that event behind the scene.
I hope you got my idea ....
I do not want to be on the page to let that event trigger, i just want when some particular time which i will mention if arrives record inserted int DB.

I am using Asp.net VB and MS ACCESS as DB. PLS HELP

      If Convert.ToDateTime(mytxtboxdepart.Text) > Convert.ToDateTime(mytxtarrivon.Text) And mynightrun = Now.ToLocalTime.ToLongTimeString Then
                    'MsgBox(txtBoxTimer.Text & " = " & Now.ToLocalTime.ToLongTimeString)

                    Me.myAccessConnection.ConnectionString = Me.connStr
                    Me.myAccessConnection.Open()
                    command.CommandText = "insert into ReservationTb([confirmid],[Gname],[ArrivalOn],[Departure],[Nights])values (confirmid,Gname,ArrivalOn,Departure,Nights)"
 end if
0
Screenshot: https://www.screencast.com/t/andGYDsex  notice one table is less wide than the other

The following code removes an unwanted column

                              for each trw in tbl.rows
                                    if trw.cells.count > 6 then
                                          trw.cells(7).Delete
                                                
                                          
                                    end if
                                    
                              next


The result is randomly reducing some of the tables widths while not reducing the widths of others.
How can I make this consistent?
0
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim cell As TableCell = e.Row.Cells(4)
            Dim cell2 As TableCell = e.Row.Cells(6)
            Dim mytxtboxdepart As TextBox = e.Row.FindControl("txtBoxDeparture")
            Dim mytxtboxstays As TextBox = e.Row.FindControl("txtBoxStays")
            Dim mytxtboxcriteria As TextBox = e.Row.FindControl("txtBoxCriteria")

            Dim provider As String
            Dim connString As String
            Dim myconnection As OleDbConnection = New OleDbConnection
            provider = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("~/App_Data/myDB.mdb")
            connString = provider
            myconnection.ConnectionString = connString

            If Convert.ToDateTime(mytxtboxdepart.Text) < Convert.ToDateTime(mytxtboxstays.Text) Then
                myconnection.Open()
                Response.Write(Convert.ToDateTime(mytxtboxdepart.Text))
                cell2.BackColor = Color.Red
                Dim str As String
                str = "DELETE * FROM ReservationTb WHERE Criteria" = "5"
            End If
            command.Connection = myAccessConnection
            command.ExecuteNonQuery()
            myAccessConnection.Close()
        End If
    End Sub

But i am getting the error ...
0
Dear Experts,
I hope i will get the answers of my question by today ..
I am working on Hospitality Management Software, of which 70% is done only Billing Section's few part left .. and thats where i am stuck. I am using Asp.net VB & MS Access as back-end.
My Requirement i would like to take a value when a NEW RESERVATION will be made "Arrival on" to "Departure"
Right now i just can save 2 values which is Arrival date & Departure date in database but i want something like this as below ...
so what i need i am giving you idea in DB actually how it goes ....

id    confirmid   name     arrivalon     departure         currentdate
1      1111           ABC       01/3/2018   01/05/2018       01/3/2018
2      1111           ABC       01/3/2018   01/05/2018       01/4/2018
3     1111           ABC       01/3/2018   01/05/2018       01/5/2018   ------> if this equals departure date ABC  CHECK OUT
4      2222           XYZ        01/3/2018   01/04/2018       01/3/2018
5      2222           XYZ        01/3/2018   01/04/2018       01/4/2018    ------> if this equals departure date XYZ CHECK OUT

so my problem is i just can save arrival on & departure first row which is id 1, the remaining id 2 & & 3 how can i save,
Similarly id 4 is saved when i make a new reservation the id 5 how can i save.

PLS HELP ... I NEED MY PROJECT TO FINISH IT BY A NEXT WEEK, THANKS IN ADVANCE
0
I have written a VBA function in MS Outlook that takes about 30 seconds to run. It needs to open and read data in a spreadsheet as well as loop through emails. I need the application to run every 30 minutes or so to see if there have been any new emails arrive or any updates to the spreadsheet. The trouble is that if I am using MS Outlook at the time it will interrupt and make me wait so I was wondering if there is a way to run it without interfering.

I was thinking that perhaps it may be possible to create an instance of Outlook and Excel using VB Script or perhaps running it from another MS product that I don't use very often like Publisher or Powerpoint, or perhaps I should create a virtual machine and leave an instance of Publisher running on it (though that will likely be very resource hungry). I don't think this is a new problem so I am hoping someone has a relatively straightforward suggestion.
0
[Webinar] Database Backup and Recovery
LVL 11
[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

I just started using VBA and need some guidance.
Aim: Highlight cells upon this 4 conditions. All conditions have to be applied

1.Same Date
2.Same Name
3.Diff Address
4.Overlapping timing
    example:
   data 1> start time: 09:00 end time: 09:35
   data 2> start time: 09:20 end time: 10:00
   When the start time of the second data overlaps with the end time of the first data, it should be highlighted

Sample data:

sample data
Sample Output:

Sample output
What I have done:

Sub DupEntry()
Dim cel As Variant
Dim rng As Range
Dim clr As Long
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set rng = Range("A1:A" & Range("A1048576").End(xlUp).Row)
rng.Interior.ColorIndex = xlNone
clr = 3
For Each cel In rng
If Application.WorksheetFunction.CountIf(rng, cel) > 1 Then
If WorksheetFunction.CountIf(Range("A1:A" & cel.Row), cel) = 1 Then
cel.Interior.ColorIndex = clr
clr = clr + 1
Else
cel.Interior.ColorIndex = rng.Cells(WorksheetFunction.Match(cel.Value, rng, False), 1).Interior.ColorIndex
End If
End If
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
excel vba excel-vba

Open in new window


It only highlights the duplicate in the first column

Any help would be appreciated. Thank you!
0
hello experts ,
im trying to export a key froma pre defined varibale , but it cannot read its content . please help below is a sample script .

Option Explicit
dim user , objshell
user= "HKEY_USER"
Set objShell = CreateObject("WScript.Shell")
objshell.run reg export (" & user" c:\temp\test.reg)
0
i want to collect all info like logon activity, computer name, serial number and model from users in active directory and save it to mysql from group policy object did i create. is that any vbscript to collect info from users to mysql without installing mysql connector? sorry for my english.
0
im looking for a script to export last logged in user registry ( HKCU ) and run it as a shutdown script .
if i dont run it as last logged in user , it will run as System ... any idea?  
Thank you ,
0
Greetings:

Using a Try ... Catch statement in VB.NET attempting a SQL insert I receive an HResult code of 0x80131904 (decimal -2146232060). I understand attempting to insert a row where the key value already exists on the database is a violation. What I'm looking for is a definitive way to determine the error verbiage of "Cannot insert duplicate key in object ..." can always be detected by the HResult code of 0x80131904, and, a HResult code of 0x80131904 always means "Cannot insert duplicate key in object ...".

Do I need to interrogate additional structures to determine the specific error verbiage of "Cannot insert duplicate key in object ..."?

My thinking here is the verbiage of "Cannot insert duplicate key in object ..." may change, however, the HResult code (and any other structures I may need to interrogate) will not change.

Any assistance you all might provide would certainly help me.

Much thanks,
David Bach
0
I have a simple VB datagridview form that is used to update a table in my MSSQL DB.
Form looks like this:
2017-12-22_10-12-42.png
I need to run the query and get sum total of all the values.
Here is my TableAdapter  query.
 Private Sub SearchBTN_Click(sender As Object, e As EventArgs) Handles SearchBTN.Click
        Me.CV_Allocation_TblTableAdapter.FillMatterID(CVDataSet.CV_Allocation_Tbl, Nothing)
        StatusLabel1.Text = "Ready"
        Try

            If CheckBox1.Checked = False Then
                Me.CV_Allocation_TblTableAdapter.FillMatterID(CVDataSet.CV_Allocation_Tbl, TextBox1.Text)
            Else
                Me.CV_Allocation_TblTableAdapter.FillExactMatterid(CVDataSet.CV_Allocation_Tbl, TextBox1.Text)
                MsgBox(Me.DataTable1TableAdapter.FillSUM(CVDataSet.DataTable1, TextBox1.Text))
            End If
        Catch ex As Exception

        End Try

Open in new window


 2017-12-22_10-20-45.png
SELECT        SUM([Partner Origination] + [Responsible Partner] + [Case Manager]) AS Total
FROM            cv_allocation_tbl
WHERE        (MatterID = @matterid)
GROUP BY MatterID

Open in new window


When I run my form I get a value of 1 for Msgbox when I expect 100.

2017-12-22_10-24-30.png
0
My default browser is launched when a batch calls this VB Script and refreshes as the application does not open instantly and needs refresh. But it is refreshing all the tabs. I want the particular tab to get refreshed with this particular URL and once the application is  open the refresh operation should stop. can it be done within this VB script.

My code:  

Option Explicit
      
      Dim myowmObj
      Dim ObservedPort
      Dim Counter
 
    Set myowmObj=WScript.CreateObject("WScript.Shell")
    ObservedPort = WScript.Arguments(0)
    myowmObj.Run "http://localhost:"&port&"/HatsDemo"
      'Wait for 3 seconds
      Wscript.Sleep 3000
     
      Counter = 20
      Do While Counter > 0
            Counter = Counter - 1
           
            'Send the F5 key for a refresh
            myowmObj.SendKeys "{F5}"
            'Wait for 2 seconds
            Wscript.Sleep 2000
      Loop
0
I would like to calculate % change from last year in column I and need some help with the formula.

Here is my excel table

Excel.JPG
Here is my formula that i have in cell I6.
=(D6-H6)/D6

How can i make it that if cell D6 is blank then the default value in Column I cell I6 is 100%

All cell format types are set to "Accounting"
0
Dear Experts:

I got hundreds of file names where I should eleminate any consecutive use of the underscore character, ...

i.e. multiple consecutive occurrences of the underscore character should be replaced by just one underscore character, such as


Before                                                                             After
MyProduct__134_final____file.xls                                  MyProduct_134_final_file.xls
My_Products__4_finalfile_file__latest.xls                    My_Products_4_finalfile_file_latest.xls  
etc.

Can this be done using a formula or do I need a VBA solution.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
0
Free Tool: ZipGrep
LVL 11
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Greeting Experts,

I need help creating PowerShell script to read the name multiple files (over 2,000 files names) in a file directory and then import that information into a ".csv" document. Can somebody help me with this task...
0
I have a text file like :

1,Jane Doe,JKSMFFK332S,JJK332S,OptiPlex 960,2017-12-18 11:02:01
2,Jane Doe,JIBRAIL,4WK332S,OptiPlex 960,2017-12-18 11:04:34
3,Jonathan Davis,JKSGYYO332S,YYO332S,OptiPlex 960,2017-12-18 11:30:25
4,Jane Doe,MIKAIL,GGF332S,OptiPlex 960,2017-12-18 11:56:02

How do i find keyword "Jane Doe,JIBRAIL" and replace the time stamp (2017-12-18 11:04:34) to current time stamp
0
Set wshShell =wscript.CreateObject("WScript.Shell")
do
wscript.sleep 3000
wshshell.sendkeys "{/}"
wshshell.sendkeys "{s}"
wshshell.sendkeys "{e}"
wshshell.sendkeys "{n}"
wshshell.sendkeys "{d}"
wshshell.sendkeys "{ }"
wshshell.sendkeys "{t}"
wshshell.sendkeys "{r}"
wshshell.sendkeys "{a}"
wshshell.sendkeys "{d}"
wshshell.sendkeys "{!}"
wshshell.sendkeys "{e}"
wshshell.sendkeys "{s}"
wshshell.sendkeys "{ }"
wshshell.sendkeys "{i}"
wshshell.sendkeys "{m}"
wshshell.sendkeys "{a}"
wshshell.sendkeys "{f}"
wshshell.sendkeys "{k}"
loop

i want to press F5 to stop the loop and f4 to start it again?
0
So I feel this is a rather hard question but it might not be.
Here's the situation:  We have this huge database, thank to experts like you all, that does a ton of things for us.  And has made our job a million times better.  Once again thank you all or the great support, solutions and ideas.

So some managers have a requirement to fill out a rather lengthy form from time to time.  Not only is it lengthy but it takes quite some time to gather the information and then fill out the form.  But luckily, this great database has 90% of all the information they need for the form.

I know how to write the VB to export single fields into the word document.  What I envision is where the manager can bring up a list of employees in the database, check the ones they want on the form and then hit export and the form is filled in with those checked names.  Is this possible and if so how do I go about making it happen?

Thanks
John
0
Good day everybody,

Even though I've tried many different syntax, I don't get to work the following code:
I define Year and Year1 as variables, where year is 2017 and Year1 is 17
Year= ActiveSheet.Range("C3")
Year1=ActiveSheet.Range("C4")

Then, there's a part of the code where I need to use a SUMIFS to other workbook already open, the original formula is:
=SUMIFS('[Comisiones 2017.xlsm]Stats17'!$F$3:$F$10000,'[Comisiones 2017.xlsm]Stats17'!$E$3:$E$10000,C2,'[Comisiones 2017.xlsm]Stats17'!$B$3:$B$10000,G2)

So, the only thing I want to do is that "2017" and "17" can be defined into the formula with both variables, since the names of the files and sheets will be changing depending on the current year.

I had this problem before and I solved it by inserting, litterally something like: "SUMIFS('[Comisiones "&Sheets("MXN").Range("C3")&"..." as if it took the variable directly from the workbook, however, this solution only works for me when the formula and the referenced cell are on the same workbook, and now, the reference workbook is different from the workbook I want to set the formula in.

Thank you in advance for any help you can provide to me,

Best Regards
0
Hi All,

I am trying to run a script which has popups kind of telling the user that the script is still active. The issue that I am running into is that the popups are minimized. Is there a way to have it open on the main screen?
Here is the code.

Const TIMEOUT = 6
Set ObjShell = WScript.CreateObject ("WScript.Shell")
ObjShell.Popup ' This is a Test", TIMEOUT
0

VB Script

36K

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.