Using InstallUtil.exe WIth parameters

Hi all,

Hopefully someone can arrest my slow slide into insanity. I know you can do what I want as I have done it several times before, but I cannot quite remember the syntax and I cannot find my notes that I made at the time so I am pulling my hair out as I am on a deadline.

I have written and tested a system service in VB.Net and it is all compiled into a .EXE and ready to go. I am now trying to install the service using the installutil.exe utility provided by Visual Studio (in my case at C:\Windows\Microsoft.NET\Framework\v4.0.30319). I have started a DOS window (as Administrator) and have set my current directory to the location of installutil.exe and am now typing (what I thought was) the command to install the service passing a single parameter which is the location of the Configuration File for the service (names and paths changed):

installutil.exe "D:\MyPath\MyService.exe"" ""D:\MyConfig Files\MyConfig.xml"

It's not having it - just keep getting an error back:

Exception occurred while initializing the installation:
System.ArgumentException: Illegal characters in path..

As I said, I know you can do this as I have done it several times before, and have several services configured and running the same way - just can't get my quotes right to get it working. I know it is something like the above ....

Thanks,
Steve
Steve MarshallIT ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

it_saigeDeveloperCommented:
If you are tying this into a command window, then you only need one set of quotes for each parameter that contains spaces; e.g. -
installutil.exe D:\MyPath\MyService.exe "D:\MyConfig Files\MyConfig.xml"

Open in new window

The quotes are needed because there are spaces in the path and/or filename.

-saige-
0
Steve MarshallIT ManagerAuthor Commented:
Hi Saige,

I have tried that, but it gives exactly the same error as I identified above.

Steve
0
it_saigeDeveloperCommented:
Looking at the accepted installutil parameters, there is not one explicitly defined for accepting an xml configuration file.  Try using:
installutil.exe D:\MyPath\MyService.exe

Open in new window

If your service has parameters that it accepts as a part of it's install, then you would pass the parameters *by name* to installutil; e.g. -
installutil.exe /config="D:\MyConfig Files\MyConfig.xml" D:\MyPath\MyService.exe

Open in new window

Assuming that your service installer accepts a parameter by the name of config.

https://docs.microsoft.com/en-us/dotnet/framework/tools/installutil-exe-installer-tool
http://dotnetstep.blogspot.com/2009/06/passing-parameter-to-installutil.html

-saige-
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve MarshallIT ManagerAuthor Commented:
Hi Saige,

This seems to have been a complete brain-fade on my part!! The parameter is not set via the installutil command line as I was incorrectly remembering. It is in fact set in code. I needed to implement the OnBeforeInstall in the Installer for the Service as follows:

    Protected Overrides Sub OnBeforeInstall(savedState As System.Collections.IDictionary)
        Dim parameterString As String = "D:\Config Files\MyConfig.xml"

        Context.Parameters("assemblypath") = String.Format(CultureInfo.CurrentCulture,
                                                           """{0}"" ""{1}""",
                                                           Context.Parameters("assemblypath"), parameterString)

        MyBase.OnBeforeInstall(savedState)
    End Sub

Open in new window


Your pointer to the code set me on the right path to remembering - so I have selected that as the solution.

Thanks,
Steve
0
Steve MarshallIT ManagerAuthor Commented:
Pointer to code pinged a deep memory and guided me to the right solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.