General_Windows

This page is a collection of developer and configuration issues for any kind of Windows development in question and answer format that does not better fit in any of the other pages.  Nearly all of these tips are for user-mode code or programs.  Other than this, they may apply to the Win32 API, C#, scripting languages - anything on Windows.

Contents

  1. 1 Q:  Marking a code segment in user mode as non-pageable does not work:  when the process loads, the segment is neither locked nor allocated from the non-paged pool.  How do I fix this?
  2. 2 Q:  I can't capture the contents of a Internet Explorer 9 window or a DirectX window using the tried-and-true GDI method of copying the window contents using it's DC - I just get a black hole where the window contents should be.  How do I fix this?
  3. 3 Q:  Outlook crashes when reading a message all of the sudden.  How do I fix this?
  4. 4 Q:  How do I increase the VMWare BIOS boot screen delay so I can get into it?
  5. 5 Q:  How do I give a VMWare VM a static MAC address?
  6. 6 Q:  I installed VMWare on Windows 7, but host only networking isn't working.  VMNet1 on my host shows with a 169 IP, although it's configured to use a static IP, and so I can't ping the host or vice-versa.  Firewall is off.  Why can't I communicate via IP?
  7. 7 Q:  I installed GT Suite on a Windows 7 machine, but it fails the self-test with "Generating combined dat file - Access Denied."
  8. 8 Q:  In MATLAB, when I open a Simulink MDL file I get the error "Error using ==> open - <filename> is an invalid model name or the file <filename> does not exist".  The file exists and works elsewhere.
  9. 9 Q:  In MATLAB, I get the error "Unable to open model file - ??? Error using ==> sim - Unable to load block diagram 'EngineController.mdl'"
  10. 10 Q:  Where can I find documentation on the MATLAB file format?
  11. 11 Q:  How do I install MATLAB 14 on Windows 7?
  12. 12 Q:  When I uninstall MATLAB 14 on Windows 7, I get "Bummer - Uninstaller Error! - Exception calling main."
  13. 13 Q:  When I open a MATLAB MDL file, I get the error "Warning:  Unable to open model file '<filename>'", but the right file is in the same directory and GT Suite is installed and licensed.  In the model, my GT node shows as red with the error "Bad Link."  If I try too run the simulation, I get many warnings and the error "Failed to find the library 'gtlink70'..."
  14. 14 Q:  I get "Specified GT data file does not exist in the working folder" when running my MATLAB simulation embedding a GT Suite file.  The filename is correct and the file exists in the right directory.
  15. 15 Q:  In the GT Suite Simulink Coupling tutorial, where do I find the SensorCon and ActuatorCon parts?
  16. 16 Q:  In the GT Suite Simulink Coupling tutorial, how do I create a link between parts?
  17. 17 Q:  In the GT Suite Simulink Coupling tutorial, how do I create the SimulinkHarness object?  I can't drag and drop.
  18. 18 Q:  In the GT Suite Simulink Coupling tutorial, I can't find the menu option "Create .dat file"
  19. 19 Q:  In the GT Suite Simulink Coupling tutorial, where did the .sim file come from?
  20. 20 Q:  How do I create a SimuLink simulation?
  21. 21 Q:  Where are the parts for the MATLAB simulink_model in the Simulink library?
  22. 22 Q:  Are some MATLAB model filenames invalid?
  23. 23 Q:  I copied an MDL with supporting DAT to another directory and when I open them I get the error "Specified GT data file does not exist in the working folder"
  24. 24 Q:  What are the GTI file types?
  25. 25 Q:  How do I create the Simlink MDL file used in the SimulinkCoupling tutorial?
  26. 26 Q:  How do I setup Visual Studio remote debugging?
  27. 27 Q:  In Process Explorer, I can't see the Path, Command line, or current directory for the app I'm inspecting.  Why?
  28. 28 Q:  My Access 2007 Autonumber field is recycling previous values.  Why?
  29. 29 Q:  How do I reset a Jet/Access AutoNumber field?
  30. 30 Q:  I'm getting an "Error using ==> open '<filename>' is an invalid model name or the file" from MATLAB when opening a Simulink MDL, but the file exactly matches one that works.
  31. 31 Q:  My application fails to start on Vista+ with "A referral was returned from the server"  How do I fix this?
  32. 32 Q:  MATLAB rejects my Simulink file with an error, but the gti_fname file specified exists and is in the working directory.  Why won't it work?  The error is:
  33. 33 Q:  Depends fails on Windows Vista or higher with a complaint about a missing IViewers.dll, but it is there.
  34. 34 Q:  How can I make an action in a MSBUILD XML script conditional?
  35. 35 Q:  How do I programmatically check if Windows is activated?
  36. 36 Q:  How do I make the C++ runtime use the user's current Windows locale?
  37. 37 Q:  Visual Studio 2005 will not let me set a breakpoint in C++ code, but I know the symbols are correct.  Why?
  38. 38 Q:  How do I remove a guideline I've added using the Visual Studio 2010 Productivity Power Tools?
  39. 39 Q:  In Visual Studio, how do I set a breakpoint on a Windows API call?
  40. 40 Q:  How do I resolve problems when my manifest has multiple references to the same assembly as different versions?  For example, Microsoft.VC80.CRT at 50727.762 and 50608.0.
  41. 41 Q:  I installed NuGet in Visual Studio 2010, but don't get any packages listed.  When I go to Tools|Library Package Manager|Manage NuGet Packages for Solution... and select Online|NuGet official package source, I get the error "Could not load file or dependency 'TTVSAddinDotNet.resources.module' or one of it's dependencies.  The system cannot find the file specified.
  42. 42 Q:  How can I view a multi-line string in Visual Studio, without having to use NotePad or some other text editor?
  43. 43 Q:  How do I fix the date/time in a VMWare Workstation VM so it does not change?
  44. 44 Q:  Visual Studio 2010 refuses to add a reference to a type library with the error "This file may not be a managed assembly", but it is a valid TLB.  How do I add it?
  45. 45 Q:  Why won't Visual Studio 2010 step through the NET framework source?  I have everything configured correctly.
  46. 46 Q:  How do I disable the background image on a Windows 7 Starter netbook?
  47. 47 Q:  In Visual Studio 2010, how do I jump to a matching brace?
  48. 48 Q:  In Visual Studio 2010, how do I embed a resource in only one build configuration?
  49. 49 Q:  How do I determine the help topic ID number that a program is displaying when I hit help?
  50. 50 Q:  I can't some kind of fields in a Word 2010 document.  I get the error message "protected content".  How do I delete this text?
  51. 51 Q:  If I use Google Chrome to search and click a social.msdn.com link, the response is slow and I ultimately get a "Something went wrong" error.  However, I can view the results in Internet Explorer.
  52. 52 Q:  When using the Surround SCM command line to checkin a file, I get the error "Unable to find mainline  with branch ."
  53. 53 Q:  The monitor on my nVidia card has suddenly switched to greyscale.  How do I get the color back?
  54. 54 Q:  While debugging code in Visual Studio 2012, I get an error "Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information."
  55. 55 Q:  I get the error "Invalid argument or procedure call" when scripting the VMWare VIX API in a .vbs script run by the Windows Scripting Engine (wscript/cscript), but the code matches the VMWare example.
  56. 56 Q:  In Visual Studio 2012/2013, how do I order an item configured with Custom Build Tool so it is done before compilation or the resource compiler?  The Execute Before box is greyed out.
  57. 57 Q:  In Visual Studio 2010/2012/2013/higher when debugging a 32-bit DLL run using rundll32, Visual Studio reports the error "The breakpoint failed to bind."  How do I fix this?
  58. 58 Q:  How can you XPath query XML data that uses namespaces?
  59. 59 Q:  I can't login to GitHub for Windows with the error "Unable to retrieve your user info from the server."  However, I can login to https://www.github.com.
  60. 60 Q: I can't install NET 3.5 on Server 2012. I get the error "One or more installation selections are missing source files..."
  61. 61 Q:  Server 2003 reports a specific certificate as invalid, stating: The integrity of this certificate cannot be guaranteed.  The certificate may be corrupted or may have been altered."  However, any operating system Windows Vista or above recognizes the certificate as valid.  How do I fix this?
  62. 62 Q: I published a Computer certificate template, but cannot see it in the Certificates snap-in when I use Request New Certificate.  Why?
  63. 63 Q:  The Certificate Service caps the validity period of any cert I make at 2 years even though the request asks for a longer period.  The root CA is valid longer than 2 years.  How do I fix this?
  64. 64 Q:  JavaScript single-stepping and debugging is very slow in Internet Explorer.  It takes 3-10 seconds between pressing <F10> and the step.  How do I fix this?
  65. 65 Q:  How do I get the serial number of a Yubikey?
  66. 66 Q: How do I use an environmental variable in Visual Studio 2010, 2012, 2013 for Start External Program?
  67. 67 Q: In PowerShell, I get the error "cannot be loaded because the execution of scripts is disabled on this system" How do I fix this?
  68. 68 Q:  How do I run Hyper-V (in Windows Server) in a VM under VMWare Workstation 10+?
  69. 69 Q:  I get the error "linked to missing export" with my function template, declared in a header and defined in a CPP.
  70. 70 Q: How do I set the binding order of network adapters on a multi-homed Server 2012 computer?
  71. 71 Q:  How do I enable copy/paste with a VMWare Server/vSphere VM?
  72. 72 Q:  Is there a WMI browser or test utility built into Windows?
  73. 73 Q:  In Visual Studio 2012, the Solution Configuration box in the toolbar is too small, cutting off the text.  How do I make it wider?
  74. 74 Q: In Visual C++ 2012, I get C4995s reported as errors instead of warnings and cannot build. How do I fix this?
  75. 75 Q:  How do I Url Escape/Encode in C++?
  76. 76 Q:  In C#, I can't write to a file whose handle is stored via SafeFileHandle using native APIs during a finalizer.  The handle appears to already be closed.  Why?
  77. 77 Q:  When installing Exchange 2013 on Server 2012, I get the error "Unsupported Operating System", but 2012 is clearly supported.  Why?
  78. 78 Q:  I can't get Exchange 2013 install, it fails for various reasons.
  79. 79 Q: How do I use the GITHUB GIT from a command line on a Windows machine connecting to an SSH GIT repository?
  80. 80 Q:  Visual Studio or MSBUILD never end after running a batch file that runs and exits fine at command line.  How do I fix this?
  81. 81 Q:  Chrome on Windows hangs when I minimize, then restore when using it with multiple monitors between display changes.  How do I fix this?
  82. 82 Q:  What is the easiest way to test ADFS to verify it is working?
  83. 83 Q:  In Windows 10, how do I get the F8 Startup Options menu to display?
  84. 84 Q:  How do I set a breakpoint in DllMain when I am not sure where the function is defined?
  85. 85 Q:  How do I save a list of all trusted certs for the machine and current user to a file?
  86. 86 Q:  Why does a _COM_SMARTPTR_TYPEDEF-defined smart pointer throw on Release if it has no pointer?
  87. 87 Q:  Does the Exchange team use exceptions in C++?
  88. 88 Q:  How do I get the boot menu options to display at boot-up on Windows 8 on demand?
  89. 89 Q:  When I try to copy a 64-bit file from a Visual Studio post-build command, I get the 32-bit version instead.  How do I fix this?
  90. 90 Q:  When I reference the ProgramFiles(x86) variable in a batch file, I get a "file specified was not found" error.  How do I fix this?
  91. 91 Q:  Using ATL implementing an interface #import'd from a TLB, I get the errors static_cast' : cannot convert from '[Class]::_ComMapClass *' to '[Interface*]', followed by "cannot convert from 'ATL::_ATL_CREATORARGFUNC (__cdecl *)' to 'DWORD_PTR'".  How do I fix this?
  92. 92 Q:  When I use the Resource Editor in Visual Studio, it changes the macros in my RC file to their literal equivalents and reports an error about __useHeader redefined.  How do I fix this?
  93. 93 Q:  Exchange 2013 refuses to start, citing an error mounting it's database.  How do I fix this?
  94. 94 Q: How do I get a static activation key for Visual Studio 2015?
  95. 95 Q: I edited a web page with TextPad and now the raw source is returned. How do I fix this?
  96. 96 Q:  SmartGIt is fails to retrieve the SimpleSaml repository with "Could not read from remote repository", but it used to work.  I am connected to the VPN.  How do I fix this?
  97. 97 Q:  Exchange 2013 is generating huge logs in C:\Program Files\Microsoft\Exchange Server\V15\Logging\Monitoring\Monitoring\ActiveMonitoringTraceLogs. How do I stop this?
  98. 98 Q:  How do I debug a Windows Credential Provider?
  99. 99 Q:  Is it OK to use .NET to implement a credential provider or other Windows core security plug-in?


