Solved

Creating Batch File to install windows service.

Posted on 2010-08-16
6
565 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
We have adopted the strategy to use Computers in Student Labs as the bulletin boards. The same target can be achieved by using a Login Notice feature in Group policy but it’s not as attractive as graphical wallpapers with message which grabs the att…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now