A personal repository of technical notes. - CSC

Windows Explorer Command-Line Options for Windows XP

BAT file code
@echo off
start %SystemRoot%\explorer.exe /n,/root, "C:\MyFolder"


References
"Explorer.exe Command-Line Options for Windows XP." Microsoft Support. Web. 24 Dec. 2009. <http://support.microsoft.com/kb/314853>.

The options that you can use with Explorer.exe are /n, /e, /root (plus an object), and /select (plus an object).

Option            Function
----------------------------------------------------------------------
/n Opens a new single-pane window for the default
selection. This is usually the root of the drive that
Windows is installed on. If the window is already
open, a duplicate opens.

/e Opens Windows Explorer in its default view.

/root,<object> Opens a window view of the specified object.

/select,<object> Opens a window view with the specified folder, file,
or program selected.

CSS Nested Lists

  

<ol style="list-style-type: decimal;">

<li>aaa

<ol style="list-style-type: lower-alpha;">

<li>aaa</li>

<li>bbb

<ol style="list-style-type: lower-roman;">

<li>aaa</li>

<li>bbb</li>

<li>ccc</li>

</ol>

</li>

<li>ccc</li>

</ol>

</li>

<li>bbb</li>

<li>ccc</li>

</ol>

  1. aaa
    1. aaa
    2. bbb
      1. aaa
      2. bbb
      3. ccc
    3. ccc
  2. bbb
  3. ccc

How to Debug JavaScript

Problem
Debugging JavaScript in Firefox
Debugging JavaScript in IE

Solution for Debugging JavaScript in Firefox

Firebug Method:
  1. Open page to debug in Firefox
  2. Start Firebug
  3. Click on the "Script" tab on top of Firebug pane
  4. Assign break points and step through code as you would with VS2005
Solution for Debugging JavaScript in IE6

Debugger line method:
  1. IE: Tools/Internet Options/Advanced Tab/Uncheck "Disable Script Debugging"
  2. VS: Add following line to JavaScript code:
    debugger;
  3. Add breakpoint to line above
  4. Remove line above after debugging complete
VS2005 Attach to Process Method:
  1. IE: Tools/Internet Options/Advanced Tab/Uncheck "Disable Script Debugging"
  2. VS: Solution Explorer/Right-Click .ASPX/View in Browser
  3. VS: Debug/Attach to Process...
    1. Attach to: Click Select.../Check Script
    2. Available Processes/Select iexplore.exe of .ASPX
    3. Click Attach
  4. VS: Debug/Windows/Script Explorer
  5. VS Script Explorer: Double-Click page to open scipt for setting break points

Visual Studio Documentation Comments for C#

Tip
Include XML Documentation Comments in C# code:

<c>
<code>
<example>
<exception>
<include>
<list>
<para>
<param>
<paramref>
<permission>
<remarks>
<returns>
<see>
<seealso>
<summary>
<typeparam>
<typeparamref>
<value>

References
"Recommended Tags for Documentation Comments (C#)." MSDN: Microsoft Development, MSDN Subscriptions, Resources, and More. Web. 02 Dec. 2009.
<http://msdn.microsoft.com/en-us/library/5ast78ax%28VS.80,loband%29.aspx>.

SQL Server Management Studio Default My Projects Location

Problem
Need to change default location of My Projects folder in SSMS

Solution for SSMS 2008
Had to add a new registry entry "VisualStudioProjectsLocation" of type "Expandable String Value" (REG_EXPAND_SZ) at
HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server\100\Tools\Shell

Solution That Worked for SSMS 2005
Modify registry entry "VisualStudioProjectsLocation" at
HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server\90\Tools\Shell

References for Solution That Worked for SSMS 2005
"How to change the default ‘My Projects’ location in SQL Server Management Studio «." Pepper's Perspective. Web. 15 Sept. 2009. <http://p3john.wordpress.com/2009/08/11/how-to-change-the-default-my-projects-location-in-sql-server-management-studio/>.


Solution That Did Not Work for SSMS 2005
This solution did not work for me. After saving vssettings file, SSMS regenerated the settings file with the old values on the next start after displaying message "Microsoft SQL Server Management Studio is configuring the environment for first time use. This might take a few minutes."

Manually modify SSMS *.vssettings XML file at location:
\My Documents\SQL Server Management Studio\Settings\

See entry:
<PropertyValue name="ProjectsLocation">%vsspv_visualstudio_dir%\Projects</PropertyValue>
References for Solution That Did Not Work for SSMS 2005
"Changing the My Projects folder location (and other settings) in SSMS :." Visual Studio Hacks. Web. 15 Sept. 2009.
<http://visualstudiohacks.com/tips/options/changing-the-my-projects-folder-location-and-other-settings-in-ssms/>.

