vbScript - Create a Log File Using vbScript Classes Before I retired I was responsible for most of the corporate data plumbing at our control centre. All of the plumbing was written in vbScript. As any maintenance programmer knows, log files are a vital key in identifying and fixing problems. Because I am basically lazy I don't like to code the same process over and over so I created logging code that could be included in any script. The scripts were run automatically on periods ranging from once every five minutes to once a week, or even as little as …

Member Avatar
+0 forum 0

##vbScript - Run an External Program and Capture the Output Please see my post [vbScript - The Basics](https://www.daniweb.com/programming/threads/516400/vbscript-the-basics) for more details on vbScript. When you want to execute an external program for a particular result (such as resizing an image, as shown in a previous snippet) you can simply use the `Run` method of the `Wscript.Shell` object. However, if you want something a little more complex there is the `Exec` method of the same object. This method gives you access to the standard input, output, and error streams. As such, you can take advantage, for example, of the increased flexibility …

Member Avatar
Member Avatar
+1 forum 1

Over the last few days I have been converting old video files from avi to mp4. I've been doing this using the command line version of DivX. This is the process behing the DivXPro GUI and it is named `DivXEngine.exe`. Converting video files takes a big hit on the CPU and I would prefer to set the process to a lower priority to minimize the impace on my usual tasks. Under Windows 7 there was a utility program that could be used to permanently change a task priority. Unfortunately it no longer works in Windows 10 so I did the …

Member Avatar
+1 forum 0

##vbScript - An Application to Modify srt Subtitle Files Please see my post [vbScript - The Basics](https://www.daniweb.com/programming/threads/516400/vbscript-the-basics) for more details on vbScript. So far I've posted either functions/subs or code snippets to illustrate a technique. This time I am going to post a complete application. First, a few points. 1. I am somewhat hearing impaired - just one of the hazards of increasing age and heredity. 2. Because of 1 I find I am making increased use of videos with subtitles 3. I like to collect videos over the winter to watch at the cottage in the summer I use …

Member Avatar
+0 forum 0

##vbScript - Some Useful String Functions Please see my post [vbScript - The Basics](https://www.daniweb.com/programming/threads/516400/vbscript-the-basics) for more details on vbScript. vbScript provides a number of functions for manipulating strings. I find that a few more simple functions would have made things a lot simpler. For example, I find myself checking to see if a string starts with a given string. What I have to code is If len(str1) < len(str2) Then StartsWith = False Else If Left(str1,len(str2)) = str2 Then StartsWith = True Else StartsWIth = False End If It would be much clearer if I could do If StartsWith(str1,str2) Then …

Member Avatar
Member Avatar
+1 forum 1

##vbScript - Identify File by Perceived Type Please see my post [vbScript - The Basics](https://www.daniweb.com/programming/threads/516400/vbscript-the-basics) for more details on vbScript. There are times when you want to operate on all files of a given type. For example, you may want to enumerate all files in a folder or a drive that are recognized by Windows as video or audio. But how would you do that? There are so many video file types that it would be difficult to test for even the more common file extensions. Better to ask Windows to do the identification. The Windows Registry contains an key …

Member Avatar
+1 forum 0

##vbScript - Get Drive Letter by Volume Label Please see my post [vbScript - The Basics](https://www.daniweb.com/programming/threads/516400/vbscript-the-basics) for more details on vbScript. I have all my computers partitioned with two partitions. The drive letters are C (OS and applications) and D (user data). I use Macrium Reflect to take monthly full and daily differential images of C. To backup D Ii use a script front end for robocopy. Using a script to do the backup has one major problem. The drive letter of my dedicated backup external drive may change. I find that even if I have used Drive Manager to …

Member Avatar
+1 forum 0

##vbScript - Browse for Folder or File Please see my post [vbScript - The Basics](https://www.daniweb.com/programming/threads/516400/vbscript-the-basics) for more details on vbScript. Some scripts need input (other than from the command line) from the user. This can be read from the console (StdIn) or from a pop-up textbox (InputBox). This is fine for simple input but you certainly wouldn't want to have to type a folder or file name, especially when it might include a lengthy path. There are several ways to avoid typing a long folder or file name. If you create a shortcut to your script on the desktop you …

