6

I'm trying to follow this walk-through:

Hosting a WCF in a Windows Service

Up to this step:

Step 6: Install the Windows Service In this step, you install the Windows service and run it from the Services console.

  1. Rebuild the solution and open a Visual Studio command prompt.
  2. Browse to the bin directory of the project where WindowsService1.exe is located.
  3. Run the following command to install the service:

Installutil WindowsService1.exe

I've never used the Visual Studio Command Prompt before. How do I do number 2 Browse to the bin directory of the project where WindowsService1.exe is located? What do I type in after the >?

Using normal command line syntax, like cd, doesn't work, so how do I browse to a location using this tool? For example, if I type this into the Command Window cd "C:\" it returns Command "cd" is not valid.

Hmmm, I have found something ... Visual Studio Command Aliases (MSDN).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
whytheq
  • 34,466
  • 65
  • 172
  • 267

2 Answers2

10

cd does work. However, keep in mind that if the path you're trying to get to has spaces, you need quotes around it (the path). E.g.:

cd "C:\Program Files\Microsoft Visual Studio 10.0"

Also, note that the "Visual Studio command prompt" that is mentioned in Step 6 is not the "Visual Studio Command Window" - I think this is where the problem comes from. The command prompt is a separate executable that you can start by clicking Start, point to All Programs, point to Microsoft Visual Studio, point to Visual Studio Tools, and then click Visual Studio Command Prompt. Alternatively, just search "Visual Studio" in the search bar in the Start menu, and it should show up

vlad
  • 4,748
  • 2
  • 30
  • 36
  • I type this `>cd "R:\Statistics\Reporting\Miscellaneous\WcfServiceLibraryTest\WindowsService1\bin"` and it says this `Command "cd" is not valid.` – whytheq Oct 02 '12 at 21:14
  • 2
    @whytheq I think you're confusing the *command prompt* with the *command window*. Added more details. – vlad Oct 02 '12 at 21:19
  • +1 - thanks. Now when I try to run `Installutil WindowsService1.exe` I get `'Installutil' is not recognised as an internal or external command, operable program or batch file` ... If I search on the C drive I can see this Installutil.exe ...? – whytheq Oct 02 '12 at 21:41
  • @whytheq are you sure that you opened the correct command prompt? Unfortunately, the regular command prompt (i.e. the one that's built into Windows) doesn't have the correct paths set. When I search for "command prompt" at the Start button search bar, the Visual Studio command prompt is called "Visual Studio Command Prompt (2010)". As per MSDN (http://msdn.microsoft.com/en-us/library/50614e95.aspx), `installutil` should be installed automatically with Visual Studio. – vlad Oct 02 '12 at 21:48
  • - I'm using the "Developer Command Prompt for VS2012". Anyway I found a copy of `installutil` and copied it into the application's directory. So it runs now. The application wouldn't install though. `An exception occured during the Install phase. System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security` ... not much fun for a newbie ! – whytheq Oct 02 '12 at 22:10
  • @whytheq my guess is that you need to install with admin privilege if you want automated logging. To do this, right click on the Command Prompt and choose 'Run as Administrator' – vlad Oct 03 '12 at 13:00
  • I tried a different app `msbuild` and had a similar problem so this confirms that one of the environ pathway variables is missing from the VS install. Look at my screen print in [HERE](http://stackoverflow.com/questions/12703645/how-to-resolve-installutil-is-not-recognized-as-an-internal-or-external-comma) . If I put in the complete pathway to the `msbuild` app then it runs fine. So problem I'm having with `installutil` must be the Windows Service it is attempting to install: look at error message [HERE](http://stackoverflow.com/questions/12699240/windows-service-not-installing) – whytheq Oct 03 '12 at 13:54
1

The easier way to "Step 6" whytheq would be to right click on your project in Visual Studio and then click on "Open Folder in Windows Explorer". A window should pop up and you should see your "Bin" directory. Just hold down "Shift" and right click on the "Bin" directory and click "Open Command Window Here". That should open a command window right where you need to complete step 6 above!

Icemanind
  • 47,519
  • 50
  • 171
  • 296
  • +1 - I like that. Is that the same Command Window as the Visual Studio Command Prompt? Now when I try to run `Installutil WindowsService1.exe` I get `'Installutil' is not recognised as an internal or external command, operable program or batch file` ... – whytheq Oct 02 '12 at 21:39
  • 1
    It is NOT a visual studio prompt, however, [read this article](http://andrewchaa.me.uk/2012/02/18/visual-studio-2010-command-prompt-here-on-the-context-menu-of-windows-explorer/) and it will explain how to make it a VS 2010 prompt. – Icemanind Oct 02 '12 at 21:45
  • What is *"whytheq"*? – Peter Mortensen Aug 13 '21 at 15:51