Q:  Marking a code segment in user mode as non-pageable does not work:  when the process loads, the segment is neither locked nor allocated from the non-paged pool.  How do I fix this?

A:  The Windows user-mode program loader does not honor this attribute as it is intended for use in kernel mode.  To accomplish the same effect once the program is loaded, you must manually mark a memory region as locked by doing the following:
  1. Determine the starting address and size of the regions to make non-paged.  In user mode, this is called working set locked.
  2. Total the size above.
  3. If on a 32-bit system, you must call AdjustTokenPrivileges to enable SeLockMemoryPrivilege, and the system must have AWE extensions enabled.  Neither are necessary on Win64.
  4. Call SetProcessWorkingSet with the total from step 2 plus some additional buffer to ensure other key areas - such as the stack guard page - are included.  If this step is skipped, VirtualAlloc will fail with error code 1453 (0x5ad) or ERROR_WORKING_SET_QUOTA:  Insufficient quota to complete the requested service.
  5. Call VirtualLock on the region(s) to lock.
The only commonly available tool that can report this locked user-mode memory is SysInternals VM Map!  Task Manager and Process Explorer WILL NOT REPORT the locked pages!  Both can display nonpaged memory, but these values show a process's consumption of the kernel-mode nonpaged pool.  The user mode locked allocations are not backed by memory from this pool.  Consequently, neither Task Manager nor Process Explorer will report them.  To verify the locked status of the memory, run VMMap and checked the Locked WS column, for Locked Working Set.  Note also that the SysInternals tool RAM MAP is unable to distinguish locked user-mode pages from any other pages.

Q:  I can't capture the contents of a Internet Explorer 9 window or a DirectX window using the tried-and-true GDI method of copying the window contents using it's DC - I just get a black hole where the window contents should be.  How do I fix this?

A:  It may be impossible except on Windows 7.  For any DirectX-based app, which now includes IE9, GDI is not aware of the windows contents.  DirectX essentially cuts a hole out of the GDI surface and owns that part of the screen.  If the window is visible, you can use the DirectX APIs to copy the front-buffer of the display surface and then extract the window contents from that screenshot.  If the window is not visible, you're stuck, except on Windows 7.  On Windows 7, it should be possible to get the contents using the new Desktop Window Manager.  See this link for more information and sample code in C#, dependent on the SlimDX library on CodePlex. Other useful notes:

Q:  Outlook crashes when reading a message all of the sudden.  How do I fix this?

A:  There are many causes.  Trying running outlook in safe mode, with /safe.  If this doesn't work, try restarting the print manager.  If this works, it's a printer driver issue, although the issue could be with any installed printer driver.  First, check for any trial printer drivers that may have timed out and remove them.  Next, do the following to resolve this on Windows 7:
  1. Go to Control Panel|Administrative Tools|Print Management
  2. Click All Drivers
  3. Select all listed drivers
  4. Right click and select Set Driver Isolation|Isolated.
For more possible solutions, see the Microsoft Outlook problem reference at http://support.microsoft.com/kb/2652320.

Q:  How do I increase the VMWare BIOS boot screen delay so I can get into it?

A:  Do the following:
1.  Shutdown the VM, and if it is displayed in the VMWare GUI, close it.
2.  Open the VMX file in the VM's directory
3.  Add the following line:
        bios.bootdelay = 20000
4.  Save and restart the VM.  You should now have a 20 second delay at the BIOS screen.

Q:  How do I give a VMWare VM a static MAC address?

A:  The steps in the VMWare user's manual are incorrect, but close.  Follow these steps:
1.  Close the VM.  Otherwise, the file may be locked or your changes could be overwritten.
2.  Open the VMX file in a text editor
3.  Find and delete the following entries for the ethernet device you want to change.  Replace N with the device #:
    ethernet<N>.generatedAddress
    ethernet<N>.generatedAddressOffset
4.  Change the ethernet<N>.addressType entry to static, so the line looks like:
        ethernet<N>.addressType = "static"
5.  Add a fixed MAC address using the format shown below.  XX, YY, and ZZ must be hex values.  XX must be <= 3F.
        ethernet0.address = "00:50:56:<XX>:<YY>:<ZZ>"

Q:  I installed VMWare on Windows 7, but host only networking isn't working.  VMNet1 on my host shows with a 169 IP, although it's configured to use a static IP, and so I can't ping the host or vice-versa.  Firewall is off.  Why can't I communicate via IP?

A:  Edit the properties for the VMNet7 connection and set a default gateway using the physical machine's IP in VMNet1.  Windows 7 has categorized the VMNet1 connection as undefined, making it unreachable.  VMWare unintentionally causes this by not setting a default gateway.  This can also be caused if the connection is configured to use DHCP, but there is no DHCP server currently.

Q:  I installed GT Suite on a Windows 7 machine, but it fails the self-test with "Generating combined dat file - Access Denied."

A:  Run GT Suite as admin.  GTI tries to open it's example file GTI\v7.1.0\examples\RunMeFirst.gtm for GENERIC_WRITE, but since GT isn't elevated and the file is under Program Files, the open fails.  When run as admin, GT doesn't actually modify the file.

Q:  In MATLAB, when I open a Simulink MDL file I get the error "Error using ==> open - <filename> is an invalid model name or the file <filename> does not exist".  The file exists and works elsewhere.

