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,

Is there a way to run an AutoHotkey (AHK) script directly from Notepad++?

I recently began editing my AutoHotkey scripts in Notepad++ rather than in Notepad. Now I'm wondering if, after making changes to a file, I can run it directly from Notepad++.

With regular Notepad, you must first save the edited file then go to Explorer (or wherever you have a shortcut) and run the file from there. It would save several keystrokes if the file could be run directly from Notepad++.

I do see a "Run" menu but after clicking, a box comes up asking you to enter the file you'd like to run. It would be quicker of course if there's a way to simply run the code in the currently active tab.

Thanks
0
Trying to restart a service via a .bat script BUT I need it to run as a certain user.  I tried the following but can't get it to work

sc config \\123.123.123.1 /USER:LOCALSERVER\!localaccount P@Ssword
sc stop SerViCeName && 
sc start SerViCeName
0
The code is stuck on     Range("K:K").Value = Range("K:K").Value
If the calculation is turned to automatic, it runs quickly.
But if calculation is on auto, it sits for hours.

Can anyone help?
Sub Count_Dim()

Application.ScreenUpdating = False
Sheets("Change box size").Activate
    Dim LastRow As LongPtr
    With ActiveSheet
        LastRow = .Cells(.Rows.Count, "J").End(xlUp).Row
    End With

With Range("K2")
.Formula = "=COUNTIFS(G:G,G2,B:B,B2)"
.AutoFill Destination:=Range(.Offset(0, -1), .Offset(0, -1).End(xlDown)).Offset(0, 1)
End With

    Range("K:K").Value = Range("K:K").Value
    
Range("K1") = "# Package Dimension"
Application.ScreenUpdating = True

Open in new window

0
I'm migrating users from Exchange 2010 to Exchange 2013 and Office 365.
I'm looking for a way to automate sending an email to each user in a batch of users after they are migrated.
To tell if they are migrated:  the attribute "msExchRecipientTypeDetails" = 1 if a user is NOT migrated.  
If the user is migrated, it reads a long number.

Looking for a script that would read from a file for the user/s to check this attribute - and if anything other than a "1" value - send an email to that user/s.

Any help to get me started would be appreciated.
0
Hi Experts,

We have a constant problem trying to restore NTUSER.DAT and corrupt profiles, whilst we are troubleshooting the root cause, id like a script that automates the restoration of NTuser.dat from a snapshot a few days earlier. I'm trying to make this as user friendly as possible automating many of the tasks, so it would be handy to just enter a username, and from there find where the users profile is located automatically and then restore the file.

I have no idea where to begin, or whether power-shell is the best way to script this, I'm sure someone has dealt with a similar task before?
0
I had this question after viewing Creating An Intelligent Dropdown.

Hi Experts.

So I finally was able to decipher the solution provided in the above mentioned post, and I think we're going to need to dig a little further.

Basically, the solution modified the XLSM to include some very cool formulas on the 2nd tab which determined who all was on the Home Team. The VBA code then referred to this data to determine whether or not to include it in the dropdown.

I will need to do this without formulas, and without adding new data to the spreadsheet. I would think we could use VBA to loop through [Roster] and add anyone with a Home Team of "9" (value stored in $W$5) to the Dropdown's list of values.

I'm also not able to add any additional controls for selecting Team Numbers due to "real estate" issues and also because I only really care about the Home Team. I'm almost imagining an If/Then/Else statement that adds Home Team players to Dropdown1 and everyone else to Dropdown2. So for now, we'll just go with that.

As always, I greatly appreciate your helpfulness and patience!

Tony G.
Example-1.xlsm
0
I had this question after viewing Dropdown menu selection to change criteria on autofilter.

Hey Guys.
This is my first post, so please be patient as I try to provide the necessary info for us to get through to the "finish line".

O.K. So I've created an XLSM which has on one sheet a Roster of Player Numbers, Names, Team Numbers, and Names. I've assigned the name "Rosters" to this range.

On another sheet, I've created some cells to store various data, in particular the Home Team Captain's Player Number. This is the Key for finding the home team's number and name.

On a third sheet, I've got an ActiveX ComboBox called cbPlay1, and another called cbPlay2. I want cbPlay1 to represent the Home Team, and only show players who are on the Home Team when the dropdown is clicked. On the opposite side of the coin, cbPlay2 should show all players who are NOT on the Home Team.

Please let me know what additional data you need to help me figure out how to code this in VBA.

