Bookmark and Share

In this post:

 

How Can I Release Memory from an SSIS Loop Container on Windows Server 2003?

Hey, Scripting Guy! Question

Hey, Scripting Guy! When I use a For loop to cycle through a container a number of times when running another package, I have needed to reboot the server to release memory so that the server could continue to function. I expanded the page file to prevent server freezing, but I see that when the SSIS package ends, the page file utilization remains at a high level. Is there a script that can be run from SSIS to release memory from a SSIS Loop Container on a Windows 2003 Server upon completion of the script? Apparently, this memory loss is a known problem.

-- SD

 

Hey, Scripting Guy! AnswerHello SD,

Microsoft Scripting Guy Ed Wilson here. Wow. You lost me at SSIS package. I am not sure what that is, but it really does not matter. I know of no way, via script, to manipulate the page file and to force something to release memory other than stopping and restarting processes. The problem on SQL Server is that if you choose to stop and restart the SQL service, if it is Microsoft SQL 7 or above, you lose the cached execution plans and other things that are used by SQL to improve performance. The SQL process will always expand to consume all the available memory on a server to eventually cache portions of the database in memory.

If your SSIS program has a memory leak, the maker of the program should fix the problem. If it is a Microsoft product, a support case should be opened with our Customer Support Services. Running a script, and then rebooting the server is not a very productive method of management, and certainly not be taken as a standard operating procedure.


Tell Me About Scripting for Windows Vista

Hey, Scripting Guy! Question

Hey Scripting Guy! Hi! I would like to know where I could find information on scripting and syntax (code) for Windows Vista, and what software I could use to write it. In addition, I would like to know if C++ could achieve these same results somehow. I want to do real basic things such as turn an integrated camera or microphone on and off. I think this is basic, but might require some more knowledge. Thanks in advance!

-- CP

 

Hey, Scripting Guy! AnswerHello CP,

In Windows Vista you can use VBScript to do many things. Scripts that worked all the way back to Windows 2000 for the most part will still run on Windows Vista. There have been a few additions over the years, and even a few improvements in Windows Vista, but all in all, it is the same. We have a Scripting for Vista page at the TechNet Script Center that might give you a few ideas.

If it were I, however, I would download and install Windows PowerShell 2.0 onto my Windows Vista machine. Windows PowerShell 2.0 is extremely powerful because it provides nearly complete access to the .NET Framework and even allows you to run Win32 APIs and other unmanaged code.

To control your camera, microphone, and whatnot is not really basic scripting. In fact, I believe you will be writing in C++ or at least calling the Win32 APIs from Windows PowerShell 2.0. If you decide to do this, you may wish to look at the PInvoke wiki, which is what I use because the method signatures can get rather complicated for those who are not using it on a daily basis.

At any rate, I think it will be a fun and most excellent project. I would love to see your code when you get it finished, so please share it on the Script Repository.  

 


Can I Send Data from a VBScript Script to an Already Opened Microsoft Excel Workbook?

Hey, Scripting Guy! Question

Hey, Scripting Guy! How can I send data from a VBScript script to an already opened Microsoft Excel workbook without opening a new Excel object?

-- MG

 

Hey, Scripting Guy! AnswerHello MG,

You need to use the save method from your workbook object. The How Can I Make Changes To and Then Re-Save an Existing Excel Spreadsheet Hey, Scripting Guy! Blog post talks about using the save method and will provide you with the appropriate guidance for your script.

 

 

Tell Me More About Inputs and Outputs in Windows PowerShell

Hey, Scripting Guy! Question

Hey, Scripting Guy! Thanks for publishing that great article about adding help to a Windows PowerShell script. That table of available leafs was particularly useful. My concern or should I say frustration would be around .Inputs and .Outputs and the whole .NET access with Windows PowerShell. I have loved being able to use .NET instead of WMI for things like ping and .NET for accessing WSUS, but I have limited exposure as an system administrator to .NET. I have tried to read and teach myself, but I am just concerned there is potential that Windows PowerShell will never reach in many system administrators’ hands.

-- JK

 

Hey, Scripting Guy! AnswerHello JK,

I am glad you enjoyed the article. Regarding inputs and outputs, you do not need to have those tags if you do not wish. I like to add them because it is helpful information. I use the Get-Member cmdlet to see what kind of object I am using. For example, I recently wrote a function for Microsoft Visio Week that will convert disk space from bytes to megabytes, gigabytes, and terabytes. I “figured” the input was an int32 and used this constraint on the function: [int32]. The function worked sometimes, but other times it would fail. Bummer! It is particularly distressing when you are automating Visio and have never done that before!

I removed the constraint, and the function worked perfectly! Strange, I thought. Then I used the Get-Member cmdlet on some of my data types and discovered that a terabyte expressed in bytes is an Int64 and not an int32. I found this out by using the syntax seen here:

PS C:\> 1tb | gm

 

   TypeName: System.Int64

 

Name        MemberType Definition

----        ---------- ----------

CompareTo   Method     int CompareTo(System.Object value), int CompareTo(long value)

Equals      Method     bool Equals(System.Object obj), bool Equals(long obj)

GetHashCode Method     int GetHashCode()

GetType     Method     type GetType()

GetTypeCode Method     System.TypeCode GetTypeCode()

ToString    Method     string ToString(), string ToString(System.IFormatProvider provider), string ToString(string f...

 
Having this kind of unexpected information in the inputs and outputs is helpful, and it aids in learning some of the finer points of Windows PowerShell.

 

What Are the Best Online WMI References?

Hey, Scripting Guy! Question

Hey, Scripting Guy! I thought you might have an opinion about the best online reference for building WMI event queries. I am working on documenting WMI event monitors and want to provide a reference about how to build the query.

-- BW

 

Hey, Scripting Guy! AnswerHello BW, 

The “best” documentation is always the MSDN documentation. On the Hey, Scripting Guy! Blog, we have TONS of Hey, Scripting Guy! posts related to receiving WMI events. That link contains both VBScript and Windows PowerShell examples. In my Microsoft Press WMI book, I have an entire chapter dedicated to working with WMI events.

 

Well, this concludes another edition of Quick-Hits Friday. Join us tomorrow for the Weekend Scripter as we delve into the mysteries of…well, we will let that remain a mystery for now.

If you want to know exactly what we will be looking at tomorrow, follow us on Twitter or Facebook. If you have any questions, send e-mail to us at scripter@microsoft.com or post your questions on the Official Scripting Guys Forum.

By the way, do not forget the 2010 Scripting Games begin on April 26. Beginners are encouraged to give it a go because you will learn a lot and have a ton of fun. Follow the Scripting Wife as she progresses in her quest to be the first Scripting Wife to ever compete in the Scripting Games. Because she is a complete novice when it comes to scripting, she can help you learn scripting in a way that no one else can—she feels your pain and shares your joys. Not only that, she is really cool.

 

Ed Wilson and Craig Liebendorfer, Scripting Guys