Member Avatar
+0 forum 0

##vbScript - Convert Integer to Binary String Please see my post [vbScript - The Basics](https://www.daniweb.com/programming/threads/516400/vbscript-the-basics) for more details on vbScript. vbScript has a number of functions for converting from one type to another. These functions are named C<type> as in CInt (convert to int), CDbl (convert to double), etc. There are also functions that will format numbers as string (FormatNumber, FormatPercent, FormatCurrentcy, Hex, etc.) One glaring omission is a function to format numbers (integers) as binary. Fortunately the process is straightforward. If we first convert the number to e hexadecimal string we can then convert each hex digit into its …

Member Avatar
+0 forum 0

##vbScript - Sorting With and Without Code Please see my post [vbScript - The Basics](https://www.daniweb.com/programming/threads/516400/vbscript-the-basics) for more details on vbScript. Sorting is something that must be done from time to time. I'm going to examine three ways. The first is the well known (at least by name) QuickSort method. Rather than repeating existing explanations of the actual algorithm I'll just refer you to the [Wikipedia QuickSort article](https://en.wikipedia.org/wiki/Quicksort) and present the code with comments below. The second method uses a binary tree. The concept is simple even if the implementation is a little difficult to grasp initially. We start with the …

Member Avatar
+1 forum 0

