Solved

Creating Batch File to install windows service.

Posted on 2010-08-16
6
577 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 13

Accepted Solution

by:
Ben Personick (Previously QCubed) 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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
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 13
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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

707 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