Saturday, March 28, 2009

Scripting Q&A

Q: How can I automate the FTP process so it runs on scheduler without user intervention?
A: The FTP.EXE (File Transfer Protocol) command line utility comes standard with the Windows Operating system. Because it's a command line utility, it allows for many options to be entered at run time (simply enter FTP /? at the command prompt for a complete list). When using the -s:filename switch allows for the commands to be read from the filename specified. For example, first create a text file called myFTP.prm with the following commands:

open www.myftpsite.com
myUserID
myPassword
prompt off
binary
mput myfile*.txt

From a command line, execute FTP -s:myFTP.prm. Please note there's no specific extension for file containing the FTP commands. For more info on this, please visit http://support.microsoft.com/kb/96269


Q: How can I execute a command line utility from with a VB Script?
A: The CMD.EXE is a command line utility used for running other command line applications. Typing cmd /? will reveal a variety of command line options for executing the command shell. Listed below is a sample VB script for doing this:

Option Explicit
Dim return, objShell
Set objShell = WScript.CreateObject("WScript.Shell")
return = objShell.Run("cmd /C DIR > DirLog.txt", , True)

After saving these commands into a .vbs file, they can be executed by running "cscript myFile.vbs". Please note the file extension must be .vbs.


Q: Using a VBS script, how can I access registry keys?
A: Listed below is a sample script for accessing registry keys.

Set SysVarReg = WScript.CreateObject("WScript.Shell")
value = SysVarReg.RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Windows Presentation Foundation\Hosting\Hosts\v3.0")
WScript.Echo value

After saving these commands into a .vbs file, they can be executed by running "cscript myFile.vbs". Please note the file extension must be .vbs.

Another useful example of scripting is to query all the processes running on the current machine and output them to the console.

strComputer = "."
Set objServices = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set objProcessSet = objServices.ExecQuery("SELECT Name FROM Win32_Process",,48)

For Each Process in objProcessSet
WScript.Echo Process.Name
Next

For more information on scripting, visit Microsoft's Scripting Center at http://www.microsoft.com/technet/scriptcenter/default.mspx

Thursday, March 12, 2009

What is a Tablix?

The term "Tablix" can mean different things to different people. However, in the Microsoft realm it refers to the ability of SQL Server Reporting Services (SSRS) to combine a table and a matrix together.


Wednesday, March 11, 2009

Book Promotion from Packt Publishing







Packt Publishing has recently released a new book titled "C# 2008 and 2005 Threaded Programming". To help promote the new book, they have extended a 15% discount to members of the C#/VB.Net User Group. To take advantage of this offer, simply follow the 3 steps below:
  1. Visit http://www.packtpub.com/books and select any Packt title.
  2. Click the "ADD TO CART" button to add the book to your shopping cart.
  3. Now enter "CD15ug" (without quotes) in the 'Promotional Code' field and click the "Update" button. The discounted price should now be reflected in your order.
Although Packt is based in the UK, they do offer free shipping to the US, with books arriving in only a few days. Packt Publishing has also sent a free copy to be given at an upcoming user group meeting. For more information, please visit http://www.packtpub.com/

Wednesday, March 4, 2009

March .Net Events

Mar 10th: .Net User Group (Using TFS). To register, go to http://www.bennettadelson.com/seat.aspx?sig=net&ID=141

Mar 12th: ONSQL User Group. To register, go to http://www.bennettadelson.com/seat.aspx?sig=sql&ID=141

Mar 14th: GCPCUG General Meeting (Switching to a Mac & Windows on a Mac). To register, go to http://www.gcpcug.org/

Mar 24th: Cleveland C#/VB.Net User Group (Writing Secure Code). To register, go to http://www.clevelanddotnet.info/

Mar 25th: Cleveland SharePoint User Group (TBA). To register, go to http://www.sharepointcleveland.com/default.aspx

Mar 28th: Cincinnati Silverlight Firestarter. To register, go to http://cinnug.org/default.aspx.