Thanks!
0
I have an order form that is populated from a database. When I submit, I read the number of lines from the form and then want to read the form data into code rather than showing on screen (response.write) so I can iterate through the code to build an email form with the order. I have a working model with a set number of fields where I have written umpteen lines in manually. The issue is that if an additional product is added by another admin, that order line won't appear in the results, as it has not been pre-coded in.

This is what I want to write in:
ProduktName<1>=Request.Form("ProduktName<1>")
Quantity<1>=request.form("Quantity<1>")
IF Quantity<1> <> "0" THEN
Produkt<1>Weight=request.form("Produkt<1>Weight")
ELSE
Quantity<1> = ""
END IF

** Items above shown as <1> are incremented based on total output lines in the order form 

Open in new window


I then need to pull the responses in for the eMail (CDO) in a formatted table:
HTML = HTML & "<tr><td>&ProduktName<1>&</td><td><b>"&Quantity<1>&" "&Produkt<1>Weight&"</b></td></tr>"

Open in new window


Any help would be very much appreciated.
0
Hi there.

I have a question that I heard should be possible, and I would like to do the same.
I have a MySQL database on my webhotel, and I would like to make some Excel spreadsheets that pulls data from the MySQL database, and the spreadsheet must be stored on the webserver. A user should then be able to click to open the spreadsheet and show graphics etc. based on "fresh" data from the MySQL database.
Any solutions? :-)

Best regards

Ulrich
0
Created a task to run a powershell script automatically. When i run the task the powershell runs, but it gets stuck at the prompt to hit R for Run once S for Suspend or ? Help.

How do I get the script to answer the prompt automatically with R each time?

Example of my script:  -file C:\Netwrix_Auditor_Add-on_for_RADIUS_Server\Netwrix_Auditor_Add-on_for_RADIUS_Server.ps1 -Radiushost 192.1.1.4
0
how can i put the code to clear the filter in same workbooks all worksheets??
If ActiveSheet.FilterMode Then
                   ActiveSheet.ShowAllData
                End If

Open in new window


its works for the active sheet only but not for all
0
Experts,

I have seen a lot of scripts, but can't seem to find one that will cover my needs. I need a script that will sync/ mirror two folders. The parameters of the script need to have the following:

1. Sync the newer file
2. Ignore if the file exists
3. Include Subfolders/ files
4. Network restart-able

Location 1:  C:\%username%\Documents
Location 2: \\server\users\%username%\Documents
0
What is the difference between

<%@LANGUAGE="VBScript" CODEPAGE="1252"%>

Open in new window


AND

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

Open in new window


And how would a page would be affected if I changed 1252 to 65001 ?
0
HI Experts

Hope you can help

I have the following code in a sheet called FinesMAIN that is linked to a button and creates a simple report with a calculation in the footer.

Public Sub SetFooter()
 Dim ws As Worksheet
 Dim subTotal As Long
 Application.ScreenUpdating = False
 For Each ws In Worksheets
 ws.Select
 With ActiveSheet
   subTotal = Evaluate("=SUBTOTAL(9,G2:G39)")
 .PageSetup.RightFooter = "Total Invoiced: £" & subTotal
 End With
 subTotal = 0
 Next
 End Sub

I have added some other sheets to create numerous statistics however when I try to run  the report, it selects other sheets in the workbook and convolutes the results.

How can I set it to just take the information from the FinesMAIN sheet and not affect any others? The code is currently under the worksheet itself as an object, not a module.

Any help would be greatly appreciated

J
0
Hello experts,

I have the following csv file attached.

I am looking for a vbscript function in order to cover the following requirement:

-Generate x files with the following name strPrefix and datestamp based on a flag related of the number of lines strIntLines those variables and constants should be defined in the script.

Supposed I have a csv file as attached with 50 lines (header not included)
And I report the following
strPrefix=Report
strIntLines=10

-5 files should be generated and each of them should take into account the first 10 lines and the second file the next 10 lines and so one with the following name
Report_20170214_163501.csv, Report_20170214_163503... and so one
-Header should be always be generated in the first line of each file.
-Files should be also be generated in a datestamp folder.
-If the number of lines reported in the csv file is not multiplied by the strIntLines flag this one should be generate a last file with the remaining lines
Example
strIntLines=12 for the same file composed by 50 lines.
The procedure should generate 4 files with 12 lines and the last file with 2 lines in order to cover the various lines in the master file.


Please find bellow the excellent template used from the other the other questions:

' ==============================================================================
' C O N S T A N T S   &   V A R I A B L E S
' 

Open in new window

0
Good Afternoon.

