[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Creating Batch File to install windows service.

Posted on 2010-08-16
6
Medium Priority
?
582 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 14

Accepted Solution

by:
Ben Personick (Previously QCubed) earned 2000 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this 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…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

649 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