SQL Profiler doubleclick does not open .trc files any more

SQL Profiler doubleclick does not open .trc files any more

Rate This
  • Comments 1

Whenever I double-click on a profiler trace *.trc file I get the error

image

Unrecognized command line argument. All command line arguments will be ignored. ..Please run 'profiler.exe -?' to see a list of valid command line arguments.

I suspect this happened when I installed a component of Visual Studio called the ATL Trace Tool, which messed up my associations somehow.

 

To prove what’s going on, I used my favorite debugger WinDbg.exe to see what parameters were being passed into the process.

!peb is sufficient to show the parameters as follows:

CommandLine:  '"C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\PROFILER.EXE" "G:\files\SPID00128.TRC"'

Hmm, it didn’t put any switches in the command line. I read from Profiler.exe help with switch -? that the valid switches for passing a file name is –f or –F

Let’s try to fix this. Find a profiler .trc file and right click to bring up the Open With context menu…

 

image

 

Reset the default program to open the .trc file back to SQL Server profiler.

image

Voila! Now when I doubleclick a .trc it works.

To prove that it changes somethings after it worked, I attached the debugger, and did !peb this time.

By re-associating the file, the /f is added back into the command line parameters.

CommandLine:  '"C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\profiler.exe" /f"G:\files\SPID00128.TRC"'

 

This can be seen from the default associations as well… in Windows 7

Control Panel > Programs >Default Programs > Set Associations

Updates:

If you like more control than what Windows shows, there is a handy tool from this link which can give a richer experience to edit program associations in Windows 7. http://defaultprogramseditor.com/

Underneath the Win 7 covers I see this selection sets two registry keys

 1. The choice to associate a .trc file extension to sql profiler should live in this reg key (Start > run > regedit)


HKEY_USERS\<your sid>\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.trc

There are 3 subkeys there:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.trc\OpenWithList

a = REG_SZ = PROFILER.exe

MRUList = REG_SZ = a

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.trc\OpenWithProgids

SQLServerProfilerTraceData = REG_NONE

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.trc\UserChoice

Progid = REG_SZ = SQLServerProfilerTraceData

  2. Then profiler has a default OPEN action - it knows how to open the file because the file name is passed as an argument - %1 with quotes (in case there are spaces in the current file name's path.

HKEY_CLASSES_ROOT\Applications\PROFILER.EXE\shell\open\command

(default) = "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\PROFILER.EXE" "%1"

Leave a Comment
  • Please add 1 and 1 and type the answer here:
  • Post
  • For me, with SQL 2008 R2, the HKEY_CLASSES_ROOT\Applications\PROFILER.EXE\shell\open\command was actually at:

    HKEY_CLASSES_ROOT\SQLServerProfilerTraceData\shell\open\command

    And to get it to work it needed setting to:

    "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\profiler.exe" /f"%1"

    The /f had somehow gotten removed. Adding it back manually resolved the issue.

Page 1 of 1 (1 items)