This is the first in (hopefully) a series of posts about vbScript. Please see my post [vbScript - The Basics](https://www.daniweb.com/programming/threads/516400/vbscript-the-basics) for more details on vbScript. My wife and I take a lot of pictures. Naturally, we end up sending pictures to friends through email. I find it is unnecessary, and often inconsiderate to send full size images via email. When most of our friends end up viewing these images on a hand-held device, it is pointless to send an image wider than 600 pixels. As such, I have to repeatedly 1. Copy the full size image to a temporary folder …

Member Avatar
+2 forum 0

##vbScript - the basics My plan is to post a series of hopefully useful and informative vbScript Functions and Subs. I started writing up my first code snippet and found that I was taking too many side trips to explain things about the vbScript syntax and language so I decided to postpone the first snippet until I had completed a vbScript intro. There has been a lot of interest in scripting languages, most notably Perl and Python. While decidedly less versatile and powerful than Python, vbScript (which is way down on the list) has several good points to recommend it. …

Member Avatar
Member Avatar
+2 forum 1

This code generates an ascii maze of up to size 30x30. If you try to generate a larger maze then you will likely run out of stack space. There is no way to increase the size of the stack in vbscript. Each cell in the maze is represented by a string of five characters such as "11110". The first four chars represent whether a wall is present ("1") or absent ("0") in the four directions "UDLR". The fifth char represents whether a cell has been visited ("1") or not ("0"). Each cell maintains its awareness of the four walls bounding …

Member Avatar
Member Avatar
+0 forum 2

I've been using GenuTax since 2013 to file my Canadian tax return. It's provided free and does the job nicely, but it misses one feature. Up north we can do pension splitting. That means I can offload some of my pension income onto my spouse, hopefully putting us in a lower tax bracket. Figuring out the optimum split is a chore. I have to type in a value then add up the separate values for me and my spouse to see if the combined number is better or worse than my previous guess. It's tedious and unnecessary so this yoar …

Member Avatar
+0 forum 0

Over the years I've seen a lot of discussion (and several implementations) of the Quicksort algorithm. Most of what I have seen, unfortunately, lacks sufficient commenting as well as meaningful variable names. Hopefully the following vbScript code will more clearly show how Quicksort actually works. A couple of incidental notes: 1. I use PrimalScript for editing and I have comments set to display with a silver-grey background and black text. This makes comments very distinct from code (and is also why I have a closing single quote at the end of lines). 1. The test code section at the end …

Member Avatar
Member Avatar
+1 forum 6

An often underused control from vb.Net is the FolderWatch control. But sometimes you need to throw something together that doesn't need a fancy GUI. Or perhaps the task seems too trivial to go to the hassle of coding it up in vb.Net (or C#). Because the FolderWatcher is built on underlying WMI (Windows Management Instrumentation) technology, it can actually be implemented quite simply from vbScript. Please see the sample below. In actual use you would place more useful code in the Create/Delete/Modify Case clauses.

Member Avatar
+1 forum 0

A while back I came across an article that mentioned genetic algorithms. For those unfamiliar with the term, simply put, rather than finding a solution to a problem by iterating over all possible cases, a genetic algorithm attempts to find a solution by starting with a guess, then generating a next guess by applying numerous random changes to the current guess and picking the guess that best fits the solution as the next best guess. Rinse and repeat. Unfortunately, most of the articles and examples I came across involved far too much tech speak and math for a brain long …

Member Avatar
Member Avatar
+2 forum 4

Hello, I've been working on learning VBScript to make a few useful scripts to work with WinNT and make a more user friendly interface when searching for users on a domain. While doing so, I discovered something interesting about arrays and I'm hoping someone could explain if it's just the way microsoft made VB or if it's something else. If I decalre an Dim myArray(2), one would think valid subscripts would be myArray(0) and myArray(1), but it's not. Dim myArray(2) myArray(0) = "Hello" myArray(1) = "World" myArray(2) = " This should give an error" WScript.echo myArray(0) & " " & …

Member Avatar
Member Avatar
+0 forum 2

I have a Chromecast that I use to stream video from my laptop to our TV. It works great, however, until VLC (Videolan) releases their promised upgrade with Chromecase support, I am limited to streaming files in the mp4 format. Fortunately, ffmpeg allows me to convert other formats to mp4. Unfortunately, figuring out what parameters to use can be daunting. So far I have determined the commands to use to convert avi, flv and mkv. The last two are a simple repackaging of the contents (takes but a few seconds). The first, avi, requires a complete recoding. The following commands …

Member Avatar
Member Avatar
+1 forum 4

Group, I'm trying to write some code that will read the clocktime. When it hits a predetermined time, I want it to run a routine. I know how to do this in VB.net. It would be done like this: Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick If TimeOfDay = "10:01:00 PM" Then 'Go do something important End If End Sub Unfortunately I don't know the equivalent to the same in vbScript (if there is something like it). I did find a "timer" online that counts the number of seconds from midnight. It looks like this: Function TimeIt(N) …

Member Avatar
Member Avatar
+0 forum 4

Hi All, I'm working on a script which has a primary function to look for jpg files. I can get it to work if the folder path is just my desktop but if I try the start of the path to be C:\ it errors out. Right now the error has to do with the MID function but I know it is because of me trying to go through all of C:\. See the code below and if you can assist me I would really appreciate it. Set objFSO = CreateObject("Scripting.FileSystemObject") 'objStartFolder is where you enter the folder path string …

Member Avatar
Member Avatar
+0 forum 4

Not sure if this is the right spot for this question but I'm here! I'm trying to make a vb script that opens large text files, one at time, searches each line for Null values (there can be many) and then replaces them with a space. My coworker put the following together which takes a very long time because it is basically iterating through millions of characters in the file: Do Until objFile.AtEndOfStream strCharacters = objFile.Read(1) 'Wscript.Echo strCharacters ' Wscript.Echo Asc(strCharacters) If Asc(strCharacters) = 0 Then objOutFile.Write(" ") Else objOutFile.Write(strCharacters) End If Loop What I was hoping to do was …

Member Avatar
Member Avatar
+0 forum 6

I find that I occasionaally have special projects where it would be nice to have a context menu for files. I tend to write housekeeping scripts and it is convenient to be able to run these scripts against one or more files at a time without having to navigate and run through the command line. For example, I have accumulated a large number of articles and ebooks. I file them with a consistent naming convention, to wit Author Name - Title.ext where the author name is in the form "First Last" if I have not yet read the article or …

Member Avatar
+0 forum 0

Hi, I have a scenario where in I had to sort an array, find duplicates and increment one or the other by 1. So, Eg: An array has 22, 23, 21, 21, 24 within it then, an array should be able to find 21 and increment it by 1 i.e. 22. Also, on the other hand, it should now go scanning from the start and find 22 already present and increment that by 1. So, far had managed to sort an array which is just a part of the entire project. Anyone too good in VBscript, please?

Member Avatar
Member Avatar
+0 forum 2

Hi all, We use a .hta vbscript from a fileserver, but after office 2007 has been intalled, the script does not read/write from/to a .mdb file on that same fileserver. The script does work (with office 2007), if it is started from a desktop instead of the fileserver. (reading/writing the same .mdb file on the same fileserver) On the desktops, in office 2007, the fileserver and directories are added to the "save locations". Any Idea's on why the script doesn't work anymore when started "on" the fileserver, what can be done to make it work again..? (going back to office …

Member Avatar
Member Avatar
+0 forum 2

> I have an xml document that looks like this: <OUTPUT version="2.0"> <RESPONSE> <LOAN_DATA loan_id="xxxx" loan_number="1111" loan_type="HE" status_code="OK"> <![CDATA[<MORTGAGE_LOAN xmlns="http://www.something.com/CLF" version="1.0"> <APPLICANTS> <APPLICANT is_declined="N" first_name="MARISOL" last_name="TESTCASE" m_initial="L" middle_name="L" ssn="000000001" > </APPLICANT> </APPLICANTS> </MORTGAGE_LOAN>]]> </LOAN_DATA> </RESPONSE> </OUTPUT> I can successfully read down to the CData section and can even access the CData section using the following: string cData = ""; XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(loanData); XmlNode node = xDoc.DocumentElement.SelectSingleNode(@"RESPONSE/LOAN_DATA"); XmlNode childNode = node.ChildNodes[0]; if (childNode is XmlCDataSection) { XmlCDataSection cdataSection = childNode as XmlCDataSection; cData = cdataSection.Value; } > cData now holds: <MORTGAGE_LOAN xmlns="http://www.something.com/CLF" version="1.0"> <APPLICANTS> <APPLICANT is_declined="N" first_name="MARISOL" last_name="TESTCASE" …

Member Avatar
Member Avatar
+0 forum 1

GoodDay All. I am trying to create a hit counter in vbscript on a HTML Page for specific client needs. I cannot use any hit counters available for free. My problem is that my code only finds the text file on my notebook(Local C:\ drive) and not in the website even though the file does exist. my other problem is that when the page code reaches the "server.creatobject" line, i get the error (Microsoft VBScript runtime error: Object required: 'server'). I write mostly in VB but the client wants a specific HTML page and NOT ASP/ASPX. Can someone help me …

Member Avatar
Member Avatar
+0 forum 1

I had written a script to login to some terminals and do some basic commands remotely. It fails at password entry. ******************************************************************* Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "cygwin" ' Give Cygwin time to load WScript.Sleep 2000 a=Array(112) For Each i In a WshShell.SendKeys "`ssh user@XX.XX.XX.XX" & i & " 'hostname;ps aux' " & "{ENTER}" WScript.Sleep 1000 WshShell.SendKeys "******" & "{ENTER}" WScript.Sleep 2000 Next *************************************************************** It's taking till password step fails very next. I had double confirmed the password.

Member Avatar
+0 forum 0

Hi all, We use a .hta vbscript from a fileserver, but after office 2007 has been intalled, the script does not read/write from/to a .mdb file on that same fileserver. The script does work, if it started from a desktop instead of the fileserver. (reading/writing the same .mdb file on the same fileserver) On the desktops, in office 2007, the fileserver and directories are added to the "save locations". Any Idea's on why the script doesn't work anymore, what can be done to make it work again..? (going back to office 2003 is not possible) Kind regards

Member Avatar
+0 forum 0

How to create a website which i want to create by using a vb srcipt and also i want to make a use of java script in this.pls help me out..give me suggestions regarding this.

Member Avatar
Member Avatar
+0 forum 1

The End.