Content
ramblings of a coldfusion developer
Wednesday 1 September 2010
-
Filed under
Code
If your computer is like mine you have a host of things installed:
- ColdFusion
- Database server
- Web server
- Version control server
- Mail server
- ????
By default I always set all these services to disabled so when I boot my computer I don’t have to wait 30 minutes for everything to start up. And it’s possible I may not be doing any application development so why have all that stuff running if I’m not using it?
But I also don’t want to have to navigate into the Control Panel > Adminstrator Tools > Services each time I want to hack on some ColdFusion.
So let’s automate things with some simple batch scripts and make our lives easier!
In our last post we wrote a simple script to automatically shut down our PC. Fire up your favorite text editor and let’s create a few more files in the same directory:
net start "ColdFusion 8 Application Server"
REM net start "ColdFusion 8 ODBC Agent"
REM net start "ColdFusion 8 ODBC Server"
REM net start "ColdFusion 8 Search Server"
net start "World Wide Web Publishing"
net start "IIS Admin"
REM net start "Simple Mail Transfer Protocol (SMTP)"
net start "OracleServiceXE"
Save this file as cf_start.bat (or whatever you’d like to name it). This will start all our application related services using the net start command. Not sure what the service is called? Open up the services window and look under the “Name” column – that’s what you need to enter – use quotes if there are spaces in the service name as I did above with the ColdFusion related services. REM is like commented out code – it will not run. I normally don’t run my mail server but if I need to I can remove the REM statement, run the script and mail will start.
To shutdown all our services I can simply use net stop (save this as cf_stop.bat):
net start "ColdFusion 8 Application Server"
net start "ColdFusion 8 ODBC Agent"
net start "ColdFusion 8 ODBC Server"
net start "ColdFusion 8 Search Server"
net start "World Wide Web Publishing"
net start "IIS Admin"
net start "Simple Mail Transfer Protocol (SMTP)"
net start "OracleServiceXE"
You’ll notice I’ve removed all the REM statements – this will attempt to stop ALL services – and if it is already stopped – no harm done.
I also usually write a short script (cf_restart.bat) to bounce my ColdFusion servers:
net stop "ColdFusion 8 Application Server"
net start "ColdFusion 8 Application Server"
So how can you use these?
I have these stored in a /scripts directory which I then tell my keyboard launcher (Find And Run Robot) to index. So I simply hit my shortcut key (ALT+SPACE) and enter cf_start… or cf_stop… and hit enter and viola everything cranks up/shuts down. You could also write a AutoHotkey script to run these with a keyboard shortcut. Or you could automate these with a scheduled task so they are started in the morning or maybe restarted while you are at lunch!
In our next post we’ll examine some other common tasks we can automate using simple scripts.
::
Share or discuss
::
2010-09-01 ::
Jim Priest
Tuesday 31 August 2010
-
Filed under
Code
So I’ve blogged about about tools (Cron, Windows 7 Task Scheduler) to run scheduled tasks. But what exactly should you schedule?
Today let’s talk about turning your PC on and off. Do you do that manually?
I like to save trees so I power my computer off each evening. But not when I leave the office. I leave my PC running in case I need to remote into it from home. But after 10pm or so it’s unlikely I’ll be dialing in – so the computer can be turned off – but I’m not driving back to work to hit the power button! :)
First grab a copy of PSTools from SysInternals. SysInternals has a load a great tools and PSTools itself contains several useful utilities but we’re interested in
PsShutdown – shuts down and optionally reboots a computer
Download PSTools, copy the files somewhere in your system path (C:\Program Files\ etc) so that you can open a command prompt and enter psshutdown and it will run.
Next lets create a simple batch file to call this:
# Uses psshutdown from SysInternals (now Microsoft)
PsShutdown.exe -o -f -k
Save this file as shutdown.cmd
There is a huge list of options available for PsShutdown but we just need a few:
- -o Logoff the console user.
- -f Forces all running applications to exit during the shutdown instead of giving them a chance to gracefully save their data.
- -k Poweroff the computer (reboot if poweroff is not supported).
When I leave the office I usually close everything but the -f will force any open applications to quit, and -k will actually power off the machine.
So I simply setup a scheduled task to run this batch file every day at 10:00PM and save some energy in the middle of the night.
In The Morning
Do you roll into work – power on your PC and then spend 10 minutes gabbing to co-workers and grabbing coffee? When I roll into the office my computer is on and ready for me to get to work! Every computer may not have this option but most Dell’s I’ve used have an option within the BIOS to power-on the computer at a specific time. So I have my PC set to crank up at 7:00AM so when I crawl into the office at 8:00 my PC is ready to go.
If your computer BIOS doesn’t have a power-on option and you are using Windows 7 you could possibly put your computer to ‘sleep’ and then use the new Task Scheduler to ‘wake up’ the computer using “Wake the computer to run this task” condition.
In the next entry we’ll talk about automating all the services you have running on your machine.
2 comments ::
Share or discuss
::
2010-08-31 ::
Jim Priest
Monday 30 August 2010
-
Filed under
Code
Did you miss my CFUnited presentation because you couldn’t step into the room because it was jam packed?
I’ll be giving my “Digging Into The Developer Toolbox” presentation on the CFMeetup!
Right now I’m tentatively schedule for September 9th @ 6:00PM.
Every developer has their basic toolset – a robust IDE, source control and a good bug tracker. But what else is in your toolbox?
In this presentation I’ll explore some additional tools that can increase your productivity and allow you to concentrate on developing applications.
Some of the tools we will explore include:
- Autohotkey – save time and type less! Autohotkey can do simple text replacements and well as complex GUIs!
- Keyboard Launchers – clean up that messy desktop and stop hunting for icons!
- Virtual desktops – Now that your desktop is clean – organize your applications into task focused areas.
- Cron – replace the unreliable Windows Scheduled task with a simple to use task scheduler.
- Clipboard managers – a clipboard manager can keep a long running history of what you type so you don’t have to. and more…
All of these are free, open-source and for the most part have similar equivalents available on all three platforms – Windows, Mac and Linux.
In this presentation we will focus on Windows.
::
Share or discuss
::
2010-08-30 ::
Jim Priest
Thursday 26 August 2010
-
Filed under
Code
Check out Packt’s 2010 Open Source Awards! Submit your votes in popular categories:
- Open Source CMS … hmmm… what great open source ColdFusion based CMS do I know about… oh yeah – Mura CMS!
- Hall of Fame CMS
- Most Promising Open Source Project
- Open Source E-Commerce Applications
- Open Source JavaScript Libraries
- Open Source Graphics Software
There are a LOT of open source CFML projects – have you looked at RIAForge lately or maybe Brian Rinaldi’s open source list or his Open Source Update?
Pick your favorite open source CFML project and vote today!!
::
Share or discuss
::
2010-08-26 ::
Jim Priest
Friday 20 August 2010
-
Filed under
Code

