sreevatsan@gmail.com
Posts: 1
Joined: Tue May 23, 2017 4:24 pm

Shortcut for Win32 service

Hey there,

I am working on a MSI installer for a Java Win32 service. I would like to have a shortcut in the Desktop that has capabilities to start/stop and restart services, the functionalities that are available from Administrative Tools -> Services. How would I go about doing this using Advanced Installer packaging?

Thanks,
Sree
Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: Shortcut for Win32 service

Hello Sree and welcome to our forums,

A service could be started or stopped by "net start" / "net stop" command line. Your scenario could be implemented by creating a desktop shortcut to a batch file contained by your package. This batch could have a selection menu for the three requested operations : start, stop, reset service

You could use this code for your batch:

Code: Select all

@ECHO OFF
C:
CD\
CLS

:MENU
CLS
ECHO 1.  Stop Service
ECHO 2.  Start Service
ECHO 3.  Restart Service

ECHO    PRESS 'x' TO QUIT
ECHO.

SET INPUT=
SET /P INPUT=Please select a number:

IF /I '%INPUT%'=='1' GOTO Selection1
IF /I '%INPUT%'=='2' GOTO Selection2
IF /I '%INPUT%'=='3' GOTO Selection3
IF /I '%INPUT%'=='x' GOTO Quit

CLS

ECHO Please select a number from the Main
echo Menu [1-3] or select 'x' to quit.
ECHO -------------------------------------
ECHO Press any key to continue

PAUSE > NUL
GOTO MENU

:Selection1
net stop "YOUR SERVICE NAME"
pause
:Selection2
net start "YOUR SERVICE NAME"
pause
:Selection3
net stop "YOUR SERVICE NAME"
net start "YOUR SERVICE NAME"
pause
:Quit
CLS
ECHO Press any key to continue
PAUSE>NUL
EXIT

You should add the BAT file as a resource in "Files and Folders" page. Then you should right click on it and go to "New Shortcut To - Installed file". Select Desktop in "Shortcut folder" field. By doing this the install will create the shortcut to your batch.

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Feature Requests”