Saturday, October 29, 2011

Appcmd.exe for IIS7


Appcmd.exe is a command line tool for managing IIS7.

Location:  %systemroot%\system32\inetsrv\

Here are the available commands:




















I needed to create some bindings for my Default Web Site. Here are the commands I used:

appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.tcp',bindingInformation='808:*']
appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.pipe',bindingInformation='*']
appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.msmq',bindingInformation='localhost']


appcmd.exe set app "Default Web Site/evals" /enabledProtocols:http,net.pipe,net.tcp,net.msmq

When running these commands I got errors like this:






This means the binding already exists. If you want to remove the existing binding and replace it, here is the command to run:

appcmd.exe set site "Default Web Site" /-bindings.[protocol='net.tcp',bindingInformation='808:*'] 

and to add back:

appcmd.exe set site "Default Web Site" /+bindings.[protocol='net.tcp',bindingInformation='808:*']

You can also use AppcmdUI:
http://blogs.iis.net/ksingla/archive/2007/04/14/appcmdui-appcmd-command-autocompletion-tool.aspx

Other useful links:
http://learn.iis.net/page.aspx/114/getting-started-with-appcmdexe/
http://forums.iis.net/t/1158284.aspx

Thursday, October 27, 2011

Batch files - useful commands

We all need from time to time to create batch files to make our work easier.
Here are some useful commands:

1. First to create a batch file open Notepad.exe and save the file as 'anything.bat'. And you have a batch file that you can edit.

2. Copy files XCOPY command:

XCOPY [source] [destination] [(optional) parameter]

Ex: XCOPY C:\test\text.txt C:\newtest\ /Y
- this will copy the text.txt file from C:\tets to C:\newtest and override it if it already exists, supressing the confirmation.

3. Stop/Start Windows Services - NET STOP / NET START commands:
NET STOP [windows service]

EX: net stop "World Wide Web Publishing Service"
net start "World Wide Web Publishing Service"

4. Rename files - REN command
REN [drive:][path]old_filename new_filename

Ex: REN C:\test\text.txt newtext.txt

5. Import .reg fiel in Registry - REGEDIT.EXE command
REGEDIT.EXE [ /parameters ] importfile.REG

Ex: REGEDIT.exe /S "C:\test\Add registry key.reg"
- this will silently import the 'Add registry key.reg' file into Registry

6. Reset IIS - IISRESET command
iisreset

To be continued...

Useful links:
http://commandwindows.com/windows7-commands.htm
http://support.microsoft.com/kb/240268
http://aumha.org/a/batches.php
http://ss64.com/nt/ren.html
http://www.robvanderwoude.com/regedit.php

Wednesday, October 26, 2011

System.InvalidOperationException: Cannot load the X.509 certificate identity specified in the configuration.

For this error,


here is a simple solution:

Make sure the following line is present for each Identity in the App.config file:


Something like this:



AddressAlreadyInUseException HTTP could not register URL http://+: Another application has already registered this URL with HTTP.SYS.


If you get this error when running a WCFServiceHost here is what you have to do:

1. Stop Debugging.
2. Go to the ServiceLibrary project -> right-click -> Properties -> uncheck the option Start WCF Service Host when debugging another project in the same solution.



3. Save.
4. Press F5 to Start Debugging again.

=> the error should not occur anymore.



Monday, October 24, 2011

F8 key to boot in Safe Mode with Networking

If your machine bluescreens and you can't start it or you need to enter Safe Mode for any other reason here is what you need to do:

1. Restart the machine;
2. Quickly press F8 to get into the Advanced Boot Options menu. It should look like this:


3. Select Safe Mode or, my favorite, Safe Mode with Networking;
4. Press Enter.


=> your computer will start in safe mode.

Tuesday, October 18, 2011

Registering and unregistering .DLL files


Open Command prompt and type: 


1. Register file:
regsvr32 <filename>.dll
or
regsvr32 <path>\<filename>.dll
where <path> is the path to the file, and <filename> is the name of the file.

2. Unregister file:
regsvr32 -u <filename>.dll
or
regsvr32 -u <path>\<filename>.dll
where <path> is the path to the file, and <filename> is the name of the file.

Friday, October 7, 2011

Install SMTP server on 2003 R2

Simple and fast way to create a SMTP server on a 2003 server.




1. Go to Control Panel -> Add or Remove Programs -> Add/Remove Windows Components -> Application Server -> Details -> Internet Information Services (IIS) -> Details -> check SMTP Service -> OK.



2. Go to Start -> Administrative Tools -> Internet Information Services (IIS) Manager -> expand server -> Right click on Default SMTP Virtual Server -> Properties -> Access -> Relay… -> select All except the list below -> OK -> Apply -> OK.



3. Test the server:
Send a manual email through telnet to confirm everything working successfully. (Telnet is also installed from Server Manager -> Add Features).

- Open Command Prompt and type: 
telnet localhost 25 (Enter key)
HELO (Enter key)
mail from: anyuser@anymailserver.com (Enter key)
rcpt to: anotheruser@anymailserver.com (Enter key)
data (Enter key)
mail test (Enter key) . (Enter key)

=> "Queued mail for delivery" message should be displayed.