Windows 98 Scheduled Tasks
On Window XP the ability to reliably schedule anything was severely limited and problematic. Tasks wouldn’t run if you were logged out, and if you changed your password tasks would fail with authentication errors unless you remembered to update each task.
Given these limitations I searched for an alternative and in previous posts I’ve talked about using Cron as a viable replacement for Windows Scheduled tasks.
This has worked great… on Windows XP at work. Recently while I was preparing for my presentation at CFUnited I discovered that the particular Cron package I was using ( nnCron ) did not work on Windows 7. I discovered this the night before my presentation!
On a whim I looked to see what the scheduler looked like in Window 7 and was presently surprised in the improvements made by Microsoft!
In Windows 7 you can hit the Windows menu and simply type “Task” and you will see an entry for “Task Scheduler”.
The interface has totally been revamped. Don’t panic – it is fairly intuitive after clicking around a bit.

Wndows 7 Task Scheduler
The interface is split into 3 panes. The left most pane is the list of tasks. The middle pane is where the task details are defined and the right pane is a quick menu to frequent actions.
To get started – hit Create Task in the right pane.

Right Pane - Action Menu
Create Basic Task… will allow you to quickly setup a task with limited options. Create Task… will give you more control.

New Options
The Create Task pane has several tabs – and clicking through them we can see many new option not available in the old Scheduled Tasks. You can now run tasks whether you are logged in or not.

New Options
There is too much to cover in one blog post but if you are using Windows 7 take a few minutes to click through and explore all the features. Between the available triggers (at log on, startup, on event, on lock, etc) and the actions (start program, send mail, display message) and conditions (on AC power, idle, etc) you should be able to schedule just about anything!
1 comment ::
Share or discuss
::
2010-08-20 ::
Jim Priest