A personal repository of technical notes. - CSC

Windows Event Viewer Filter XML

Windows 7 XML Sample

<QueryList>
       <Query Id="0" Path="Security">
              <Select Path="Security">
                     *[System[(
                           EventID=4624
                           or EventID=4625
                           or EventID=4634
                     )]]
                     and
                     *[EventData[(
                           (
                                  Data[@Name='TargetDomainName'] = 'Abcd'
                                  or Data[@Name='AccountDomain'] = 'XYZ'
                           )
                           and
                           (
                                  Data[@Name='TargetUserName'] != 'U123'
                           )
                     )]]
              </Select>
       </Query>
</QueryList>

References

"Event Viewer - Wikipedia, the free encyclopedia." Wikipedia, the free encyclopedia. N.p., n.d. Web. 19 Oct. 2011.
<http://en.wikipedia.org/wiki/Event_Viewer#Filtering_using_XPath_1.0>.

"Windows Event Viewer CUSTOM XML FILTER | Jamin Quimby Installation & Development Notes." Jamin Quimby .com | Jamin Quimby Installation & Development Notes. N.p., n.d. Web. 19 Oct. 2011.
<http://jaminquimby.com/index.php/microsoft-windows-2008/129-windows-event-viewer-custom-xml-filter>.

"Event Log Hell (finding user logon & logoff) - Ars Technica OpenForum." Ars Technica. N.p., n.d. Web. 19 Oct. 2011.
<http://arstechnica.com/civis/viewtopic.php?f=17&t=1139356>.

Blackberry Tips

Blackberry Browser View Source: alt + RBVS
Note: Tested on Blackberry 8800

Blackberry Reboot: alt + right shift + del
Note: Tested on Blackberry Bold 9700. Takes about 5 seconds for the red light to come on. Another 5 seconds for the screen to change.

Microsoft Outlook Tips

Hack to view full folder path of a message found in Search results
Outlook 2010
1) Double click on the message to open it in its own window.
2) Open the Advanced Find feature in message with CTRL+SHIFT+F
3) Click Browse... next to "Look in" folder name.

Source:
Determine the folder path of a message found in Search results - MSOutlook.info. (2013, December 19).
Retrieved February 6, 2015, from http://www.msoutlook.info/question/846

View Source of HTML Email
Outlook 2010
1) Open message
2) Ribbon Message tab/Move section/Actions/Other Actions/View Source

View Internet Headers
Outlook 2010
1) Open message
2) Ribbon File tab/Info section/Properties

Conditional Formatting of Email in Inbox
This allows you to, for example, have email from your manager show up as bold and red; or, show all email addressed specifically to you as green; etc.
Outlook 2010
1) Ribbon View Tab/Current View section/View Settings/Conditional Formatting
2) Add or modify rules

Updates
2012-09-04 Added "Conditional Formatting of Email in Inbox"
2012-09-06 Added "View Internet Headers"
2015-02-06 Added "Hack to view full folder path of a message found in Search results"

IIS 7 Command Line Utility Tips (APPCMD)

To use APPCMD, type this in command prompt
cd %windir%\System32\inetsrv
appcmd /?


Display all applications
appcmd list APP

Display all sites
appcmd list SITE

Display all applications belonging to a site
appcmd list APP /site.name:MySiteName

Find all virtual directories with the specified path
appcmd list VDIR /path:/GlobalControls

Output to XML, then open in Excel for formatted columns
appcmd list vdir /xml > "C:\AppcmdOutput.xml"

Create an IIS Command Prompt Shortcut:
  1. Create new shortcut
  2. Target: %comspec% /k "appcmd /?"
  3. Start in: %windir%\System32\inetsrv

To combine commands, see:
Do complex IIS management tasks easily with AppCmd command piping « Mike Volodarsky's Blog Mike Volodarsky's Blog
http://mvolo.com/do-complex-iis-management-tasks-easily-with-appcmd-command-piping/