A:  Do one of the following:
1.  Change the directory shown in the MATLAB Current Directory window to be the directory your file is in
2.  Add the directory to MATLAB's search path by entering path(path, '<directory path>') at the MATLAB prompt, then run it by entering sim('file node name and ext>') at the MATLAB command prompt.

Q:  In MATLAB, I get the error "Unable to open model file - ??? Error using ==> sim - Unable to load block diagram 'EngineController.mdl'"

A:  The file format is invalid for this version of MATLAB.  There are three causes:
1.  0-byte file
2.  Newer file with old MATLAB.  Reference point is Simulink 6.6/R2007a and newer.
3.  Older file with new MATLAB.  Reference point is Simulink 6.6/R2007a and newer.
In cases 2 and 3, the MDL file is using simulation components, called blocks, that this version of MATLAB doesn't support.  The included blockset changed as of Simulink 6.6 (R2007a).  If the file was created with a newer MATLAB/Simulink, download the update.  You will need the license login and password to get access to the updates on the web site.  If the file was built with an older MATLAB/Simulink, use this conversion tool to update it http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=12808.
Reference:  http://www.mathworks.com/support/solutions/en/data/1-3Q7OBT/index.html?product=DS&solution=1-3Q7OBT

Q:  Where can I find documentation on the MATLAB file format?

A:  MATLAB files:  http://www.mathworks.com/help/toolbox/simulink/slref/f22-7245.html
Simulink MDL files:  http://www.mathworks.com/help/toolbox/simulink/slref/f22-7548.html

Q:  How do I install MATLAB 14 on Windows 7?

A:  Set the display theme to Windows Classic, then run the setup.exe as administrator.

Q:  When I uninstall MATLAB 14 on Windows 7, I get "Bummer - Uninstaller Error! - Exception calling main."

A:  MATLAB 14 is not compatible with Windows 7, so your results may vary.  To attempt to resolve this:
1.  Go to Control Panel|Appearance and Personalization|Personalization|Change the Theme
2.  Select Windows Classic
3.  Start|Run the UninstallString for MATLAB so it is run elevated (HKLM\SW\Microsoft\Windows\CurrentVersion\Uninstall, search for MATLAB.  If on Win64, HKLM\SW\Wow6432Node\...)
Reference:  http://www.mathkb.com/Uwe/Forum.aspx/matlab/162797/how-to-uninstall-matlab-7-0-1-from-win7-64-bit

Q:  When I open a MATLAB MDL file, I get the error "Warning:  Unable to open model file '<filename>'", but the right file is in the same directory and GT Suite is installed and licensed.  In the model, my GT node shows as red with the error "Bad Link."  If I try too run the simulation, I get many warnings and the error "Failed to find the library 'gtlink70'..."

A:  In MATLAB, select File|Set Path, click Add Folder, then browse to the directory where gtlink70.mdl is, typically GTI's v7.0.0\simulink directory.  NOTE that this file changes between GTI revisions, so a MATLAB model using GT Suite 7.0 will not work if GT Suite 7.1 is installed on the machine.

Q:  I get "Specified GT data file does not exist in the working folder" when running my MATLAB simulation embedding a GT Suite file.  The filename is correct and the file exists in the right directory.

A:  Double-click the GT node in Simulink and remove the ".dat" extension from the GT-SUITE Data File field.

Q:  In the GT Suite Simulink Coupling tutorial, where do I find the SensorCon and ActuatorCon parts?

A:  Select Window|Tile with Template Library to show the template library.  The Template Library window is not visible by default and there is no control or menu item to "open template library".

Q:  In the GT Suite Simulink Coupling tutorial, how do I create a link between parts?

A:  Right click in the workspace and select Create Link Mode.

Q:  In the GT Suite Simulink Coupling tutorial, how do I create the SimulinkHarness object?  I can't drag and drop.

A:  Right click the CONTROL\Components\SimulinkHarness node in the Mini Map and select Add Object, then enter a name and click OK.  Next, drag the new object that appears underneat SimulinkHarness to the workspace.

Q:  In the GT Suite Simulink Coupling tutorial, I can't find the menu option "Create .dat file"

A:  It's under Run|Run Simulation Utilities|Create .dat file.  The tutorial incorrectly describes it as being directly on the Run menu.

Q:  In the GT Suite Simulink Coupling tutorial, where did the .sim file come from?

A:  This is generated when you create the .DAT file.

Q:  How do I create a SimuLink simulation?

A:  Follow these steps:
1.  Start MATLAB
2.  Click MATLAB's Start button at the bottom of the MATLAB window
3.  Select Simulink|Library Browser, then File|New|Model.

Q:  Where are the parts for the MATLAB simulink_model in the Simulink library?

A:  Desired Torque:     Simulink\Sources\Sine Wave Function
    Unnamed circle:     Simulink\Commonly Used Blocks\Sum
    PID Controller:     Simulink Extras\Additional Linear\PID Controller
    Saturation:         Simulink\Commonly Used Blocks\Saturation
    GT-SUITE Model:     GT-Suite7.1\GT-SUITE Model
    Unnamed block:      Simulink\Commonly Used Blocks\Demux
    Crank Angle:        Simulink\Sinks\Scope
    Avg. Torque:        Simulink\Sinks\Scope

Q:  Are some MATLAB model filenames invalid?

A:  Yes.  A MATLAB .mdl file node name must be a valid MATLAB model name.  This excludes symbol characters such as -, #, =, !, ', ",

Q:  I copied an MDL with supporting DAT to another directory and when I open them I get the error "Specified GT data file does not exist in the working folder"

A:  Goto the MATLAB main window and click the browse (...) button in the toolbar to the right of the Current Directory control, then select the directory that the MDL file is in.  Supporting files are expected to be in the current MATLAB directory.  Opening a Simulink MDL does not change the working directory.

Q:  What are the GTI file types?

A:  They are:
    GTM - GUI engine design
    DAT - command line (solver) model.  Export a GTM to get this.

Q:  How do I create the Simlink MDL file used in the SimulinkCoupling tutorial?

A:  Follow these instructions:
1.  Create a work directory.
2.  Copy the GTI Suite DAT file produced in that exercise to the work directory.
3.  Start MATLAB.
4.  Click the browse (...) button in the toolbar to the right of Current Directory and select the work directory created in step 1.
5.  From the MATLAB Start menu, select Simulink|Library Browser.  The window may come up in the background.
6.  In the new model window, select File|New|Model.
7.  Create the Simulink model by dragging nodes from the Library Browser window and dropping on the model window, then double clicking and configuring the new node.  Drag out the following nodes and set the parameters listed.
    Simulink\Sources\Sin Wave
        Sine type   Time based
        Time (t)    Use simulation time
        Amplitude   20
        Bias        50
        Frequency   2
        Phase       0
        Sample time 0
        Interpret vector parameters as 1-D  OFF
    Simulink\Commonly Used Blocks\Sum
        Main
            Icon shape      round
            List of signs   |+-
            Sample time     -1
        Signal data types
            Saturate on integer overflow    ON
    Simulink Extras\Additional Linear\PID Controller
        Proportional    0.1
        Integral        5
        Derivative      0
    Simulink\Commonly used blocks\Saturation
        Upper limit                         1000
        Lower limit                         0
        Treat as gain when linearizing      ON
        Enable zero crossing detection      ON
        Sample time                         -1
    GT-Suite7.1\GT-SUITE Model
            Filename            <DAT file node name no extension>
            Number of inputs    1
            Number of outputs   2
    Simulink\Commonly used blocks\Demux
        Number of outputs   2
        Display option      bar
        Bus selection mode  OFF
    Simulink\Sinks\Scope
        After creating, click the Scope label and rename to Avg Torque
    Simulink\Sinks\Scope
        After creating, click the Scope label and rename to Crank Angel
8.  Connect the nodes.  Input and output connections are shown as small in and out arrows.  To connect two nodes, move the cursor over one of these, then click and drag to the other.  Connect the nodes as follows:
    Sin Wave -> Sum +
    Sum Output -> PID Controller
    PID Controller -> Saturation
    Saturation -> GT-SUITE Model
    GT-SUITE Model->Demux
    Demux top -> Scope #1
    Demux bottom -> Scope #2
    Sum - -> (Line connecting Demux top to the Avg Torque Scope)
9. Select Simulation|Configuration Parameters and set Stop time to 1.0.
10.  Save the file.
11.  Select Simulation|Start to run the simulation.

Q:  How do I setup Visual Studio remote debugging?

A:  To enable native debugging, follow these instructions:
1.  Build debug and copy the debug binaries along with symbols (PDBs) to the machine where the application will run (debuggee).
2.  Login to the debuggee as a user with local administrative rights.
3.  Install the VS2010 remote debugger on the debuggee.
4.  You must grant local administrative rights on the debuggee machine to the account used on the debugger machine.  If the two machines are not in a domain, to do so, create an account on the debuggee machine with the same username and password as used on the debugger machine with local administrative rights.
5.  Browse to the debuggee from the debugger.  You should be able to see the machine and not be prompted to login.
6.  Run the Remote Debugger (NOT the configure Wizard) on the debuggee machine, elevated if on Vista+.
7.  Select Tools|Options and set the Authentication mode to No authentication (native only), check Allow Any User to debug, and click OK.
8.  At the debugger machine, start Visual Studio and select Debug|Attach to Process.
9.  Set Transport to Remote (Native only with no authentication) and enter the machine name or IP of the remote in Qualifier, then hit Enter.
10.  Select the process to debug.

