Blog: script

One of our customers is using Microsoft System Center Configuration Manager (SCCM) to manage software on their network. SCCM requires a client to be installed on each computer. They wanted to use a VB script that checks common errors that cause the SCCM client to stop working and will install the client if it is not installed. I modified a script that was downloaded from the Internet that seemed to meet their needs. The customer has VB scripts set to edit instead of open, so I had to call the VB script from a batch file using cscript. [more]

The script ran fine when testing it from my login by calling it from a command prompt using cscript and then the file path. The batch files calls the VB script, which then does several tests and calls the SCCM install exe if necessary. After setting up group policy to run the script as a startup script, the script would start to run and then fail in the middle of the SCCM client install. During testing, we inserted a “pause” at the end of the batch file and found that the SCCM client installed properly.

What was happening was the SCCM install would immediately quit when the parent batch file ended. There are two ways to fix this problem. The first is to add “ping –n 600” so the batch script will stay open for 10 minutes, which is enough time for the install to complete. Occasionally, this method causes the computer to wait until the batch file completes before it will load the user’s desktop. The second option is to run the batch file as a scheduled task. The scheduled task will be set by another batch files run through group policy. The scheduled task option seems to be the most reliable path at this point because no side effects are seen with this method.


If you need to make modifications to a drive mapping in a logon script that uses the “Net Use <drive> \\computername\sharename” command, be sure to add a line above to delete the previous map using “Net Use <drive> /delete”.  If the previous drive mapping isn’t deleted and recreated, it can continue to use the old drive mapping location.


Incase you didn't know, there is a command line interface for WMI - wmic.

Some documentation is here, and

You can write simple scripts to manage just about anything that your might write a short VB program for – printers, accounts, scheduled jobs, processes, etc. It has a lot of aliases you can use that are documented in the online help, but you can use the actual class commands.  If you just enter wmic on the command line and let it prompt, it sets your command window width to 1500 so output from most commands will not wrap.  You can enter /? At any point for help.  Some examples: [more]

  • wmic process get Caption,Commandline,Processid
  • wmic /node:server1 cpu get description, manufacturer, maxclockspeed, revision
  • wmic process where name='iexplore.exe' call terminate
That last one kills all processes running iexplore.exe.  If you just ran that to see what it would do without reading ahead, then chances are you are not reading this right now.




If Control C will not capture text from a popup message window, you can use Alt-PrtScn, paste into Paint, save to a TIF file, open that with Microsoft Office Document Imaging, choose Recognize Text using OCR, and then Send Text to Word.  Here is an AutoIt script to do that.  Several assumptions are made:  An image is already in your paste buffer, c:\temp\ocr.tif exists, location of %windir% and %ProgramFiles%, etc.  You may have to tweak the sleep statements and as always, your mileage may vary.  [more]

<script language="AutoIt">
; Do OCR on paste buffer
WinWait ("untitled - Paint")
WinActivate("untitled - Paint")
Send("^v")   ; Paste in image
Send("!FA")   ; Save as a TIF file
Send("Y")   ; Yes to replace file
Send("!FX")   ; Exit Paint
Run("C:\Program Files\Common Files\Microsoft Shared\MODI\11.0\MSPVIEW.EXE")
WinWait("Document1 - Microsoft Office Document Imaging")
WinActivate("Document1 - Microsoft Office Document Imaging")
Send("!FO")   ; Open in Microsoft Office Document Imaging
Send("!TR")   ; Recognize Text
Send("!TT")   ; Send Text to Word