vbscript,wildcard,unzip , Unzip files that begin with a particular string

Unzip files that begin with a particular string


Tag: vbscript,wildcard,unzip

This is my second attempt at cracking this problem I am facing.

In a nutshell I get some files sent to me on a weekly basis which begin with the same 11 characters and anything after that can differ from week to week.

I have some basic code that unzips the files when an exact filename is found, but I'm hoping to move away from that by having a procedure which uses wildcards. So anything that is a zip file and anything that begins with those 11 chars.

I have gotten this far, but seem to have hit a wall with a name space error, can somebody please help me out where I'm going wrong?

Set fso = CreateObject("Scripting.FileSystemObject")

ExtractTo="C:\Users\W1 Process\_ThisWeek\"

For Each f In fso.GetFolder("C:\Users\W1 Process\_ThisWeek\").Files
  If LCase(fso.GetExtensionName(f)) = "zip" And Left(f.Name, 11) = "Home Weekly" Then
    set objShell = CreateObject("Shell.Application")

    set FilesInZip=objShell.NameSpace(ZipFile).items

    Set fso = Nothing
    Set objShell = Nothing
  End If


You could use a regular expression for matching variable file names:

Set re = New RegExp
re.Pattern = "^home weekly.*\.zip$"

Set fso = CreateObject("Scripting.FileSystemObject")
Set app = CreateObject("Shell.Application")

ExtractTo = "C:\Users\W1 Process\_ThisWeek"

For Each f In fso.GetFolder("C:\Users\W1 Process\_ThisWeek").Files
  If re.Test(f.Name) Then
    Set FilesInZip = app.NameSpace(f.Path).Items
  End If


VBScript Redirect to Network Folder

I have taken over a web page recently I have some programming knowledge and can usually muddle my way through things but I cant seem to get it today. There is a snippet of code on the website that opens a folder on a network drive when a user opens...

Excel Advanced Filter not working with Wildcard (* asterisk) using regular numbers and hyphenated number system

I have set up an advanced filter in Excel. I can not get the advanced filter to produce any output when using wildcard asterisks (*), using a source list that contains numbers and hyphenated numbers, OR alternatively when using a separate list which is producing a number from a formula....

VBScript Regular Expression Insert Line

I try to insert a line between 2 specific lines in a files with VBScript : # Ligne 1 # Ligne 2 => # Ligne 1 # Ligne 1 bis # Ligne 2 My script code is : Dim regEx Set regEx = New RegExp regEx.Pattern = "# Ligne 1\r\n#...

FormatCurrency giving different results on different pages in different browsers?

Given the following VBscript code: FormatCurrency("123",2) written to an html page: <td><%= FormatCurrency("123",2) %></td> Both pages have the same charset "ISO-8859-1", and show the same behavior with charset "UTF-8". I am getting several results across browsers - IE10 and FireFox38 display the following: "Payment Page": £123.00 "Receipt Page": £123.00 while...

JAVA SQL assign all wildcards to null

I currently have an sql string returned with the string wildcards marking null values. I am trying to find a way to set all of these wildcard values to null. After looking around, I have found a preparedStatement.setNull() method however it takes an index and the indexes of the wildcards...

Classic ASP and JQuery reloads default.asp page on redirect

I have integrated an existing Classic ASP site with JQuery (they were using VBScript before). The previous version works fine but the script's needed to be updated so it will work on other browsers. But when I redirect the page with JQuery integrated, the system loads the default.asp file and...

VBS (MSGBOX)- How can I add multiple attribute numbers (such as 16)

I want to create a VBS script that has a message box with multiple numerical attributes, for example having a message box with the 16 icon as well as the 2 value (Abort,Retry,Ignore) In other words, I would want to combine the following two scripts into one. lol=msgbox("Body message",16,"Title") with...

Cast and Convert functions are not supported on converting the column to date time format (in vbscript - Excel adodb)

I have written a vbscript to connect the excel file (.xlsx) as a database using ADODB connection. I want to extract the records from excel file which has the values in 'StartDate' column greater than '15/05/2015', but on executing a adodb query an error is thrown as "Data type mismatch...

Can't read first row of CSV file

I can't figure out why my script is not reading and storing the first row of the CSV file. It is starting with the second row for some reason. I have the following code (reading from a 2 column CSV file): Set rs = CreateObject("ADOR.Recordset") 'this just gets the folder...

Script works on its own but not as a subroutine of a bigger program

I have written the following code, tested it, and it works. I then literally copied and pasted it into a larger program as a sub. I'm getting a Type mismatch on the Split Function now. I copied & pasted it out of the subroutine and into a new file and...

vbscript to run command

I'm trying to create a script that runs the command: RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255 Right now this errors out Dim objShell Set objShell = Wscript.CreateObject("WScript.Shell") sEXE = """C:\Windows\system32\RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255 """ with CreateObject("WScript.Shell") .Run sEXE & " " , 1, true end with Wscript.Quit Any suggestions? Could I make the script...

Get dates from AUT?

My Web-based application (like most) follows the browser locale to format dates. So if you configure British English as the preferred language in the browser, the app will display dates in "DD/MM/YYYY" format. Now QTP (ok, it´s VBScript that is the culprit) does not know about this. It strictly follows...

WshShell.SendKeys - SLASH not allowed?

Today I am having difficulties with this following code: x=msgbox("Your Text Here" ,0, "Your Title Here") UserName=inputbox("After this message, you have 5 seconds to switch to Minecraft. Please enter the username you wish to type the song to:") wscript.sleep 5000 WshShell.SendKeys "/msg" + UserName + "I know that we just...

Error code 0x8000500D when trying to access PasswordLastChanged

I'm writing a VBScript that will simply check each user in AD if their password has been changed within a given number of days. When I was trying to get it working for a single user, I came up with the following working code: Option Explicit Dim objUser, strLDAPConnection, intPwdExpLimit...

Microsoft VB Compilation Error

I am learner to vbscripting and as a beginner trying to execute the below code. But I keep getting the compilation error [Please see error message below]. I am not sure as I do not see any error in the code. Also, I made sure that I type in all...

remove button and use dropdown box in hta-vbscript

I am fairly new to hta & vbscript. I have a **hta** script downloaded from internet to delay reboot of computer. There are button for delay such as 30 min, 45 min, 60 min etc. I would like to use combobox(Dropdown box) instead of button. I also want my vbscript...

How to click a plain button on a webpage using VBScript?

I have a button on an website like this <button> Like </button> Does anyone know how to find and click this button using VBScript? Since he have no ID or other things I don't know how to find the button....

VBScript to detect Facebook IE window, press Like and close the window

I tryed to make a script to detect the IE window that is opened on Facebook and hit the Like button. Let's say I have 10 IE opened. Only one of them is on a page on Facebook. I want my script to detect that IE window, click this button:...

How can I get a one liner xcopy command to run in vbscript?

I have an xcopy that cannot run correctly in a .bat (batch) file because of some Norwegian characters. The line is: xcopy /I /V /H /R /C /Y /K /O /X "G:\P - cad_files\Drawings\163997 Ø1000XØ90 T7-8-9.PDF" "F:\CAD\P - cad_files\Drawings\163997 Ø1000XØ90 T7-8-9.PDF" If I run it from a batch file it...

How to detect after system boot if the service is running, if running then start my apps?

In VBScript is it possible to query a specific service name if it's started or running? if its running then execute finally my application. So here is how the flow i am trying to prepare: System is booted Windows 8.1 Startup script is executed (VBS) VBScript now wait and keep...

Publishing Excel as Webpage

I am trying to save excel as a webpage using VB Script. The problem I am facing is the sheet names in excel (E.g. Sheet1) also gets saved in webpage. I don't want the sheet name to be present in webpage. One solution that I found was that if the...

Wildcards in Standard ML

I just came across the following function in ML for the Working Programmer: fun null [] = true | null (_::_) = false 1) Can't both wildcards be empty lists? If not, how does ML prevent this? 2) Could the function be shortened to be: fun null [] = true...

