Since way back I have been working with a batch file (which calls a script for COM+ shutdown) called from a post build event in Visual Studio to deploy to my development environment (note this only really works if run on the server itself - but I typically develop event system code on the server, in order to debug it). As it works fine, I never made an effort to update it with Powershell - which would be a better option in this day and age (Dominic's example will give you pretty much the same code).
Heres the batch file, which should be called with the path of the folder where the event dll and pdb is as a parameter. Eg in a post build event:
Note that this version works for 2013 - you may have to tweak the services which are stopped/started for 2011 as the dependencies changed.
@echo Stopping Tridion Services
REM stopping the services with 'net stop' instead of 'sc stop' (this is synchronous)
REM note that the other services are dependent on these two so will also be stopped
net stop TCDTransportService /Y
net stop TcmServiceHost /Y
@echo Stopping Tridion Website App Pool
appcmd stop apppool /apppool.name:"SDL Tridion"
@echo Stopping Tridion Com+ application
@echo Copying DLL and PDB to Tridion bin\Extensions folder
copy /Y %1 "D:\Tridion\bin\Extensions\"
@echo Starting Tridion Website App Pool
appcmd start apppool /apppool.name:"SDL Tridion"
@echo Starting Tridion Services
REM starting the services again with 'sc start' instead of 'net start' (this is asynchronous so faster)
REM note that the other services are dependencies of these three so will also be started
sc start TcmBatchProcessor /Y
sc start TCMPublisher /Y
sc start TcmSearchIndexer /Y
StopComPlus.vbs looks like this:
Set oCatalog = CreateObject("ComAdmin.COMAdminCatalog")
Wscript.Echo "Shutting down SDL Tridion Content Manager"
Call oCatalog.ShutdownApplication("SDL Tridion Content Manager")
Wscript.Echo "Completed shutdown process. Exiting"
Set oCatalog = Nothing
The only real difference to Dom's script is that the Tridion CM app pool is stopped and started either side of the copy, which I found necessary for 2013, and is a little bit less disruptive than a full iisreset (often on dev environments, the web app(s) are also running in IIS on the same box).