Solved

Creating Batch File to install windows service.

Posted on 2010-08-16
6
574 Views
Last Modified: 2012-05-10
Experts,

I have a windows service that I have written and I am installing it using windows InstallUtil.exe from the command line.  Every time I make a change to the code and rebuild I have to go to the command line and uninstall then reinstall again, and this is getting old fast.  Am I able to write a batch file that will accomplish the the following steps that I'm doing manually? (I am a newbie to batch files)

1. Use cmd line to navigate to the dir where my service and installutil.exe are located.
2. Type in installutil -u myservice.exe
3. Type in installutil myservice.exe
4. Window pops up asking for username and the password (two textboxes for password)

After googling, I think I got the jest of writing what I need, except for the username password part.  How would I achieve that step in a batch file?
0
Comment
Question by:P1ST0LPETE
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:deisrobinson
ID: 33446914
Capture the user input.......i.e:
http://www.robvanderwoude.com/userinput.php
0
 
LVL 10

Author Comment

by:P1ST0LPETE
ID: 33447067
@deisrobinson

I think that is still requiring me to type in the username and password each time I run the batch file correct? Is there not a way where I can just code the username/password into the batch file and allow me to not have to type anything?
0
 
LVL 11

Accepted Solution

by:
Ben Personick earned 500 total points
ID: 33447236
1. Never navigate through the command prompt, not only is this 'bad form, it will lead to yoru script failing epically at times.  Instead always call the full path to the item you wish to execute.

installutil.exe /user=uname /password=pw myservice.exe
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 10

Author Comment

by:P1ST0LPETE
ID: 33447357
Awesome Sauce QCubed:

I have the following script and it seems to be working:

ECHO
C:
cd\Applications\abcd\abcd\bin\Debug
installutil -u myservice.exe
installutil /username=machinename\username /password=pw myservice.exe
PAUSE

Do you see a problem there with how I'm navigating, or does it look ok?
0
 
LVL 10

Author Closing Comment

by:P1ST0LPETE
ID: 33447422
Thanks for the help.
0
 
LVL 11

Expert Comment

by:Ben Personick
ID: 33447955
@P1

'grats NP Mate.  Glad to help!

The reason not to navigate is if you ever change the path and then run the file again you runt he risk of executing your commands in the base directory.

Also you want to remember to use Echo Off so you have cleaner less confusing output.

Also if youa re runnign the command as the local user you are logged on as just set the username portion = to the variables %ComputerName%\%UserName%

To avoid this you should always call the full path to the command instead.

@Echo Off
Installutil -u c:\Applications\abcd\abcd\bin\Debug\Myservice.exe

Installutil /UserName=%ComputerName%\%UserName% /Password=pw "c:\Applications\abcd\abcd\bin\Debug\Myservice.exe"


0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question