References
"Getting Started with AppCmd.exe : Management Tool Options : Planning Your IIS 7 Architecture : The Official Microsoft IIS Site." Learn IIS7 : The Official Microsoft IIS Site. Web. 15 Aug. 2011.
<http://learn.iis.net/page.aspx/114/getting-started-with-appcmdexe/>.
"Appcmd.exe." MSDN – Explore Windows, Web, Cloud, and Windows Phone Software Development. N.p., n.d. Web. 10 May 2012.
<http://msdn.microsoft.com/en-us/library/cc772200(v=ws.10).aspx>.

Could not open a connection to SQL Server in ASP.NET on Windows 7 x64 IIS 7

Problem

While developing an ASP.NET website on a local Windows 7 x64 IIS 7 machine, received the following error:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

However, a connection could be opened using SQL Server Management Studio (SSMS) with the same credentials used by the website.

Solution

Set up server alias in 64-bit version of SQL Native Client Configuration using Sql Server Configuration Manager. The reason that SSMS was working was because it was using the 32-bit aliases set up at an earlier time.

Missing System.Web.Extensions Reference in Windows 7 x64 VS2010

Problem

Unable to compile an ASP.NET 2.0 project in Visual Studio 2010 on Windows 7 x64 that references System.Web.Extensions (ASP.NET AJAX 1.0). The following errors were thrown:

c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3268: The primary reference "MyClass, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the framework assembly "System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "MyClass, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" or retarget your application to a framework version which contains "System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".

c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3267: The primary reference "System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL", which is a framework assembly, could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" or retarget your application to a framework version which contains "System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL".


Solution

1) Installed ASP.NET AJAX 1.0:

Download Details - Microsoft Download Center - ASP.NET AJAX 1.0
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=883

However, could not add a reference to System.Web.Extensions even though it was installed:


2) Had to manually add the following registry entry:

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\ASP.NET AJAX Extensions]
@="C:\\Program Files (x86)\\Microsoft ASP.NET\\ASP.NET 2.0 AJAX Extensions\\v1.0.61025\\"


Could then add a reference to System.Web.Extensions:



References

"MSBUILD 4.0 Fails on AJAX Extensions." Visual Studio 2010 - MSBUILD 4.0 Fails on AJAX Extensions - Stack Overflow. 3 June 2010. Web. 26 July 2011.
<http://stackoverflow.com/questions/2966769/msbuild-4-0-fails-on-ajax-extensions>.

Windows SendTo Folder

Location (Windows 7)
C:\Users\MyUserName\AppData\Roaming\Microsoft\Windows\SendTo
or
%APPDATA%\Microsoft\Windows\SendTo
or
shell:sendto

Location (Windows XP)
C:\Documents and Settings\MyUserName\SendTo
or
%USERPROFILE%\SendTo
or
shell:sendto

Tip to Open SendTo Folder (Windows 7, XP)
1) Create a text file in SendTo folder called "Open SendTo Folder.bat".
2) Add the following line:
start explorer.exe shell:SendTo
3) To quickly open SendTo folder while using the right-click/Send to feature, click on "Open SendTo Folder.bat".

Team Foundation Server Compare Ignore Whitespace

Problem

Need to get TFS Compare to ignore whitespace

Solution

Select menu item Tools/Options/Visual Studio Team Foundation Server.
Click button Configure User Tools...
Click Add
Extension = .*
Operation = Compare
Command = C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\diffmerge.exe
Arguments = %1 %2 %6 %7 %5 /ignorespace

See command line help with:
"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\diffmerge.exe" /?

References

"JB Brown: Whitespace in Team System Compare Results - TeamReview, Visual Studio Team System, and Lean." JB Brown - TeamReview, Visual Studio Team System, and Lean. Web. 21 June 2011.
<http://www.controlstatements.com/2009/03/whitesapce-in-team-system-compare.html>.

"Difference Command." MSDN Explore Desktop, Web, Cloud, and Phone Software Development. Web. 21 June 2011.
<http://msdn.microsoft.com/en-us/library/6fd7dc73(VS.80).aspx>.

