cmd
to start what in the old days we used to call a "DOS box" and run something like this: NET START postgresql
NET STOP postgresql
On Windows 7, however, it is a little more complicated than that. The problem is that, if you simply run
cmd
and try to start or stop a service, you will most probably get this error message:System error 5 has occurred.
Access is denied.
To overcome this, you need to start a "DOS box" as Administrator since, to the best of my knowledge, one cannot run a single command as Administrator inside the command prompt window opened under an account with fewer rights (there are no
su
and sudo
commands in Windows). One option is to click the "Start" button, type
cmd
into the "Search programs and files" box and hit Ctrl+Shift+Enter instead of just Enter. This will start a "DOS box" with administrative rights. Now, in this DOS box, you can run one of these commands (replacing the "9.1" with whatever your actual version of PostgreSQL is): NET START postgresql-9.1
(for the 32-bit version)NET STOP postgresql-9.1
(for the 32-bit version)NET START postgresql-x64-9.1
(for the 64-bit version)NET STOP postgresql-x64-9.1
(for the 64-bit version)Of course, you can also start and stop other services like that. For example, run
NET START MySQL
to start MySQL database server NET STOP MySQL
to stop MySQL database server NET START Apache2.2
to start Apache 2.2 web server.NET STOP Apache2.2
to stop Apache 2.2 web server.If you are a slave to convenience, there is another way: create a shortcut to start the DOS box as Administrator. Here are the steps:
- Right-click anywhere on your desktop.
- From the drop-down menu select "New", then - "Shortcut".
- In the first "Create Shortcut" dialog box, type in
cmd
and click "Next". - In the next "Create Shortcut" dialog box, give your new shortcut a meaningful name (e.g., "CMD as Admin" or "DOS box as Admin"). Click "Finish". The new shortcut will be created.
- Right-click the newly created shortcut and select "Properties" from the drop-down menu.
- On the "Shortcut" tab (opens by default), click the "Advanced..." button.
- In the pop-up dialog box, check the "Run as administrator" checkbox. Click the "OK" button.
- Click the "Apply" button. Then - the "OK" button.
If you are really lazy, like yours truly, there is yet another way: create desktop shortcuts for starting and stopping PostgreSQL. Here is how (pretty much the same as above):
- Right-click anywhere on your desktop.
- From the drop-down menu select "New", then - "Shortcut".
- In the first "Create Shortcut" dialog box, type in
NET START postgresql-9.1
(replace "9.1" with "x64-9.1", "9.0" or whatever your version of PostgreSQL is). Click "Next". - In the second "Create Shortcut" dialog box, give your new shortcut a meaningful name (e.g., "Start PostgreSQL Server"). Click "Finish". The new shortcut will be created.
- Right-click the newly created shortcut and select "Properties" from the drop-down menu.
- On the "Shortcut" tab (opens by default), click the "Advanced..." button.
- In the pop-up dialog box, check the "Run as administrator" checkbox. Click the "OK" button.
- Click the "Apply" button. Then - the "OK" button.
- Create another shortcut exactly as the one above. Just replace "NET START" with "NET STOP" and call it something like "Stop PostgreSQL Server".
All of the above should also apply to Windows Vista.
10 comments:
You are da' man.
You are welcome, polandroide.
Thanks man.Good work
You are welcome. Glad to save others the pain of learning the hard way.
Thank you so much for your post. It works!
You are most welcome!
Thank you so much :)
You bet!
it works perfectly. thanks
You are welcome, David.
Post a Comment