VB Petition

Source Code, Ask the NT Pro

    The following code was all published for Ask The NT Pro, and can also be found at Ask The NT Pro.

To find a project where a particular API is used, look at the API Lookup.

rule1.gif (1558 bytes)

As of 10/02/2000, I will no longer be doing the monthly Ask The NT Pro column. DevX is cutting back on their costs, and to quote, "Your solutions have a regular audience, but not a large one." It 's been a fun run, for about 4.5 years (since 3/98), and hopefully some of the solutions have been helpful to you. I have now updated the projects on this page to include all of the columns, but there won't be any more updates.

rule1.gif (1558 bytes)

(#44) Comparing Computer Information With VB and WMI (Part 2)

    The final solution is an extension of solution #42, which uses a slightly different technique (reading the NT registry via WMI) to get *all* the installed software (not just the MSI-installed software) and the engineering quick-fixes installed.

Download: Code for Solution #44 

rule1.gif (1558 bytes)

(#43) Reading Archived (*.EVT) Event Logs

    This solution is an extension of code I previously did for VBPJ. It allows you to view the data from a saved *.evt file from either a local or remote computer.

Download: Code for Solution #43 

rule1.gif (1558 bytes)

(#42) Comparing Computer Information With VB and WMI (Part 1)

    This solutions uses VB 6.0 for the UI, and WMI for the core code to give you a side-by-side comparison of information on two different computers on your network. With this code, you can compare operating systems, computer systems, process, logical disks, physical disks, page files, network adapters, video setting, services, and installed software.

Download: Code for Solution #42 

rule1.gif (1558 bytes)

(#41) Creating a Remote Task Manager with WMI (06/2002)

    The task manager is an extraordinarily useful tool for diagnosing problems on the local computer. So, a remote task manager would be useful diagnosing problems for remote machines, right? With WMI, it really not so hard to construct. 

Download: Remote Task Manager 

rule1.gif (1558 bytes)

(#40) Extending WMI Scripts for Reusable Code (05/2002)

    Reusing code is good, even when you are working with scripting languages. By using WSH (Windows Scripting Host), you can call multiple *.VBS files from a WSH file without copying-and-pasting each time. In other words, you can have shared, reusable code. 

Download: Using WSH 

rule1.gif (1558 bytes)

(#39) WMI: All The Info, All The Time (04/2002)

    How much information about the network and attached computers can you retrieve with WMI? Pretty much as much as you want <g>. The VB GUI shows how to get a fairly large subset of computer information from any computer on the network via WMI calls. 

Download: Retrieving Computer Info 

rule1.gif (1558 bytes)

(#38) WMI: Shutting Down or Rebooting Remote Networks (03/2002)

    Shutting down or rebooting remote computers is fairly trivial with WMI, assuming the machines have WMI installed (all W2K+ computers, can install for NT 4.0 or Win9x). The actual WMI call is simple, and could be used in a script, but I've build a GUI around it to make ad hoc calls simpler. 

Download: Rebooting with WMI 

rule1.gif (1558 bytes)

(#37) Using NetUserModalsGet (01/2002)

    You can grab global user and group security information by using NetUserModalsGet. In fact, before ADSI/W2K, it was pretty much the only way to get some of this information. It is still useful for a lowest common denominator approach with works with most of the Windows versions (although the utility itself was only tested on W2k, and the code would need some mods if you *run* the utility in Win9x). 

Download: Using NetUserModalsGet 

rule1.gif (1558 bytes)

(#36) Time Synchronization (12/2001)

    The code gives you a quick way to compare (and optionally synchronize) the time on your computer with any other NT computer on your domain. 

Download: Time Synchronization 

rule1.gif (1558 bytes)

(#35) Scripting with WMI, Part 2 (11/2001)

    Continuing with scripting with VBS and WMI (see Translate SIDs to Names with VBS), the first VBS script allows you to find all services which are set to automatic, but which aren't running, on either a local or remote machine. This is useful when you get the "one or more services did not start" on bootup. The second script shows all MSI-installed components (again, on either the local or a remote machine), with either a summary or detail levels.

Download: Scripting with WMI, Part 2 (VBS) 

rule1.gif (1558 bytes)

(#34) Translate SIDs to Names with VBS (10/2001)

(Scripting with WMI, Part 1)

    A command-line script is sometimes a better solution than a full-fledged GUI applet. This particular script will translate each SID (S-1-5-21-1857152614-3074254827-3089642312-1128) found in HKEY_USERS into a user name. It will work on either a local or remote registry (assuming you have the rights to read this info). If you are working on a machine with many logons, it makes it easy to determine which SID has the user info you are looking for.  If you do need to put this functionality into a utility program, it should be trivial to bring it into VB 5.0/6.0.

Download: Translate SIDS to Names (VBS) 

rule1.gif (1558 bytes)

(#33) Detect a Locked Workstation (09/2001)

    This little example program came from a question on the DevX forums -- "How do I tell (programmatically) if a workstation is locked?".  Seems simple, but it's really non-obvious how to do this (or, at least, it was to me). The code is the result of a look of reading (and a little guessing), but it does work, and does make sense. It will also detect if a screen-saver is running, with some limitations. Under W2K+, it will always detect the screensaver. If you are running NT 4.0, it will detect the screen saver only if the "Password Protected" box is checked.

Download: Code for Detect Locked Workstation

rule1.gif (1558 bytes)

(#32) Viewing VB Project Files (08/2001)

    I can't count the times I've dragged one after another *VBP file into a copy of Notepad to view the data there -- the components, the references, or the project properties. Wouldn't it be nice to right-click on a *.VBP file and view a condensed, easily readable extract from that file? This project is a standard executable that will allow both command-line and drag-and-drop interfaces, but if you modify and run the included *.reg file (ProjectInfo_NT.reg or ProjectInfo_Win9x.reg), then you will get an addition to your right-click context menu (for VBP files only). Be *sure* to modify the path in the *.REG file to the path of the executable *before* you run it.

Download: Code for VBP Viewer

rule1.gif (1558 bytes)

(#31) Programmatic Control of DFS (07/2001)

    There aren't a lot of examples of programmatically working with DFS (Distributed File System) for W2K, but here's one in VB 6.0. DFS allows admins to setup one or more share points on the network where all the shares are listed -- definitely a win-win situation.

Download: Code for DFS_Demo

rule1.gif (1558 bytes)

(#30) Create HardLinks in W2K (06/2001)

    Ok, HardLinks (via CreateHardLink API) are a rather esoteric subject, but are useful in certain situations. The included code works only with W2K+, but there is a alternate API to use with prior versions of NT. BTW, Hard Links have been around since NT 3.1, since they were required for POSIX compliance.

Download: Code for HardLinks

rule1.gif (1558 bytes)

(#29) Log Computer Environmental Information (05/2001)

    Many times I've needed a way to log the environmental information on a remote user's machine. MsInfo32.exe is good, if Office is installed, but it's not OLE-automatable. This project is a DLL (together with simple test frame) that you can add to your VB application to programmatically log this info to a local text file. It doesn't log *all* the parameters, but it does do those that have helped me in the past.

Download: Code for Computer Environmental Information

Download: Sample Text Output

rule1.gif (1558 bytes)

(#28) Administering NT Event Logs (04/2001)

    The code included lets you save the NT event logs to either the default binary format or a delimited format (you pick the delimiter) via WMI. A UI is included to exercise the class. The code also shows you how to monitor event log "events" and look for any entries with a specific Event ID.  

Note: a minor bug (thanks Earl Damron) has been fixed. If you want to fix it yourself without re-downloading, just go to Form2, and set the option button(0) value to FALSE. Since it was set to TRUE, setting the option value in the Form_Load did not actually do anything, and thus did not initialize the module-level variable.

Download: Code for Administering NT Event Logs

rule1.gif (1558 bytes)

(#27) Local and Remote Rebooting (03/2001)

    The code includes two ways to reboot local or remote NT machines -- via the API, or via WMI. Each method has positives and negatives, but this selection should give you enough choices to find one that meets your need.

    You can also use the utilities included in the NT Resource Kit. See the full solution at Ask the NT Pro

Download: Code for Local and Remote Rebooting

rule1.gif (1558 bytes)

(#26) Programmatic File Encryption in W2K (02/2001)

    This is an extension of the "Programmatic File Compression" (below) which allows you to encrypt of decrypt files and directories in Windows 2000. Note that Encryption and Compression are mutually exclusive in W2k, although Encryption does actually compress the file somewhat.    

    A single reusable class, NtEncrypt.cls, is included, as well as a UI to exercise the class.

Download: Code for Compress and Encrypt

rule1.gif (1558 bytes)

(#25) Advanced User Rights in W2K (01/2001)

    No code... 

rule1.gif (1558 bytes)

(#24) Programmatic NT File Compression (12/2000)

    Once you get past a couple of oddities, programmatic file compression on NT NTFS directories is very simple. This short program will show you how to do it..

Download: Code for NT File Compression

rule1.gif (1558 bytes)

(#23) NT File Attributes (11/2000)

    Show all the NT-only file attributes: like encrypted, compressed, sparse, off-line, context index, and temporary. Also, show the file size and size on disk (useful when you have compressed files).

Download: Code for NT File Attributes

rule1.gif (1558 bytes)

(#22) Short File Paths (10/2000)

    Some programs, particularly older ones, cannot use long file names or paths (particularly if they contains spaces).    

    This is a very small utility with allows you to get the short name/path from a long name/path. The most useful way to use this utility is to put a shortcut to the EXE in your SendTo folder (on NT 4.0, at x:\WINNT\Profiles\MyUserName\SendTo -- on W2K, at x:\Documents and Settings\MyUserName\Send To) . In this way, when you right-click on a file (or directory) and select SendTo, you can get the short path/name directly without doing a lot of typing.

Download: Code for Short File Paths

rule1.gif (1558 bytes)

(#21) There Has Been a Sharing Violation...  (09/2000)

    No Code....

rule1.gif (1558 bytes)

(#20) Find Registry Hacks Quickly (08/2000)

    No Code....

rule1.gif (1558 bytes)

(#19) Get User's Home Directory with ADSI (07/2000)

    Get a network user's home directory with ADSI.

Download: Code for Get Home Directory

rule1.gif (1558 bytes)

(#18) Enabling or Disabling a NT User Account (06/2000)

    How to enable or disable a NT User's account via the API (as opposed to via ADSI, if you have it available)

Download: Code for Disable Account

rule1.gif (1558 bytes)

(#17) Disk Quotas (05/2000)

    Disk quotas are a long asked-for feature in NT. Now, with W2K, we have them, and a reasonably simple COM interface (callable from Visual Basic and even script languages) to boot.
    The download is a *very* simple interface for setting disk quotas for NTFS volumes on a volume basis. Not a lot of error trapping, and a rather simple-minded UI, but it should be enough to get you started.

Download: Code for Disk Quotas

    You might want to download the more complete VBPJ code (I expanded it from the Ask The Pro column at: 

Download: VBPJ Code for Disk Quotas

rule1.gif (1558 bytes)

(#16) WMI: Another Example (04/2000)

    Get NIC information with WMI

Download: Code for WMI: Another Example

rule1.gif (1558 bytes)

(#15) Using WMI (03/2000)

    A quick example of how to use WMI to get info in hard disks.

Download: Code for WMI Demo

rule1.gif (1558 bytes)

(#14) Think ADSI (02/2000)

    No Code.... 

rule1.gif (1558 bytes)

(#13) Rights Are Important: Saving Your Registry Keys (01/2000)

    How to save a specified registry (and all it's subkeys) via API calls. It's saved in a binary format -- efficient for large amounts of info, but not human-readable.

Download: Code for Save Keys

rule1.gif (1558 bytes)

(#12) Reader Helps Out With Offline Registry Editing (10/1999)

    No Code....

Last modified on: Tuesday, 08 March 2005 07:16:15 PM