For more information, see http://www.wintellect.com/CS/blogs/jrobbins/archive/2010/06/15/vs-remote-debugging-across-workgroups-or-domains.aspx.

Q:  In Process Explorer, I can't see the Path, Command line, or current directory for the app I'm inspecting.  Why?

A:  Insufficient rights.  Exit Process Explorer and re-run it elevated and with local admin rights.

Q:  My Access 2007 Autonumber field is recycling previous values.  Why?

A:  Install Access 2007.  On systems without access, using the Jet driver that ships with Windows, the Jet driver will do this.  It is technically correct because AutoNumber is intended to provide a unique key number automatically.

Q:  How do I reset a Jet/Access AutoNumber field?

A:  Use ALTER TABLE <tableName> ALTER COLUMN <columnName> COUNTER (<starting ID>,<increment>).  Also see http://support.microsoft.com/kb/202117.

Q:  I'm getting an "Error using ==> open '<filename>' is an invalid model name or the file" from MATLAB when opening a Simulink MDL, but the file exactly matches one that works.

A:  Rename the file, removing any symbols, particularly the dash "-".  Simulink does this in particular

Q:  My application fails to start on Vista+ with "A referral was returned from the server"  How do I fix this?

A:  Set <requestedExecutionLevel uiAccess="false" /> in the manifest.  Vista+ returns this error if it cannot grant this right.  Granting this right requires the EXE to be signed and in Program Files and is only needed if you are driving the UI of another program.  Alternatively, you can disable the ValidateAdminCodeSignatures machine policy (http://msdn.microsoft.com/en-us/library/cc232764%28PROT.13%29.aspx), but this is system wide.

Q:  MATLAB rejects my Simulink file with an error, but the gti_fname file specified exists and is in the working directory.  Why won't it work?  The error is:

    No GT data file specified specified GT data file does not exist.
A:  Restart MATLAB.  You previously attempted to load and run the same MDL file with a different, bad gti_fname value.  MATLAB can sometimes get stuck in this state.

Q:  Depends fails on Windows Vista or higher with a complaint about a missing IViewers.dll, but it is there.

A:  Re-run depends elevated.  IViewers hosts a COM object that depends registers per-machine.

Q:  How can I make an action in a MSBUILD XML script conditional?

A:  Add a Condition attribute to it.  All tasks inherit this functionality, so it can be used almost anywhere.  For example, to make an action only occur if a property is set on the command line, do the following:
1.  Define the property in the PropertyGroup section by adding an element equal to the name for the property.  This is not necessary, but is a good practice.  For example:
    < Incremental ></Incremental >
2.  Modify the task line(s) to only run if the property is null.  For example:
     <Exec Condition="'$(Incremental)' == ''" Command="devenv .\source\Vision_VS2005.sln /rebuild Release" />
3.  Specify the property on the command line to enable the functionality.  For example:
    msbuild /property:Incremental=ON MyProject.proj
 

Q:  How do I programmatically check if Windows is activated?

A:  There are two different methods, depending on if the OS is pre-Vista or Vista+.  See the code below.  In addition, you may need to copy several constants from slicpub.h, if your WIndows SDK version is set to Windows XP.
// From slpublic.h when Windows SDK mode is set to Vista.
#ifndef _SLPUBLIC_H_
    typedef GUID SLID;
    typedef enum _SL_GENUINE_STATE {
      SL_GEN_STATE_IS_GENUINE        = 0,
      SL_GEN_STATE_INVALID_LICENSE   = 1,
      SL_GEN_STATE_TAMPERED          = 2,
      SL_GEN_STATE_LAST              = 3 
    } SL_GENUINE_STATE;
    typedef struct _tagSL_NONGENUINE_UI_OPTIONS {
      DWORD      cbSize;
      const SLID *pComponentId;
      HRESULT    hResultUI;
    } SL_NONGENUINE_UI_OPTIONS;


    #define SL_PROP_BRT_DATA                                    L"SL_BRT_DATA"
    #define SL_PROP_BRT_COMMIT                                  L"SL_BRT_COMMIT"
    #define SL_PROP_GENUINE_RESULT                              L"SL_GENUINE_RESULT"
    #define SL_PROP_NONGENUINE_GRACE_FLAG                       L"SL_NONGENUINE_GRACE_FLAG"
#else
    #pragma message("** Remove Windows SDK constants copied to " __FILE__ " that are no longer necessary **")
#endif

typedef int (__stdcall *LegitCheckFunction)(void);
typedef HRESULT (__stdcall *SLIsGenuineLocalFunction)( const SLID* pAppId, SL_GENUINE_STATE* pGenuineState, SL_NONGENUINE_UI_OPTIONS* pUIOptions );

#define OLDSLIC_DLL_FILENAME            "LegitLib.dll"
#define OLDSLIC_LEGITCHECK_EXPORTNAME   "LegitCheck"
#define SLIC_DLL_FILENAME               "slwga.dll"
#define SLIC_ISGENUINE_EXPORTNAME       "SLIsGenuineLocal"
// Windows AppId for SLIC:  {55c92734-d682-4d71-983e-d6ec3f16059f}
SLID SLID_WINDOWS = {0x55c92734, 0xd682, 0x4d71, 0x98, 0x3e, 0xd6, 0xec, 0x3f, 0x16, 0x05, 0x9f};

bool IsWindowsActivated()
{
    HMODULE             moduleHandle                = NULL;
    LegitCheckFunction  legitCheck                  = NULL;
    bool                checkedWindowsActivated     = false;
    bool                windowsActivated            = false;

    moduleHandle = LoadLibrary(OLDSLIC_DLL_FILENAME);
    if (moduleHandle != NULL)
    {
        // Windows XP method
        legitCheck = (LegitCheckFunction) GetProcAddress(moduleHandle, OLDSLIC_LEGITCHECK_EXPORTNAME);
        if (legitCheck != NULL)
        {
            checkedWindowsActivated = true;
            windowsActivated = (legitCheck() == 0);
        }
        FreeLibrary(moduleHandle);
        moduleHandle = NULL;
    }
    else
    {
        // Windows Vista+ method
        SLIsGenuineLocalFunction    slIsGenuineLocal            = NULL;
        SL_GENUINE_STATE            windowsLicensingState       = SL_GEN_STATE_INVALID_LICENSE;
        HRESULT                     returnValHR                 = E_FAIL;

        moduleHandle = LoadLibrary(SLIC_DLL_FILENAME);
        if (moduleHandle != NULL)
        {
            slIsGenuineLocal = (SLIsGenuineLocalFunction) GetProcAddress(moduleHandle, SLIC_ISGENUINE_EXPORTNAME);
            if (slIsGenuineLocal != NULL)
            {
                checkedWindowsActivated = true;
                returnValHR = slIsGenuineLocal(&SLID_WINDOWS, &windowsLicensingState, NULL);
                if (SUCCEEDED(returnValHR))
                    windowsActivated = (windowsLicensingState == SL_GEN_STATE_IS_GENUINE);
            }
            FreeLibrary(moduleHandle);
            moduleHandle = NULL;
        }
    }
    return windowsActivated;
}

Q:  How do I make the C++ runtime use the user's current Windows locale?

A:  Call setlocale(LC_ALL, "");  The RTL defaults to US English for legacy compatibility reasons.

Q:  Visual Studio 2005 will not let me set a breakpoint in C++ code, but I know the symbols are correct.  Why?

A:  Detach the debugger, then bring up the Attach to Process dialog and change the Attach To to Native code.  If the target program also uses managed code, Visual Studio will prefer attaching for managed debugging only by default.  The VS2005 debugger cannot attach for multiple modes simultaneously.


Q:  How do I remove a guideline I've added using the Visual Studio 2010 Productivity Power Tools?

A:  On any line, space over to the column position of the guideline to create line content out to that position, then right-click that column and select Guidelines|Remove Guideline.  If there is no line content at the guideline column, you cannot remove it.  This is not obvious.

Q:  In Visual Studio, how do I set a breakpoint on a Windows API call?

A:  Select Debug|New|Break at Function..., then enter a specially formed string in the Function box.  This is the crux of the problem, as the syntax for this string is not well described, and versions of Visual Studio older than 2010 require more verbose syntax.
        {[<function>],[<source filename>],<module filename>}Location

For example, the following are valid breakpoint descriptions for Visual Studio 2010:
Breakpoint SpecifierPlatform Works On
 _MessageBoxW@16   32-bit
 {,,kernel32.dll}_OutputDebugStringW@4  32-bit
 {,,kernel32.dll}_QueryPerformanceFrequency@4 32-bit
 {,,Advapi32.dll}_RegOpenKeyA@12 32-bit
 {,,Advapi32.dll}_RegOpenKeyW@12 32-bit
 {,,Advapi32.dll}_RegOpenKeyExA@20 32-bit
 {,,Advapi32.dll}_RegOpenKeyExW@20 32-bit
 MessageBoxW 64-bit
 {,,kernel32.dll}QueryPerformanceFrequency 64-bit
 {,,Advapi32.dll}RegOpenKeyA 64-bit
 {,,Advapi32.dll}RegOpenKeyW 64-bit
 {,,Advapi32.dll}RegOpenKeyExA 64-bit
 {,,Advapi32.dll}RegOpenKeyExW 64-bit
    
The most reliable syntax is to use the context operator {} to specify the module name and the name of the debug symbol for the function you want a breakpoint on.  The later is an important clarifier, because the name used in the C++ source will normally not match the debug symbol, and may be quite different.  There are several other exceptions:
0.  Most symbol names have an _ prefix.
1.  The Location string used for a 32-bit symbol may not work on a 64-bit build, and vice-versa.
2.  Most functions have different symbol names depending on the type of strings the module was built with.  If built for MBCS/DBCS, this is called an ANSI build since it char and TCHAR are 1 byte in size.  ANSI functions have a postfix of A.  If built for UNICODE, char is 2-bytes in size, and functions have a postfix of W.
3.  The compiler uses the size of the parameters, in bytes, as a form of function overloading at this level.  It's not as capable as C++'s name mangling, but has been around for longer.  This is appended to the function name after the string-type postfix with the separator "@".
In general, a debug symbol name for 32-bit Windows API functions will be of the form _<function name>@<parameter size>.

Finally, note that the Visual Studio 2010 parser for breakpoint strings is more capable than older versions.  In 64-bit mode, it will accept MessageBoxW instead of the more verbose, but equally accurate, {,,user32.dll}MessageBoxW.

One way to determine the symbol name used is to spin a build with a call to the API you want to break on, then perform a Go To Disassembly... to view the symbol used to perform the call.  However, note that THIS symbol isn't quite the symbol you want - this is the implicit import stub used to call the target function.  It will be prefixed with "__imp__", but otherwise should have the same name.  Also, depending on your build and system configuration, this might not work.  For example, the following are several call statements for different builds of a program calling MessageBox:

64-bit Debug:
    000000013F5B1716  call        qword ptr [__imp_MessageBoxW (13F61A7B8h)]  
64-bit Release:
    000000013F9F1579  call        qword ptr [__imp_MessageBoxW (13F9F3190h)]  
32-bit Debug
    01114516  call        dword ptr [USER32_NULL_THUNK_DATA (11773FCh)]  
32-bit Release
    010C1496  call        dword ptr [__imp__MessageBoxW@16 (10C20D0h)]  

Note that in the 32-bit debug build, the call is made through a thunk instead of via the __imp__ export.

For more information, see the following links:

Q:  How do I resolve problems when my manifest has multiple references to the same assembly as different versions?  For example, Microsoft.VC80.CRT at 50727.762 and 50608.0.

A:  See this MSDN article.  It should be possible to write an app config file to specify a redirect from the old version to the new.

Q:  I installed NuGet in Visual Studio 2010, but don't get any packages listed.  When I go to Tools|Library Package Manager|Manage NuGet Packages for Solution... and select Online|NuGet official package source, I get the error "Could not load file or dependency 'TTVSAddinDotNet.resources.module' or one of it's dependencies.  The system cannot find the file specified.

A:  Go to Tools|Add-In Manager..., find the listing for the TestTrack add-in, then uncheck it's Available and Startup boxes, then restart Visual Studio 2010.  TestTrack's Visual Studio AddIn is incompatible with NuGet - simply disabling it is insufficient.  However, you can work around this by starting Visual Studio 2010 with TestTrack disabled and not started, running NuGet, then enabling the TestTrack add-in manually.

Q:  How can I view a multi-line string in Visual Studio, without having to use NotePad or some other text editor?

A:  Click the magnifying-glass icon in the value column when you are inspecting the value of the variable and select Text Visualizer.  In the debug immediate and watch windows, it is on the right edge of the value column, but in the free-floating variable inspector, it is on the left edge.  It is easy to overlook.  The following screenshot shows the icon in the free-floating inspector window.
Visualizer Access Control Screenshot

Q:  How do I fix the date/time in a VMWare Workstation VM so it does not change?

A:  You must make four changes.  The order of the changes is insignificant.
1.  Start the VM and open VMWare tools.
2.  Disable the Time Synchronization check box and click OK.
3.  Disable the operating system's network time synchronization.  To do this in Windows:
    a.  Go to Control Panel|Administrative Tools|Services
    b.  Find the W32Time service, called Windows Time, and set it to disabled.  Manual is insufficient.
4.  Shutdown the VM and save changes.
5.  In a text editor, open the .VMX file for the VM.  This is the only file in the VM directory with the same name as the VM and the extension .VMX.  Normally, it is the only .VMX file.
6.  Find the line setting the value tools.synchTime.  Set it to "FALSE" and add several other settings, as shown below.
        tools.syncTime = "FALSE"
        time.synchronize.continue = "FALSE"
        time.synchronize.restore = "FALSE"
        time.synchronize.resume.disk = "FALSE"
        time.synchronize.shrink = "FALSE"
        time.synchronize.tools.startup = "FALSE"
7.  Save the changes.
8.  Start the VM and set the time to whatever you want it to be when the VM starts up.  If this is not done, the date will always appear to be the current date/time when the VM is started.
    a.  Click the date/time in the taskbar.
    b.  Click Change date and time settings.
    c.  Click change date and time and respond with OK/Continue if prompted for elevation.
    d.  Set the new time.
    e.  Click OK, then click OK.
9.  Shutdown the VM.
10.  Take a snapshot of the VM.  It is a good idea to optimize the disk before doing so.
When the VM starts, it will now report the current date/time as that set in step 8 at startup and will then advance time at the normal rate.

Q:  Visual Studio 2010 refuses to add a reference to a type library with the error "This file may not be a managed assembly", but it is a valid TLB.  How do I add it?

A:  This can be caused by the Visual Studio 2010 Productivity Power Tools.  To resolve it disable them.  Go to Tools|Extension Manager, click Productivity Power Tools, click Disable, then Restart Visual Studio.  Solution courtesy stack overflow.

Q:  Why won't Visual Studio 2010 step through the NET framework source?  I have everything configured correctly.

A:  Your NET binaries have been patched.  Microsoft does not post PDBs for patched binaries, only the major releases.  To resolve this, create a VM with a distribution of Windows no newer than the release date of the NET framework you want to trace and do NOT apply any updates.  Then install the framework you want to trace, if needed, and Visual Studio.  Reference this MSDN posting.

Q:  How do I disable the background image on a Windows 7 Starter netbook?

A:  Use the Ease of Access Center to disable background images.  To change the desktop color from black to something else, use Display|Change Color Scheme to change the background color.  Source yahoo.

Q:  In Visual Studio 2010, how do I jump to a matching brace?

A:  Move your cursor to a brace, then hit Ctrl-].  Note that Ctrl-[ does not work.

Q:  In Visual Studio 2010, how do I embed a resource in only one build configuration?

A:  Edit the CSPROJ file directly and add a Condition attribute to the element for the resource.  This cannot currently be done in the GUI.  For example:
    <EmbeddedResource Include="source.txt" Condition="'$(Configuration)'=='Debug'" />


Q:  How do I determine the help topic ID number that a program is displaying when I hit help?

A:  Do the following:
1.  Download and install the HTML Help Workshop, available here.  Note that the latest version is 1.3 and is dated 2009 June.
2.  Run HTML Help Workshop
3.  Select View|HTML Help Compiled Messages
4.  Start the program you are interested in.
5.  Use the program to display a help topic.
6.  The HTML Help Workshop will log the topic ID and path shown in the following format:
HH_HELP_CONTEXT: mk:@MSITStore:C:\Program Files (x86)\Accurate Technologies\ATI VISION 3.7.3 RC (build 40)\VISION.chm: 4150 (VISION_Doc/VISION-Common_Content/Common_Windows/VISION_Options_Properties_General_Tab.htm)

Q:  I can't some kind of fields in a Word 2010 document.  I get the error message "protected content".  How do I delete this text?

A:  There are several possible causes.  One uncommonly known cause is the use of design-mode fields.  To fix this:
1.  Go to File|Options|Customize Ribbon and check the Developer ribbon tab so it is shown, then click OK.
2.  Click the Developer tab.
3.  Click Design mode.
4.  Click on the field object.  A title grab bar will appear with the name of the field.
5.  Click the title bar shown in step 2.
6.  Click delete

Q:  If I use Google Chrome to search and click a social.msdn.com link, the response is slow and I ultimately get a "Something went wrong" error.  However, I can view the results in Internet Explorer.

A:  This is a cookie issue.  Clear your cookies in Chrome and it will work again.  Re-signing in to MSDN does not appear to resolve this.

Q:  When using the Surround SCM command line to checkin a file, I get the error "Unable to find mainline  with branch ."

A:  This can be caused when a repository (directory) is configured to require TestTrack defect attachments, but the account being used doesn't have rights to login to TestTrack.  To resolve this either disable requiring attach to defect on checkin, or use a different account that has TestTrack and Surround rights.  In the first case, check the properties of the repository (directory) the file is in for a "TestTrack Integration" tab.  If this exists with Attach to defect = Required, then change the setting to "Enabled" or move the file to a different repository where this is not required.  In the later case, use an account other than AutomatedBuild that has rights to both TestTrack and Surround.

Q:  The monitor on my nVidia card has suddenly switched to greyscale.  How do I get the color back?

A:  Follow these instructions:
1.  Go to the nVidia Control Panel
2.  Find the settings for the problem monitor.  Currently, this is in Display|Adjust Desktop Color Settings.
3.  Set the Digital Vibrance back to 50% and click OK.

Q:  While debugging code in Visual Studio 2012, I get an error "Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information."

A:  This occurs when debugging a NET 4.0 or above assembly that loads an older assembly targeting CLR 2.0 or previous.  There are two ways to fix this:
1.  Modify all child assemblies to use the same version of the .NET framework
2.  In the App.config, set /configuration/startup[useLegacyV2RuntimeActivationPolicy] ="true".

Source:  Marius Banicla.

Q:  I get the error "Invalid argument or procedure call" when scripting the VMWare VIX API in a .vbs script run by the Windows Scripting Engine (wscript/cscript), but the code matches the VMWare example.

A:  The most likely cause is that your script is using VBS constants for the VIX constants.  The VBS engine creates variant values of type integer, but the WIX API only accepts variants of type long, regardless of the numeric value.  This is an issue with the VIX API.  If the same code works when run under Visual Basic (not just the scripting engine or VBA), this is most likely the cause.  To resolve this, do one of the following:
1. Replace the constant definitions with clng calls, which will convert the variant integers to variant longs.
2. Use a WSF frame, import the VIX type library, and reference the constants from the type library directly.  For example:
    <job id="example">
        <reference object="VixCOM.VixLib" />
        <script language="VBScript">
            Set lib = CreateObject("VixCOM.VixLib")
            Set job = lib.Connect(VixCOM.Constants.VIX_API_VERSION, hostType, hostName, 0, hostUsername, hostPassword, 0, Nothing, Nothing)
        </script>
    </job>
Solution suggested by the VMWare Community.

Q:  In Visual Studio 2012/2013, how do I order an item configured with Custom Build Tool so it is done before compilation or the resource compiler?  The Execute Before box is greyed out.

A:  Edit the vcproj file and add the following element to /Project/PropertyGroup[Label="Globals"]:
        <CustomBuildBeforeTargets>CLCompile</CustomBuildBeforeTargets>
This will make all items configured to build with custom build tool to be performed before the C++ compiler runs.  There may be other ways to do this too.  Sources:  MSDN forums, Visual Studio blog.

Q:  In Visual Studio 2010/2012/2013/higher when debugging a 32-bit DLL run using rundll32, Visual Studio reports the error "The breakpoint failed to bind."  How do I fix this?

A:  Specify the full pathname of the 32-bit version of rundll32, in c:\windows\syswo64.  On 64-bit Windows, the rundll32 in c:\windows\system32 is the 64-bit version.  If it detects that your DLL is 32-bit, it will automatically launch the 32-bit version of rundll32 as a child process, but Visual Studio is attached to the parent instead where it cannot set the breakpoint, thus the error.

Q:  How can you XPath query XML data that uses namespaces?

A:   There are two basic ways to deal with namespaces in XPath queries:
1.  Make the XPath querier aware of the namespace URL and the short name you'll use to refer to it in the XPath query string.  Then use the prefix in your XPath query.  This is the most typical solution when using the Java or .NET XML classes.
2.  Use the local-name() XPath function to compare against the node/attribute name without namespace.  This is less common but still effective.  For example, given the following XML:
      <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
          <PropertyGroup>
              <ProductVersionMajor>3</ProductVersionMajor>
          </PropertyGroup>
      </Project>

The xmlns attribute specifies that Project and all subnodes reside in the namespace http://scemas.microsoft.com/developer/msbuild/2003.  This means that a simple non-namespace aware query like /Project/PropertyGroup/ProductVersionMajor will fail because the Project, PropertyGroup, and ProductVersionMajor specifications of the query have no namespace so do not match the apparently corresponding nodes in the sample XML.  To resolve this, use the local-name() function to exclude consideration of the namespace in the comparison, as follows:
/*[local-name() = 'Project']/*[local-name() = 'PropertyGroup']/*[local-name() = 'ProductVersionMajor']

Note that local-name must be used for all nodes along the path, and that each term must be prefixed with *.

Q:  I can't login to GitHub for Windows with the error "Unable to retrieve your user info from the server."  However, I can login to https://www.github.com.

A:  This is a bug in the GitHub for Windows client that occurs with old versions of the .NET framework.  Install .NET 4.5 or above to resolve the issue.  Courtesy github.

Q: I can't install NET 3.5 on Server 2012. I get the error "One or more installation selections are missing source files..."

A: This is a problem in Server Manager. To resolve this:
1. Start Server Manager
2. Select Add Roles and Features
3. At Installation Type, Select Role-based or feature-based
4. At Server Selection, select your server.
5. At Server Roles, click Next.
6. At Features, select .NET Framework 3.5 features, and any sub-features you need.
7. At Confirmation, click Specify an alternate source path.
8. Insert the Server 2012 DVD and note the driver letter.
9. At Specify Alternate Source Path, set Path=<DVD drive letter>:\sources\sxs. For example, D:\sources\sxs.
10. Click OK.
11. Click Install.

Courtesy Microsoft at this link.

Q:  Server 2003 reports a specific certificate as invalid, stating: The integrity of this certificate cannot be guaranteed.  The certificate may be corrupted or may have been altered."  However, any operating system Windows Vista or above recognizes the certificate as valid.  How do I fix this?

A:  Server 2003 does not support the SHA-2 hash algorithm.  This is described in Microsoft article 938397.  To resolve this, goto this KB article, click Hotfix Download Available, select your platform, and follow the instructions at the bottom of the page to be emailed a link to the file.  Note that by default the page shows only Server 2003 x64.  Click the show all platforms link and find the Server 2003 English link to get the hotfix for a standard US English 32-bit Server 2003.  Note this update will require a reboot.
An example of this error is shown below.

Q: I published a Computer certificate template, but cannot see it in the Certificates snap-in when I use Request New Certificate.  Why?

A:  This is due to an unobvious security conflict.  The Computer certificate template's security is configured so only Domain Admins and Domain Computers can Enroll.  However, when you create a Certificates snap-in for the Local Computer, that snap-in is run under the Local Computer account.  If the local computer is a domain controller, then Request New Certificate cannot Enroll using the new template because the computer, a DC, is not in Domain Computers.  To fix this:
Goto the Certificate Templates snap-in
Find the template in question, right click it, and select Properties
Click the Security tab.
Either click Add, specify Domain Controllers, and click OK; or select Authenticated Users.
Click Enroll.
Click OK.

Q:  The Certificate Service caps the validity period of any cert I make at 2 years even though the request asks for a longer period.  The root CA is valid longer than 2 years.  How do I fix this?

A: The Windows Certificate Service caps the validity period at the lesser of the root CA expiration or an internal setting, which defaults to 2 years.  To extend the built-in limit to 10 years:
Start an elevated command prompt.
Enter certutil -setreg ca\ValidityPeriod "Years".
Enter certutil -setreg ca\ValidityPeriodUnits 10.
Enter net stop certsvc.
Enter net start certsvc.
Courtesy Microsoft KB 254632 available here.

Q:  JavaScript single-stepping and debugging is very slow in Internet Explorer.  It takes 3-10 seconds between pressing <F10> and the step.  How do I fix this?

A: This can be caused by the LastPass plug-in.  To fix this, disable the plug-in, but note a restart is required for the fix to take effect.  To fix this:
 In Internet Explorer, if the menu is not displayed, tap the <Alt> key.
Select Tools|Manage Add-Ons
Select LastPass, then click the Disable button at the bottom of the Window.
Click Close.
Restart Internet Explorer.

Q:  How do I get the serial number of a Yubikey?

A:  There are several ways.  Also, note the serial number is not the same as the Public Identity.
Since late 2010, the serial number has been printed on the key in text and as a DataMatrix 2D barcode (click here for source).  For example:
It can be read electronically by their tools, although this can be disabled.  To do so:
Run the YubiKey Personalization Tool
Insert the key and wait up to 5 seconds for the GUI to detect the device.
The serial number is shown on the About tab in the right-hand pane, as shown below.

Q: How do I use an environmental variable in Visual Studio 2010, 2012, 2013 for Start External Program?

A: Not supported. See this link. In 2013 and above, the following macro subset is supported: click here.

Q: In PowerShell, I get the error "cannot be loaded because the execution of scripts is disabled on this system" How do I fix this?

A: There are two ways. First, run the PowerShell script with the "-ExecutionPolicy ByPass" option. Second, change the PowerShell policy on this machine to permit execution by the following:
1. Run PowerShell elevated as a local admin
2. Enter "Set-ExecutionPolicy Unrestricted".
Source: TechNet.

Q:  How do I run Hyper-V (in Windows Server) in a VM under VMWare Workstation 10+?

A: This can be done, but is considered unsupported by VMWare because it involves running a hypervisor within a hypervisor.  The following instructions will work for a Server 2012 VM running under VMWare Workstation 10 or Server on a Windows 7 x64 host.  They are claimed to work for Server 2008 VMs, but this could not be reproduced.
Create a Server 2008 x64 virtual machine with at least 1.5G of RAM
In Edit Virtual Machine Settings, select Processors and check Virtual Intel VT-x/EPT or AMD-V/RVI and Virtual CPU Performance Counters and click OK.
Browse to the directory that contains the VM files and open the .vmx file in a text editor.
Add the following lines, then save the file:
hypervisor.cpuid.v0 = "FALSE"
mce.enable = "TRUE"
vhu.enable = "TRUE"
If running Server 2008, after installing Windows, open an elevated command prompt and run "bcdedit /set xsavedisable 1", then reboot.
If running Server 2008, you may need to also install a Microsoft hotfix available here.  Alternately, install SP1.
Sources:
Detailed step-by-step article
Microsoft hotfix

Q:  I get the error "linked to missing export" with my function template, declared in a header and defined in a CPP.

A:  This is due to how C++ handles template functions.  To solve this, do one of the following:
Relocate the definition to a header file.  This is not recommended because it puts code in headers and increases code size, but is often done because it is easy.
Instantiate the template in the CPP file using all type(s) that are used in the project.  For example, given the following template:
template<typename TCredentialType, typename TLogonMessageType>
void LogIfLogonTypeUnexpected( void* credentialInfoRaw, TLogonMessageType expectedLogonTypes[], ULONG noExpectedLogonTypes )
That is called with the type arguments KERB_INTERACTIVE_LOGON, KERB_LOGON_SUBMIT_TYPE and _MSV1_0_INTERACTIVE_LOGON, MSV1_0_LOGON_SUBMIT_TYPE, instantiate it like this anywhere in the CPP file:
template void LogIfLogonTypeUnexpected<KERB_INTERACTIVE_LOGON, KERB_LOGON_SUBMIT_TYPE>( void* credentialInfoRaw, KERB_LOGON_SUBMIT_TYPE expectedLogonTypes[], ULONG noExpectedLogonTypes );
template void LogIfLogonTypeUnexpected<_MSV1_0_INTERACTIVE_LOGON, MSV1_0_LOGON_SUBMIT_TYPE>( void* credentialInfoRaw, MSV1_0_LOGON_SUBMIT_TYPE expectedLogonTypes[], ULONG noExpectedLogonTypes );
Source is this C++ FAQ, among many.

Q: How do I set the binding order of network adapters on a multi-homed Server 2012 computer?

A: Microsoft has moved this to an unobvious, but not hard to get to, location.  Follow these steps:
1. Goto Control Panel|Network and Internet|Network and Sharing Center
2. Click Change Adapter Settings.
3. If the menu is not displayed, tap the <Alt> key to activate it.
4. Select Advanced|Advanced Settings.
Courtesy this source.

Q:  How do I enable copy/paste with a VMWare Server/vSphere VM?

A:  This is disabled by default starting in Server 4.1.1, but can be re-enabled by editing the vmx file.  To do so in vSphere 5.x:
Start the vSphere client and find the problematic VM
Find the problematic VM and make sure it is off.
Right click the VM and select Edit Settings.
On the Options tab, select Advanced|General and click the Configuration button.
Click Add Row and enter the setting name "isolation.tools.copy.disable" with a value of "FALSE".
Click Add Rpw and enter the setting name "isolation.tools.paste.disable" with a value of "FALSE".
Click OK, then back on Virtual Machine Properties click OK.
If the VM uses snapshots, note that this will not fix any existing snapshot.  Source is this VMWare KB article.

Q:  Is there a WMI browser or test utility built into Windows?

A:  Yes, there are a few.  The easiest to use is wbemtest.exe, a graphical WMI browser.  Wbemtest is graphical, but is not a full browser:  you can list the contents of a context if you know the context, but you need to know the name of some classes to display them.

Q:  In Visual Studio 2012, the Solution Configuration box in the toolbar is too small, cutting off the text.  How do I make it wider?

A:  Follow these instructions:
In Visual Studio, goto Tools|Customize.
Click the Commands tab.
Select Toolbar, then select the Standard toolbar.
Under Controls, scroll to the bottom and select Solution Configurations.
Click the Modify Selection button on the right, then increase the width field, generally tripling it.
Source this MSDN posting.

Q: In Visual C++ 2012, I get C4995s reported as errors instead of warnings and cannot build. How do I fix this?

A: This is a result of a change to the Security Check compiler option. This cannot be fixed either in the usual way, by suppressing the C4995 warning via #pragma warning, or by setting any of the symbols such as _CRT_NON_CONFORMING_SWPRINTFS and _CRT_NONSTDC_NO_DEPRECATE, although it once could be. To resolve this:
Goto Project Properties.
Select Configuration Properties|C/C++|Command Line.
In Additional options, add /wd4995.
Alternately, disable the Security Check option under C/C++|Code Generation.
Source: this MSDN blog.

Q:  How do I Url Escape/Encode in C++?

A:  This is no single Win32 API to do this - for example, CoInternetParseUrl can handle %-encodings, but not space-to+ escaping.  To do so via Win32 APIs, you must call two APIs successively.  ATL provides AtlEscapeUrl, but it does not handle space->+ conversion or reversal.

Q:  In C#, I can't write to a file whose handle is stored via SafeFileHandle using native APIs during a finalizer.  The handle appears to already be closed.  Why?

A:  Even though a parent object may have a reference to a child object, at finalization time, there are no ordering guarantees for finalizer execution.  If you need to log at finalization time, you cannot use SafeFileHandle or Streams and instead must use all-native I/O.

Q:  When installing Exchange 2013 on Server 2012, I get the error "Unsupported Operating System", but 2012 is clearly supported.  Why?

A: The Exchange 2013 install cannot tolerate the Remote Desktop Session Host feature on the same machine.  Remove it to install Exchange.  Courtesy this MSDN question.

Q:  I can't get Exchange 2013 install, it fails for various reasons.

A:  Increase the VM memory to 4G - 8G.  4G will most likely be enough.  In practice, once installed, development (low traffic) Exchange servers work OK with 4G but are slow until NodeRunner is disabled.  Microsoft's official minimum is 8G.

Q: How do I use the GITHUB GIT from a command line on a Windows machine connecting to an SSH GIT repository?

A:  This can be done using the Git Shell icon installed with GITHUB, but this solution requires manually running the batch file once the command prompt comes up and so is typically undesirable.  Alternately, to use GITHUB's GIT from any command line, automate the following steps:
Locate the first directory matching %LOCALAPPDATA%\GitHub\PortableGit*.  This is the GIT directory.
Prepend the path with %gitdir%/cmd and %gitdir%/bin.
Run ssh-agent.
Note the two variables reported to STDOUT and set them.
Run "ssh-add %USERPROFILE%\.ssh\github_rsa"  By default, GITHUB stores your SSH key in github_rsa.  Change this if needed, or run again to add any other keys you have.
To test the connection to the server, run ssh -T <servername>.  For example, ssh -T git@phab.duosec.org.
To test the connection to the repository, run git ls-remote ssh://<repository pathname>.  For example, git ls-remote ssh://git@phab.duosec.org/diffusion/SSP/simplesamlphp.git > nul

Q:  Visual Studio or MSBUILD never end after running a batch file that runs and exits fine at command line.  How do I fix this?

A:  Most likely, the batch file is running a process that runs another process asynchronously.  For example, for GIT.EXE to function on Windows with SSH authentication, it requires SSH-AGENT.  The SSH-AGENT process spawns another copy of itself.  MSBuild, used by Visual Studio, correctly waits for not just the root process - the shell processing the batch file - to execute, but also any processes started by them to execute.  In other words, msbuild waits for the entire process group to exit.  To resolve this, terminate the spawned process before the end of the batch file.  For example, for SSH-AGENT, run SSH-AGENT -k to kill the spawned process.  Then Visual Studio and MSBuild will see the process group has terminated and will continue with the rest of the build.

Q:  Chrome on Windows hangs when I minimize, then restore when using it with multiple monitors between display changes.  How do I fix this?

A: This is a bug in Chrome.  Goto Settings|Advanced and disable "Use Hardware Acceleration When Available".  Courtesy this post.

Q:  What is the easiest way to test ADFS to verify it is working?

A:  Start a browser and goto https://[serverFQDN]/adfs/ls/IdpInitiatedSignon.aspx.  Note if you browse to this using IE it will use Kerberos for primary auth.  Courtesy this site.

Q:  In Windows 10, how do I get the F8 Startup Options menu to display?

A:  By default, you cannot - it is now disabled.  To manually enable it:
Start an elevated command prompt
Enter bcdedit /set {default} bootmenupolicy legacy.
Courtesy this link.  Note the syntax in this MSDN link is very similar, but lacks the {default} keyword and implies it is unnecessary.  However, the setting will not take effect without default.

Q:  How do I set a breakpoint in DllMain when I am not sure where the function is defined?

A:  Select Debug|New Breakpoint|Break at Function and enter "{,,[ModuleFilename]}DllMain".  Courtesy this MSDN blog.

Q:  How do I save a list of all trusted certs for the machine and current user to a file?

A:  On Server 2012, use these commands:
certutil -store root >> machine.txt
certutil -store authroot >> machine.txt
certutil -store ca >> machine.txt
certutil -user -store root >> user.txt
certutil -user -store authroot >> user.txt
certutil -user -store ca >> user.txt

Q:  Why does a _COM_SMARTPTR_TYPEDEF-defined smart pointer throw on Release if it has no pointer?

A:  This is the default behavior, but is in contrast to the the smart pointers generated by #import using the typical raw_interfaces_only, however.  To avoid this, use CComQIPtr or CComPtr instead.

Q:  Does the Exchange team use exceptions in C++?

A:  No, for technical reasons, as of 2009.  See this Larry's comment in this link, and this other related link on Exception objects in c#.

Q:  How do I get the boot menu options to display at boot-up on Windows 8 on demand?

A:  There are two basic ways to do this:  by restarting into it or displaying it during boot.  To do the first, press <Windows>-I, select Change PC Settings, click Power, then hold <Shift> and click Restart.  Click Troubleshoot, Advanced Options, Startup Settings, then click Restart.  Windows will restart and display the boot menu.
The second method is practically impossible on machines or VMs with UEFI BIOSs, because the boot loader which monitors for F8 loads too quickly.  To resolve this, install EasyBcd, click Edit Boot Menu, set Timeout Options to Wait for user selection, and click Save Settings, then reboot.  A boot menu will now be displayed on every bootup.

Q:  When I try to copy a 64-bit file from a Visual Studio post-build command, I get the 32-bit version instead.  How do I fix this?

A:  Use the sysnative alias.  This occurs because Visual Studio is a 32-bit process, so the file system redirector redirects all accesses to c:\windows\system32 to the 32-bit c:\windows\syswow64 directory.  To fix this, reference c:\windows\sysnative instead.  Courtesy this Microsoft posting.

Q:  When I reference the ProgramFiles(x86) variable in a batch file, I get a "file specified was not found" error.  How do I fix this?

A:  Set a temporary variable equal to the value of ProgramFiles(x86), as in:  set programFilesx886=%ProgramFiles(x86).  This is a problem specific to CMD.EXE when using variable names with parenthesis in them.  Courtesy this link.

Q:  Using ATL implementing an interface #import'd from a TLB, I get the errors static_cast' : cannot convert from '[Class]::_ComMapClass *' to '[Interface*]', followed by "cannot convert from 'ATL::_ATL_CREATORARGFUNC (__cdecl *)' to 'DWORD_PTR'".  How do I fix this?

A:  The class needs to inherit from this interface as well.  This bizzare error is reported when the built-in offsetofclass operator, used in the COM_INTERFACE_ENTRY macro, fails because the interface specified is not implemented by the class.  One cause may be that the interface is declared in IDL as inheriting from IUnknown, but the ATL class implementing it inherits using the IDispatchImpl template.  To fix this, either change the IDL interface to inherit from IDispatch or change the ATL class to inherit from the class directly.

Q:  When I use the Resource Editor in Visual Studio, it changes the macros in my RC file to their literal equivalents and reports an error about __useHeader redefined.  How do I fix this?

A:  Open the RC using the source code editor, then add a #include for the header that defines the #defines under TEXTINCLUDE 2, and above that add a line to #define #define _USING_V110_SDK71_ 1.  Then also make the equivalent changes that these TEXTINCLUDEs are built into by the VS Resource Editor.  The final result should look like this:
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define _USING_V110_SDK71_ 1
#include "afxres.h"
#include "..\version.h"
 
...
2 TEXTINCLUDE
BEGIN
    "#define _USING_V110_SDK71_ 1\r\n"
    "#include ""afxres.h""\r\n"
    "#include ""..\version.h""\r\n"
    "\0"
END
Courtesy this MSDN forum posting.

Q:  Exchange 2013 refuses to start, citing an error mounting it's database.  How do I fix this?

A:  Repair the database, then delete all the log files.  To repair the mail database, you need the full pathname to the mail database, an EDB file.  To find it:
Open a web browser to the ECP (hostname/ecp) and login
In the left hand nav bar, click Servers.
In the top nav bar of the right hand pane, click databases.
Click the one database listing to select it.
Click the pencil button to bring up the editor
Copy the Database Path field.
To repair the database:
Start the Exchange Management Shell (an Exchange Powershell session) from the Start menu
Enter eseutil /P "[DatabaseFilePathname]"
At the "This database is not up-to-date, are you sure you wish to update it?" prompt click OK.
Open explorer to the directory where the Mailbox database is.
Delete all files with the .log extension
Back in the ECP, Click the More Actions button "...", click Mount, and click Yes to confirm.  The database should mount successfully.

Q: How do I get a static activation key for Visual Studio 2015?

A:  In your MSDN subscription, request a product key for Visual Studio 2015.  This is a personalized static key - it works as a static key, but can be traced to you.  See the comment from James Rice at Microsoft dated 20 Jul 2015 9:04P on this page.

Q: I edited a web page with TextPad and now the raw source is returned. How do I fix this?

A: This web page is stored in UNICODE 16-bit characters instead of old-style 8-bit ANSI and TextPad has removed the 2-byte marker at the beginning of the file that indicates the endianness of the data. IIS appears to require the BOM. To restore it:
1. Start TextPad and goto Configure|Preferences
2. Select Document Classes|HTML.
3. Check "Write Unicode and UTF-8 BOM".
3. Under the Files in class list, click box button to add a new row, then enter "*.aspx".
4. Click OK.

Q:  SmartGIt is fails to retrieve the SimpleSaml repository with "Could not read from remote repository", but it used to work.  I am connected to the VPN.  How do I fix this?

A:  There's a problem with the auth configuration for phab.duosec.org.  To fix this:
In SmartGIT, goto Edit|Preferences, and select Commands|Authentication
Click the listing for phab.duosec.org, then click Remove.
Click OK
In SmartGIT, select your Duo SimpleSaml repository, then click Pull.  If you don't have one:
Select duo_IIS
Expand DuoGIT and select simplesaml.
Select Remote|Properties, then copy the URL and click cancel.
In SmartGIT, select Repository|Clone and paste in the URL copied from step C and click OK.
At the SSH authentication prompt, click the Private Key File browse button and select your SSH private key file.
Click Login.  If this doesn't work, the key is encrypted with a password.  Enter that into the Passphrase field and then click Login.

Q:  Exchange 2013 is generating huge logs in C:\Program Files\Microsoft\Exchange Server\V15\Logging\Monitoring\Monitoring\ActiveMonitoringTraceLogs. How do I stop this?

A:  Open <ExchangeInstallPath>:\bin\MSExchangeHMWorker.exe.config in a administrative notepad
Find the Line <add key="IsTraceLoggingEnabled" value="true" /> and change to false and save. Reboot server and you can now clear the logs in the monitoring path and they will not regenerate.
Courtesy this source.

Q:  How do I debug a Windows Credential Provider?

A:  There's an easy way with limited but probably sufficient support and a hard way.  The easy permits debugging of the authentication codepath only when a user is unlocking a workstation.  To do this:
Get psexec from Microsoft's SysInternals site and install Visual Studio.
Backup the DLL and overwrite it with the debug build and copy in the PDB.
If necessary, copy the source files to this machine.
In an elevated command prompt as local admin, run psexec -dsx "<full pathname to Visual Studio debugger>".
In an elevated command prompt as local admin, run psexec -dsx cmd.  This provides the ability to restore the DLL to the original in case the new code crashes or corrupts the heap.
Hit <Ctrl-Alt-Del>
Hit <Alt-Tab> to switch to Visual Studio, now running in the Secure Desktop.
In Visual Studio, select Debug|Attach to Process and attach to LogonUI.exe.
Place any needed breakpoints.
Hit <Alt-Tab>
Select Lock.
Hit <Ctrl-Alt-Del>.  Note that after this point, you cannot <Alt-Tab> back to Visual studio.
Login
After this, note that each time you hit <Ctrl-Alt-Del> to start the cycle over again, a new LogonUI.exe is started, but Visual Studio is still running on the secure desktop.  So right after hitting <Ctrl-Alt-Del>, you must repeat steps 7-11.
Do NOT use the Switch user or Sign out menu options.  These will cause LogonUI.exe and the secure desktop to be destroyed, killing Visual Studio.  Source.
Full support requires setting up a kernel debugger and requires two machines.  For more information, see this msdn link.

Q:  Is it OK to use .NET to implement a credential provider or other Windows core security plug-in?

A:  NO, Microsoft specifically recommends against this, and specifies that all such components should be implemented in unmanaged C++.  See Microsoft KB article 841927.

Comments