How to Install Microsoft Free Virus Software

  1. Download Microsoft Security Essentials installation file to your desktop
    Virus, Spyware & Malware Protection | Microsoft Security Essentials
    http://www.microsoft.com/en-us/security_essentials/default.aspx
  2. Disconnect from the internet because you will be unprotected for a few minutes. Unplug from the cable modem, etc.
  3. Uninstall virus/security software that is currently on your computer.
    If you need help figuring out how to uninstall, connect back up to the internet, go to this page and print it off, then disonnect again:
    How do I uninstall antivirus or antispyware programs?
    http://www.microsoft.com/en-us/security_essentials/Support/4cae1455-6ead-493c-b5d8-7c88f39c0656.aspx
  4. Install Microsoft Security Essentials from your desktop installation file.
  5. Make sure Windows firewall is turned on in case the old security software included a firewall.
    Understanding Windows Firewall settings
    http://windows.microsoft.com/en-US/windows7/Understanding-Windows-Firewall-settings
  6. Reconnect to the internet and allow Microsoft Security Essentials to update itself.

SQL Concatenate Row Data into Variable

Problem

Need to generate a comma-delimited string list from data contained in rows of table

Solution

DECLARE @commaDelimitedList varchar(8000)
SET @commaDelimitedList = '' -- Must set to empty value

SELECT @commaDelimitedList = @commaDelimitedList + [MyColumn] + ','
FROM [MyTable]

-- Remove trailing comma from list
IF (@commaDelimitedList <> '')
BEGIN
      SET @commaDelimitedList = LEFT(@commaDelimitedList, LEN(@commaDelimitedList) - 1)
END

-- Return record set
SELECT @commaDelimitedList AS 'CommaDelimitedList'

Debug Console Application When Started Outside of Visual Studio

Problem

Need to be able to debug a console application when the executable is started outside of Visual Studio. When doing this with a web application, you attach to process aspnet_wp.exe. This will not work with a console application.

Solution

Manually start debugger inside console application. Temporarily add the following line to the console application code:

System.Diagnostics.Debugger.Launch();

Running the console application executable will cause a prompt from Visual Studio Just-In-Time Debugger. At that time you may select Visual Studio from list of Possible Debuggers.

Option Strict On disallows late binding

Problem

When setting Option Strict On in Visual Studio macro, the following code examples:

Dim toolbar As Microsoft.VisualStudio.CommandBars.CommandBar
toolbar = DTE.CommandBars.Item("MyToolbarName")
DTE.ActiveDocument.Selection.NewLine()


Causes the error:

Option Strict On disallows late binding.

Solution

Use CType Function to explicitly convert an expression to a specified object like the following examples:

toolbar = CType(DTE.Commands.Item("MyToolbarName"), Microsoft.VisualStudio.CommandBars.CommandBar)
Dim activeDocument As Document = CType(DTE.ActiveDocument, Document)
Dim activeSelection As TextSelection = CType(DTE.ActiveDocument.Selection, TextSelection)

Windows XP Hangs Viewing Shortcuts

Problem
Windows hangs when opening or trying to view properties of shortcuts to network files that do not exist.

Note: This solution has been tested and works with Windows XP and Windows 7.

Solution
Prevent Windows from conducting a comprehensive search of the target drive in an attempt to find the file.
  1. Run gpedit.msc
  2. Select User Configuration / Administrative Templates / Start Menu and Taskbar
  3. Enable "Do not use the search-based method when resolving shell shortcuts"
References
"Windows XP Hangs When You Open a Folder That Contains a Network Shortc." PC Pitstop Forums. Web. 04 Mar. 2011.
<http://forums.pcpitstop.com/index.php?/topic/121312-windows-xp-hangs-when-you-open-a-folder-that-contains-a-network-shortc/>.
"Policy Settings for the Start Menu in Windows XP." Microsoft Support. Web. 04 Mar. 2011.
<http://support.microsoft.com/kb/292504>.
"Do Not Use the Search-based Method When Resolving Shell Shortcuts." Microsoft TechNet: Resources for IT Professionals. Web. 04 Mar. 2011.
<http://technet.microsoft.com/en-us/library/cc939469.aspx>.

Updates
2011-10-20 Added note that this works with XP and Win7.