Updates
2011-07-05 Added SSMS 2008 references.

INSERT failed because the following SET options have incorrect settings: 'ARITHABORT'.

Problem

Received the following error while performing CREATE Procedure from Visual Studio 2005 after setting up a DDL trigger for database auditing in a SQL Server 2005 database.
INSERT failed because the following SET options have incorrect settings: 'ARITHABORT'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or query notifications and/or xml data type methods.

Solution 1

Added the following line to the DDL auditing database trigger:

SET ARITHABORT ON


Solution 1 References

"Database DDL trigger." Community Bookmarks - MSDN. Web. 19 Aug. 2009.
http://social.msdn.microsoft.com/Forums/en-US/sqlreplication/thread/8333dc82-7390-4145-8081-74d9330938dd.

"SET ARITHABORT (Transact-SQL)." MSDN: Microsoft Development, MSDN Subscriptions, Resources, and More. Web. 19 Aug. 2009.
http://msdn.microsoft.com/en-us/library/ms190306%28SQL.90%29.aspx.

"Behavior When ARITHABORT and ARITHIGNORE Are Set to ON." MSDN: Microsoft Development, MSDN Subscriptions, Resources, and More. Web. 19 Aug. 2009.
http://msdn.microsoft.com/en-us/library/ms189118%28SQL.90%29.aspx.


Solution 2

Found that the database that was throwing the error was configured to be compatible with an older version of SQL Server. Setting the database to be compatible with SQL Server 2005 also corrected the problem.

Solutin 2 References

"Reorg failing - SELECT failed because the following SET options have incorrect settings: 'ARITHABORT'" Community Bookmarks - MSDN. Web. 17 Aug. 2009.
http://social.msdn.microsoft.com/Forums/en-US/sqldatabaseengine/thread/41bf9b3a-ee25-4dde-bf6f-ab1a8d59ea6b.

"Sp_dbcmptlevel (Transact-SQL)." MSDN: Microsoft Development, MSDN Subscriptions, Resources, and More. Web. 17 Aug. 2009.
http://msdn.microsoft.com/en-us/library/ms178653(SQL.90).aspx.

Disable Try Catch Block During Debugging

Problem
Would like to see full errors during debugging process without having to comment out try-catch blocks.

Solution
Note: This was tested in VS2005, VS2013.
Set Visual Studio to always break when an exception is thrown during debug.
  1. Select menu Debug/Exceptions...
  2. Check the box labeled "Thrown" next to "Common Language Runtime Exceptions".
References
"Exception Handling (Debugging)." MSDN: Microsoft Development, MSDN Subscriptions, Resources, and More. Web. 31 July 2009. http://msdn.microsoft.com/en-us/library/x85tt0dd(VS.80).aspx.

"How to: Break When an Exception is Thrown." MSDN: Microsoft Development, MSDN Subscriptions, Resources, and More. Web. 31 July 2009. http://msdn.microsoft.com/en-us/library/d14azbfh(VS.80).aspx.

Updates
2014-09-18 Confirmed works in VS2013.

Copy Formatted Source Code Into Blog Entry

Problem
Need to be able to display copied source code from editing tools with original formatting in a blog entry.

Solution
Use a combination of Microsoft Word and manual editing to generate the necessary markup.

Note: These steps were tested with blogspot.com and Word 2010.
  • Copy code to clipboard from editor such as Visual Studio, MS SQL Server Management Studio query, etc.
  • Paste into Word.
  • Replace all < with &lt;
  • Replace all > with &gt;
  • Copy code from Word.
  • Paste into blog post in "Compose" mode.
  • Publish.

Note: These steps were tested with blogspot.com and Word 2003.
  • Copy code to clipboard from editor such as Visual Studio, MS SQL Server Management Studio query, etc.
  • Paste into Word.
  • Replace all < with &lt;
  • Replace all > with &gt;
  • Copy code from Word.
  • Paste into blog post in "Compose" mode.
  • Switch to "Edit Html" mode.
  • Copy entire content from blog post.
  • Paste into text editor.
  • Delete all content before the first "<style>" tag.
  • Replace all occurrences of "</p>  <p" with "</p><p".
  • Put tag at beginning: "<pre>".
  • Put tag at end: "</pre>".
  • Copy code from text editor.
  • Paste into blog post in "Edit Html" mode.
  • Publish.

Type Exists in Both DLLs

Problem
Have two versions of a DLL that use the same namespaces and class names.

Project compliation throws the following error:

The type 'MyNamespace.MyClass' exists in both 'MyDLLv1.dll' and 'MyDLLv2.dll'
error CS0433: The type 'MyNamespace.MyClass' exists in both 'MyDLLv1.dll' and 'MyDLLv2.dll'


Solution
Use an external assembly alias.
  1. Specify "Aliases" property of DLL reference.
    1. In Visual Studio Solution Explorer, open References folder.
    2. Right-click DLL reference, select Properties
    3. Enter alias value in "Aliases" property.
    4. Example: Alias to MyDLLv1.dll reference could be "LegacyMyDLL".
  2. Specify alias in C# source code:

// Old way

using MyNamespace;

// New way

extern alias LegacyMyDLL;

using LegacyMyDLL.MyNamespace;

Microsoft References
Note: Could find no Microsoft references for specifying "Aliases" property of DLL reference within Visual Studio. Only for specifying compilation command line parameter.

"/reference (Import Metadata) (C#)." MSDN: Microsoft Development, MSDN Subscriptions, Resources, and More. 22 July 2009 http://msdn.microsoft.com/en-us/library/yabyz3h4(VS.80).aspx.

"Extern alias (C#)." MSDN: Microsoft Development, MSDN Subscriptions, Resources, and More. 22 July 2009 http://msdn.microsoft.com/en-us/library/ms173212(VS.80).aspx.

"How to: Use the Namespace Alias Qualifier (C#)." MSDN: Microsoft Development, MSDN Subscriptions, Resources, and More. 22 July 2009 http://msdn.microsoft.com/en-us/library/c3ay4x3d(VS.80).aspx.

Other References
"What use is the Aliases property of assembly references in Visual Studio 8. -." Stack Overflow. 22 July 2009 http://stackoverflow.com/questions/286632/what-use-is-the-aliases-property-of-assembly-references-in-visual-studio-8.

"Enhancements in Assemblies and Versioning in Visual Studio 2005." C#, Visual Studio 2008, Silverlight, ASP.NET, WPF, WCF, WF, and Windows Vista Community. 22 July 2009 http://www.c-sharpcorner.com/UploadFile/rambab/Assembly04292006002740AM/Assembly.aspx?ArticleID=69edb807-8118-4933-8366-773e87ee80ad.

Windows Command Line Tips

Command to determine location of program in command prompt
Description from where /?
Displays the location of files that match the search pattern.
By default, the search is done along the current directory and
in the paths specified by the PATH environment variable.

Example:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64
> where ildasm
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\ildasm.exe


Copy command output to clipboard
dir | clip

Delete all folders within a folder (Windows XP)
FOR /D %f IN ("C:\MyFolderWithOtherFolders\*.*") DO RMDIR /S /Q "%f"

Delete all folders within a folder (Windows 7, Windows Server 2008, Windows Vista)
forfiles /s /p "C:\MyTestFolder" /c "cmd /c if @ISDIR==TRUE RMDIR /S /Q @PATH"

Forfiles
This is a utility for selecting files and executing a command on them. Applies To: Windows 7, Windows Server 2008, Windows Vista.

Examples:

Display all subfolders
forfiles /s /p "C:\MyTestFolder" /c "cmd /c if @ISDIR==TRUE echo @PATH @ISDIR"

Delete all files older than 30 days:
forfiles /p "C:\MyFolderWithFiles\" /s /m *.* /d -30 /c "cmd /c del @path"

See "Forfiles." Resources and Tools for IT Professionals | TechNet. N.p., n.d. Web. 8 Oct. 2012. <http://technet.microsoft.com/en-us/library/cc753551(v=ws.10).aspx>.

Open IIS Manager at a command prompt
  1. On the Start menu, click Run.
  2. In the Open dialog box, type inetmgr, and then click OK.
See
"How To: Open IIS Manager." MSDN | Microsoft Development, Subscriptions, Resources, and More. Web. 14 July 2010. <http://msdn.microsoft.com/en-us/library/bb763170.aspx>.

Commands to Display/Remove Read-Only Attributes
REM Displays files with read-only attributes set in specified directory and all subdirectories.
dir /ar /s

REM Clears the read-only file attribute from matching files in the current folder and all subfolders.
attrib -r /s


Command Line to Lock Computer (Windows 7, XP)
rundll32.exe user32.dll, LockWorkStation

Updates
2015-02-13 Added "Command to determine location of program in command prompt"
2013-08-02 Added "Copy command output to clipboard"
2012-10-08 Added "Forfiles"
2011-08-25 Added "Delete all folders within a folder"
2011-03-04 Added "Command Line to Lock Computer"