Solved

Creating Batch File to install windows service.

Posted on 2010-08-16
6
569 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

26 Experts available now in Live!

Get 1:1 Help Now