Response.write in multiple place with same recordset

I have two divs <div class="selection mini"> <select name="selfromYear"> <option selected disabled>From</option> <option>1956</option> <option>1986</option> </select> </div> <div class="selection mini"> <select name="selToYear"> <option selected disabled>To</option> <option>1956</option> <option>1986</option> </select> </div> And I want to fill them with same fields <div class="selection mini"> <select...

Run VBScript from C# with hidden window and capture output

I am able to run VBScript from C# and capture standard output and error streams using this code: var process = new Process(); process.StartInfo.FileName = "cscript"; process.StartInfo.WorkingDirectory = @"C:\scripts\"; process.StartInfo.Arguments = "//B //Nologo vbscript.vbs"; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.StartInfo.UseShellExecute = false; process.Start(); ... This works fine but shows...

Operators suddenly not working

A week ago I wrote this script which starts up when you log in and then greets you according to the time of the day. This morning it suddenly suddenly said: "Invalid time" (it would do that if all other elseif options wouldn't match the time). This used to work...

Garbage char returned by Shell.StdOut.ReadAll

Here is my code Set objFSO = CreateObject("Scripting.FileSystemObject") a = "@echo off && " & _ "pushd ""\\xxxxx.local\cfs\Development\Docs\Baseline"" &&" & _ "cls &&" & _ "dir /b /a-d &&" & _ "popd" Set objShell = CreateObject("WScript.Shell").Exec("%comspec% /c " & a) execStdOut = objShell.StdOut.ReadAll() msgbox execStdOut Basically I am trying to...

Close Open Excel Instance

Could someone please let me know if the following simple VBScript is correct? It is supposed to close Excel after other processes have run (and left Excel open), but it doesn't work. Set MyApp = CreateObject("Excel.Application") MyApp.Quit ...

SCOM Monitor not reporting

I am running into a bit of an issue with SCOM. I have create the script below to monitor an application. It creates an entry in the Event log when the script runs and I have configured the alerts for a specific group in which the monitor is running on....

excel macro vba Filtering using wildcards

I need to filter in pivot. I need to deselect all items starting with "A." and "H." and keep everything else selected. the items ranges from: A.(3-13 characters) B.(3-13 characters) all the way to Z.(3-13 characters) the raw data also changes from 50-500 rows (I can have a data with...

VBS- Can I exit a VBS message box that repeats itself without going to the task manager or cmd?

I have a message box that repeats itself whenever you click ok- which is the only option, by the way. My code: 'Very Annoying script' Set objShell = CreateObject("Wscript.Shell") intMessage = Msgbox("Click ok to say yes",16, "Is this messagebox annoying?") If intMessage = vbOK Then RETRY Else Wscript.Quit End If...

How can I retrieve the LAN adapter MAC address?

I want to retrieve the MAC address from a Windows system, only for LAN Adapter. Can you suggest to me how I'd handle this in VBScript? I'm currently using this VBScript for getting the MAC address, but this is giving me results for all adapters, while I only want the...

Close an HTA when the user presses the 'Esc' key

I'm trying to capture key presses so that I can close my HTA when the user presses the Esc key. I have confirmed that the onKeyUp event works (I also capture the length of an input), and also that the example below is not working (by adding a MsgBox which...

same server, get url: vbscript msxml3.dll 80004005 unspecified error, or msxml6.dll error '80072ee6' System error: -2147012890

What's the correct way to get the output of an asp page located on the same server? <% GetUrl "/route/to/abc/123/" Function GetUrl(url) Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.3.0") objXMLHTTP.open "GET", URL, false objXMLHTTP.send() If objXMLHTTP.Status = 200 Then Response.Write objXMLHTTP.ResponseText End if Set objXMLHTTP = Nothing End Function %> results in this...

MySQL wildcard replace

Hi i need help with a MySQL query. Is it possible to do some wildcard replace for a string like the example below? String:                        example.com/folderone/some/path/to/file.pdf String:                        example.com/foldertwo/some/path/to/file.pdf Replace: newsite.com/some/path/to/file.pdf newsite.com/some/path/to/file.pdf newsite.com/some/path/to/file.pdf To remove the folder and change the domain but keep the path. In this case...

Unzip files that begin with a particular string

This is my second attempt at cracking this problem I am facing. In a nutshell I get some files sent to me on a weekly basis which begin with the same 11 characters and anything after that can differ from week to week. I have some basic code that unzips...

T SQL wildcard searching for a zip code

I've been messing around all day with some t-sql code for searching a zip code. I'm using a wild card to match the end of the string. However, it is not working. It only works when the whole string is entered correctly. Here is the code I have. IF (@MailFiveDigitZip...

How to delete chars in string by position only?

I need a regex search & replace pair that will delete 'n' characters from a string, starting at some definable location. For example, to delete 3 characters starting at position 5. In that case the string AAA. 01 Data From July would become AAA. Data from July (Don't know if...

Read POSTed Binary File And Write To a New Binary File

I'm creating a web page that will allow user to upload files to the server. I was able to save the file on the server, but I notice that the office files (e.g. word, excel) are corrupted and can not be opened. My UI is fairly simple <form method="post" enctype="multipart/form-data"...

How can I make a postgres role that has limited access, no insert update, but can do maintenance tasks like reindex and backups?

I have postgres 9.3 being installed with my windows desktop app on computers all over the place. I don't want Joe Script-kiddy looking at the pgpass.conf, getting the postgres password a running amuck in my Database. I was able to to make a backup role using this article but I...

getElementByID() parameter explanation

Im looking at some automation scripts that were working with a web portal to save a lot of grunt work. The commands for selecting windows and such makes sense to me, however there are a lot of lines that look like Set oSelect = wndw.document.getElementById("pvBody:PageTemplate:innerHolder:ctrlAddPassword:ddlSafename") Or Set oSelect = wndw.document.getElementById("pvBody:PageTemplate:innerHolder:ctrlAddPassword:PasswordProperties:rptRequiredProperties:_ctl2:ctrlRequiredProperties:ddlValue")...

Iterate through the folder and find a particular file

I have written this code to iterate through the folders and exit the function when it finds the ".c" file. Ideally it should return the path of the ".c" file. But its returning empty string. tval = 1 Function findStlcode(objFSO,fFolder,folderName) Set objFSO = CreateObject("Scripting.FileSystemObject") Set Folder = objFSO.GetFolder(fFolder) Set colfiles...

Why use a wild card capture helper method?

Referring to : Wildcard Capture Helper Methods It says to create a helper method to capture the wild card. public void foo(List<?> i) { fooHelper(i); } private <T> void fooHelper(List<T> l) { l.set(0, l.get(0)); } Just using this function below alone doesn't produce any compilation errors, and seems to work...

How can I find a node containing a sub-string?

I am able to find nodes in an XML file using the following statement: Set user = objXMLDoc.selectSingleNode("//user[@id = '" & id & "']") But the XML files I'm reading are being generated automatically and sometimes contain spaces after the ID. The id attribute of the user node might look...

Alternative of IN keyword of SQL in Siebel Server scripting for search spec?

Does anyone know how can we filter BC results based on multiple values in search specification? As IN keyword in SQL ? something like: bc.SetSearchExpr("[Id] in ('a','b','c')"); Or use of OR operator is the only solution? ...

for each loop: how to step out of conditions

I am stuck at creating a loop for testing filenames with VBScript. To be precise, I am trying to perform something like a jump in a For Each loop. The loop should test all files in a folder and in some cases it should delete some files. But while running,...

unformatted output with wild card in Fortran

I've searched for a long time before I ask: I need to output a lot of unformatted files in Fortran to Ensight. I want to name them with geo.000000, geo.000001 ... geo.0001000. Here is how I deal with wild card: character(54) :: filename, temp character(80) :: buffer write(temp,'(i6.6)') step filename...

Why can't we capture wildcards for the method with two parameters?

Related to that question. I know about wildcard capturing. For instance, the following could be used for reversing a list: public static void reverse(List<?> list) { rev(list); } //capturing the wildcard private static <T> void rev(List<T> list) { List<T> tmp = new ArrayList<T>(list); for (int i = 0; i <...

Return index of word in string

This code: Module Module1 Sub Main() ' Our input string. Dim animals As String = "cat, dog, bird" ' See if dog is contained in the string. If Not animals.IndexOf("dog") = -1 Then Console.WriteLine(animals.IndexOf("dog")) End If End Sub End Module Return start position 5 in string But how to return...

Selection skipping node on missing childnode

Here is my XML file: <?xml version="1.0" encoding="iso-8859-1" ?> <data> <metadata> <sector>weather</sector> <title>sourceTitle</title> </metadata> <weather> <countries> <country code="AU" name="Australia" region="Oceania"> <location type="APLOC" code="6700" name="Addington" state="VIC" postcode="3352"> <point_forecasts type="TWC"> <related_location type="TWCID" code="9508" name="Ballarat" state="VIC"> </related_location> <point_forecast...