our IT team has changed the Office programs from 32bit of Excel to 64bit, now our finance department has a lot of files with macros in them, like around 598 of those files have codes that use the window API by using the Declare statement.
i would need to convert a bunch of 32bit API calls in these files to 64bit compliant calls while preserving 32bit compatibility as well.

i created the attached template. where i can put the directory, then file names and then two box for searching code and replacing it with code.

so, ideally , the code to loop through all files in the referred directory and its subfolders and if the files listed in Column C found then initiate search on those files by finding the codes listed in column D and replace them with code in column E.

i search the whole day and i could not find anything or any help on google or in any other forum, which brings me here to EE VBA gurus and i am hoping someone would be able to help me here.

thank you in advance.
2017-02-14-12_49_34-template.xlsb---.pngtemplate.xlsb
0
I have a script question.  Here's the error message more and more users are getting.  Not everyone is getting this error, but more and more are receiving it. All clients are windows 7 or windows 10.
I have included my script below.   Can anyone tell me if I have a problem with my script?  It's strange that the script works for the majority of users, but has started to fail for some.

logon script error

'Clean Login Script
Option Explicit

'variable declared
Dim WSHNetwork, WSHShell, bReturnCode, objFileSystem, strArgs, x, y, DesktopPath, StartMenuPath
Dim Department, OfficeFilesDrive, MyShortcut, strDept, WshSysEnv, strOS, UserName, oExec

'creating objects
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set WSHNetwork = Wscript.CreateObject("WScript.Network")
Set WSHShell = Wscript.CreateObject("WScript.Shell")
Set strArgs = Wscript.Arguments

OfficeFilesDrive = "s:\"

If strArgs.Count = 0 Then 'Error Checking for variable from Batch to VBSCRIPT
    MsgBox "An error occured because no variable was passed to the vbscript. Please call Eric at ext. 7236", vbCritical, "Amazing Facts Logon Script Error"
    Wscript.Quit
Else
strDept = strArgs(0)
End If

'grabbing info from system
'DesktopPath = WSHShell.SpecialFolders("Desktop")
'StartMenuPath = WSHShell.SpecialFolders("StartMenu")


'_______________________My Subs for everyone_________________________________________

'Pause script until User is logged in
UserName = ""
On…
0
I had this question after viewing Export folder and file structure to Excel.

I came across this solution while looking for a solution to, well this basic requirement. While the solution posted here would fit my need perfectly, I'm looking to add the the file extension, size and if possible the path for any of the files that are returned. The path would be useful since I've noticed some of the outputs from the vba become a little hard to read depending on the depth. The other two attributes would be helpful in finding duplicates of files.

I've explored the add-in that was mentioned in the linked post above, and the dates are lovely and all, but really the last modified is the only one that would be useful. The others don't necessarily help me all of that much, but that could just be me. Also, I really need the extension, not the long type name.

I've tried using some of the DOS commands, and even the PS scripts, but the outputs would take too long to format given the number of systems that I was hoping to use this on.

