OnScript – VBScript Editor
See more from OnScript’s own site and get your free evaluation copy.
Alternatively, see why Guy Recommends OnScript.
Line Numbers
I actually use OnScript myself. The problem that I have with Notepad is that it’s not easy to see the line numbers, so when I get the inevitable WSH Error message I cannot easily find the line to which the message refers.
Naturally I can work out where Line: 17 is located with notepad, but it takes time. Moreover, my brain wants to concentrate on the high level task of solving the problem not the low level task of counting line numbers.
Color Coding
OnScript’s color coding prevents me from making silly errors by placing comments in green, verbs in blue and strings in dark red. Color coding and line numbers may sound trivial, but these are my killer reason for buying a script editor. However, a top quality script editor such as OnScript has many more features.
OnScript’s features
Not only will OnScript help with troubleshooting, but also it will give you extra insights as to how VBScript works. After you select a command you get a little drop down menu that show you what commands are available. OnScript also has a library of VBScript commands. As a practical point, I am increasingly impressed with tabs so that you can gain quick access to half a dozen files that I am working on.
When you run your scripts in the OnScript interface you get an output box so that you can see if it executed properly, or peruse any error messages. There is no equivalent with notepad.
Conclusion
It all comes down to whether you believe time saved means money saved. OnScript will save you time, both troubleshooting individual scripts and learning VBScript. Finally, no online software gets the ‘Guy Seal of Approval’, unless you get a trial offer and, or a money back guarantee.
Here is the link toOnScript’s free evaluation copy
Example Script: To Map a Network Drive to letter U:
Pre-requisites
You need a free local drive letter. Rather eccentrically, I have chosen letter U as the drive letter because my H: is already in use. Feel free to amend strDriveLetter.
You will need a shared folder. If no other machine is available, share out a folder on your own machine. Make sure that you amend strRemotePath to reflect your UNC path and not mine.
This script should work on any Windows, machine. However, Example 2 will need active directory for the username.
Instructions for mapping network drive
Copy and paste the example script below into notepad or use a VBScript editor.
One advantage of a good script editor such as OnScript is that it displays each method’s arguments.
Save the file with a .vbs extension, for example: mapnetworkdrive.vbs
Double click mapnetworkdrive.vbs, the check the drive letters with Windows Explorer.
‘ MapNetworkDrive.vbs
‘ VBScript to map a network drive.
‘ Author Guy Thomas https://computerperformance.co.uk/
‘ Version 1.2 – March 2006
‘ ———————————————————————-‘
Option Explicit
Dim objNetwork, objExp
Dim strDriveLetter, strRemotePath
‘ Values of variables set
strDriveLetter = "u:"
strRemotePath = "\\grand\ezine"
‘ This section creates a network object. (objNetwork)
‘ Then applies the MapNetworkDrive method. Result U: drive
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath
‘ Just to check the script has executed.
WScript.Echo "Check explorer for " & strDriveLetter
WScript.Quit
‘ End of Example script .
Learning Points
Note 1: Example 1 illustrates the classic VBScript technique: object, method, value. This week we feature a network object (not a FileSystemObject).
Note 2: In a production script we would remove the WScript.echo command. In testing, I like such commands because they demonstrate that the script has completed.
Note 3: This script, while great for learning the MapNetworkDrive basics, does have deficiencies. For instance, it does not allow you to specify a different user’s credentials. More irritatingly, it gives an error message if you run the script for a second time. For now, add :
On Error Resume Next. Next week will deal properly with this error problem.
Conclusion
It all comes down to whether you believe time saved means money saved. OnScript will save you time, both troubleshooting individual scripts and learning VBScript. Finally, no online software gets the ‘Guy Seal of Approval’, unless you get a trial offer and, or a money back guarantee.
Here is the link toOnScript’s free evaluation copy