Bug #53017 Start/stop of services is not working properly depending on Windows admin level
Submitted: 21 Apr 2010 0:26 Modified: 24 Jan 2011 20:03
Reporter: Roel Van de Paar Email Updates:
Status: Closed Impact on me:
Category:MySQL Enterprise Monitor: Installing Severity:S2 (Serious)
Version: OS:Microsoft Windows
Assigned to: BitRock Merlin CPU Architecture:Any

[21 Apr 2010 0:26] Roel Van de Paar
Start/stop of services does not give error message if non-admin account is used:

C:\Users\Roel>"C:\Program Files\MySQL\Enterprise\Monitor\mysqlmonitorctl.bat" stop


See attached video.

How to repeat:
Click start/stop service icons, observe quick cmd window popup, but nothing happens with the actual service.

Suggested fix:
Check in mysqlmonitorctl.bat if the service was stopped successfully and report if not. Normally, this should be easy doing something like this:

@echo off
net stop MySQLEnterpriseTomcat
if errorlevel 1 goto error
goto noerror
echo Error
goto end
echo No Error

However, this does not work for the "MySQLEnterpriseTomcat" service, likely because it does not stop in the correct way (/takes a while for it to shutdown). The same script works fine for checking a stop of a mysqld service for instance.
[21 May 2010 4:25] Roel Van de Paar
Some ideas:

#1 Can the shortcut not be changed?

   If I go (on the icon): right-click > properties > shortcut > advanced > tick "run as administrator"

   It seems to save this inside the .lnk file:

    Directory of C:\ProgramData\Microsoft\Windows\Start Menu\Programs\MySQL\MySQL Enterprise Monitor\Services

   21/05/2010  10:05 AM    <DIR>          .
   21/05/2010  10:05 AM    <DIR>          ..
   21/05/2010  02:06 PM             2,382 Start MySQL Enterprise Monitor services.lnk  < notice the changed time
   21/05/2010  10:05 AM             2,060 Stop MySQL Enterprise Monitor services.lnk

   As such, is it not possible for the installation process to copy in such an lnk file immediately?

#2 For doing things inside an exe, one could use AutoIT v3, it's ideal for creating small .exe's for things like this: http://www.autoitscript.com/autoit3/index.shtml
[21 May 2010 4:28] Roel Van de Paar
Btw, for making popup warnings autoit3 can be used as well. It's really ideal for scripting installation things like this in Windows.
[28 May 2010 10:39] BitRock Merlin
Patch sent to Andy.
[7 Jun 2010 23:37] Enterprise Tools JIRA Robot
Andy Bang writes: 
In build
[21 Jun 2010 14:41] Enterprise Tools JIRA Robot
Carsten Segieth writes: 
tested on Win7 (tyr53-vm3) in and the problem exists:
- service is stopped
- click on "Start MySQL ... service"
- for a very short time the a black window is visible
- service is not started
- no other message is shown
- the same user has no problems with starting / stopping the service from the Windows Service manager
[21 Jun 2010 15:05] BitRock Merlin
Hi Carsten,

We can not reproduce on our side. Could you heck if the "mysqlmonitor.bat" file contains the following section?

rem -- Check Admin privileges
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Bitrock /d 1
goto answer%errorlevel%
goto endNoAdmin
start /MIN reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Bitrock /f

Could you check if you can modify this registry key using a regular user without admin privileges? Thanks.
[8 Jul 2010 21:24] Carsten Segieth
tested with on a Win7 32bit system, logged in as a user which is definitly a member of the Administrators group: 

- the section mentioned above is part of the .bat file

- clicking on the "Start ... services" link opens a black command box showing the "no Admin" message (btw, will this text also be translated to JP ?):

  Start MySQL Enterprise Monitor Services
  You do not have Administrator privileges. Please run the command as Administrator user.
  Press any key to continue.

- the given key could be added and deleted from a DOS prompt, but only if this was right-click-started "as admin" (the command prompt then showed "Administrator: cmd" as title line instead of "cmd" when not started with right-click).

- simply starting a command prompt, e.g. with "cmd" from the "Run menu" and the RegDB could not be changed (all logged in as the same user), message is: "ERROR: Access is denied."

- starting "regedit" in UI mode it was no problem to add the given value to the RegDB

- starting the shortcuts with right-click "as administrator" works fine, services are started/stopped, where one can watch progress with the "black boxes" that are started

- I tried to change the properties of the shortcuts to enable the "run as admin" checkbox, but this was not possible, the field was greyed out.
[8 Jul 2010 21:31] Carsten Segieth
- logged in as a 'simple user' I could not add the RegDB with the given value from command line

- trying the same in 'regedit' in UI mode I can browse to "Environment" but when trying to add a value I get

  Error Creating Value:
  Cannot create value: Error writing to registry.
[9 Jul 2010 10:38] BitRock Merlin

Right, that is the implemented solution: the command prompt shows the message if the user does not have admin privileges. The user should start the services as Administrator. Our understanding is that this issue is resolved. Please let us know if this is the correct approach.
[9 Jul 2010 11:42] Carsten Segieth
from my view it would be very useful for admin users if the "run as admin" is selected for the shortcut. Is this possible when the shortcuts are created by the installer?

A non-admin user then would be asked for admin credentials, but an admin could use the shortcuts as they were installed.
[11 Jul 2010 21:51] Roel Van de Paar
"from my view it would be very useful for admin users if the "run as admin" is selected for the shortcut. Is this possible when the shortcuts are created by the installer?"

++1, see the [21 May 6:25] note on .lnk files above
[29 Jul 2010 11:25] BitRock Merlin
Patch sent to Andy.
[29 Jul 2010 23:22] Enterprise Tools JIRA Robot
Andy Bang writes: 
In build

If it tests OK, please put this back to Patch Pushed for 2.3 testing.
[24 Jan 2011 20:03] John Russell
Added to 2.2.3 change log:

When starting or stopping MySQL Enterprise Monitor services on
Windows systems, no error message was issued if the user account did
not have administrative privileges. Now, an error message is shown in
this case when starting or stopping the services from the command
line. When you use the Windows shortcut, you are prompted for
administrator credentials if necessary.