My attempts to modify the VBA provided in this solution haven't proved particularly successful since I'm both still learning VBA and some of the other examples that pull that value in use a different method of returning the results. (I'm still learning VBA, so that probably has something to do with it).

The goals I'm trying to accomplish with all of this:
  • Establish the directory structure of a folder or drive
0
I have a large .xml file that has base64 code in it.  I am not a programmer but I have a little bit of VBScript knowledge.  I am trying to figure out how to parse out the base64 code and convert it into a text document.  There is about 12,000 lines in the document.  Here is an example of what I have:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Dates>
  <Date DateId="162" Type="Text" Value="2016-11-15">
    <Revisions>
      <Revision Value="0">
        <Account Application="Info">
          <Pages PageCount="3">
            <Page>
              <PageNumber>1</PageNumber>
              <Content Encoding="Base64">DQogDQogDQo.....</Content>
               </Page>
                <Page>
                     <PageNumber>2</PageNumber>

Any help would be appreciated.

Thanks,

Jeremy
0
Hi

I am looking for script to run against few servers that will provide inventory (content) and size  of the recycle bin.
The second part of the script should empty out\clean  recycle bins  

Please assist, M
0
I have a vbscript that runs fine when I manual run the script but when scheduling a task, it doesn't run properly.  The script will provide a message box to the user on the PC when the criteria is met.   I've read multiple threads on here that you can't run interactive commands in Windows task scheduler but you can use the AT command to schedule an interactive task.   I need my task to run every 10 minutes on the PC.  When searching the AT command functions, I don't see an option to specify the 10 minute runs.

I appreciate the help.
0
Hello experts,

I have use the following script which allows me to backup (copy files and folders from and transfer them to a datestamp folder)
reported at: https://www.experts-exchange.com/questions/28936561/VB-Script-copy-backup-files-and-folders-v2.html

The script works properly when I report just one folder in the arrfolders. However when I report two folders, the second folder is not properly transferred in the datestamp folder I don't know if the byVal delcaration should be performed for the variables


' File I/O constants
Const ForAppending = 8

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

' Define folders and files to work with
strScriptDir = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
strLogFile = strScriptDir & "\log-copy.txt"
strStamp = TimeStamp(Now)
arrFolders = Array("C:\Folder1,C:\Folder2")
strFromFolder = ""
strToFolder = strScriptDir
blnFolders = True
arrSkipFolders = Array("Backups-Files")

' Open log file for appending
Set objLog = objFSO.OpenTextFile(strLogFile, ForAppending, True)

' Loop through all folders, backup files
For Each strFolder in arrFolders
   BackupFilesFolders strFolder, blnFolders
Next

' Wrap up
objLog.Close

Wscript.Echo Now & " :" & vbCrLf & "Program has completed all the actions successfully"


' Process folder
Sub BackupFilesFolders(strPath, blnFolders)

   ' If the input folder does not exist then skip this folder
   strFromPath = strPath & "\" & strFromFolder
 

Open in new window

0
i have to take the screenshot of command prompt . i have code for this. but it only takes the screenshot of desktop.please help me.
Set oWordBasic = CreateObject("Word.Basic")
      oWordBasic.SendKeys "{prtsc}"
          oWordBasic.AppClose "Microsoft Word"
          Set oWordBasic = Nothing
          WScript.Sleep 2000
        set WshShell = CreateObject("WScript.Shell")
      WshShell.Run "mspaint"
          WScript.Sleep 2000
      set WshShell = CreateObject("WScript.Shell")
      WshShell.Run "C:\Windows\System32\cmd.exe"
      WScript.Sleep 2000
      WshShell.SendKeys "ping 192.168.168.168"
      WScript.Sleep 2000
      WshShell.SendKeys "{ENTER}"
      WScript.Sleep 2000
          set shl=createobject("shell.application")
      shl.MinimizeAll  
          WScript.Sleep 2000
          shl.UndoMinimizeAll
          Set shl=Nothing
          WScript.Sleep 2000
          WshShell.AppActivate "untitled - Paint"
          WScript.Sleep 1000
          WshShell.SendKeys "^v"
          WScript.Sleep 500
          WshShell.SendKeys "^s"
          WScript.Sleep 500
          WshShell.SendKeys "F:\User_Data\skaur\Desktop\" & "screenshot" & ".png"
          WScript.Sleep 500
          WshShell.SendKeys "{ENTER}"
          WScript.Sleep 500
          WshShell.SendKeys "%{F4}"
          Set WshShell=Nothing
0
I found this script on Technet, I can get the log function to report correctly,  When I change the flag to 1 and run it, it does nothing - no account move or log information.  I'm running as admin.

'=========================================================================== 
' Checks all accounts to determine what needs to be disabled. 
' If LastLogonTimeStamp is Null and object is older than specified date, it is disabled and moved. 
' If account has been used, but not within duration specified, it is disabled and moved. 
' If account is already disabled it is left where it is. 
' Created 23/7/09 by Grant Brunton 
'=========================================================================== 
 
'=========================================================================== 
' BEGIN USER VARIABLES 
'=========================================================================== 
 
' Flag to enable the disabling and moving of unused accounts 
' 1 - Will Disable and move accounts 
' 0 - Will create ouput log only 
bDisable=1 
 
' Number of days before an account is deemed inactive 
' Accounts that haven't been logged in for this amount of days are selected 
iLogonDays=60 
 
' LDAP Location of OUs to search for accounts 
' LDAP location format eg: "OU=Users,OU=Test" 
strSearchOU="OU=Users,OU=Live" 
 
' Search depth to find users 
' Use "OneLevel" for the specified OU only or "Subtree" to search all child OUs as well. 
strSearchDepth="OneLevel" 
 
' Location of new OU to move 

Open in new window

0
Copy the value of Cell C5 into sheet2 Cell B5 if A5 to A23 on sheet 1 = (MCL). If cell C5 is empty (or 'No') do nothing. Is this possible?
I have added the work book so you can see what i am trying to do.
Thank you.
Days.xlsx
Days.xlsx
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.