I'm trying to create a Setup project for a Windows Service to install a few components of MSMQ programatically if certain registry keys don't exist.
I figured out that I can open up a command prompt manually and type: "start /w pkgmgr /iu:MSMQ-Container;MSMQ-Server" and it will fire off the installer and install the two components I want.
When I tried to execute a command prompt programatically to do this:
public override void Install(IDictionary stateSaver)
{
// if msmq isn't installed, run a shell command to install it
if (!this.IsMsmqInstalled())
{
string command = @"start /w pkgmgr /iu:MSMQ-Container;MSMQ-Server";
Process process = new Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.Arguments = string.Format("/c {0}", command);
process.StartInfo.FileName = "cmd.exe";
process.Start();
process.WaitForExit();
process.Close();
}
base.Install(stateSaver);
}
the installer has problems. An error message pops up saying that it cannot find pkgmgr.exe, even though I'm able to run this command manually via cmd.exe and it works fine!
Interesting issues I've run into trying to resolve this.
When I run "dir C:\windows\system32\pkgmgr.exe" in a C# console app (by forking to cmd.exe), it finds the file.
When I run "dir C:\windows\system32\pkgmgr.exe" by clicking on the msi (which forks to cmd.exe), it returns File not found.
Running from inside of the msi starts up the cmd.exe located in C:\Windows\SysWOW64, while the one from the console app runs the cmd.exe found in C:\Windows\System32. Manually opening up the cmd.exe in SysWOW64 and doing a dir on pkgmgr.exe also returns
File not found!
I'm officially stumped.
RE: the suggestion above, including the full path also has that same error.
Did you ever figure this out? I'm using the same method to install IIS on Vista for users. After building a small app that calls a .CMD file with the script:
That worked... until I included it in the install package. Then it returned an error "Invalid characters in path." I have no idea what this is about, so I'm going to try putting the packages in an unattend.xml file and call it that way.
It is uncanny that there is NO information floating around how to do this straightforward thing.
IISinstallation and setuppkgmgr
- Curtis
http://ShipItOnTheSide.com - Learn to ship profitable software as a side job.
I decided to install IIS7 in a pre-install setup using the bootstrapper with Visual Studio. After many hours trying to get a .NET app to fork the "start /w pkgmgr ..." call I gave up and just put the call in a batch file. Even though there is a big ugly
CMD prompt window onscreen it does work.
Another thing, the Visual Studio bootstrapper uses a UNC command-line to launch executables:
... and the .NET Process launcher doesn't like that one bit. It returns the error: "Invalid characters in path." If anyone knows how to get around this it would be helpful, otherwise, batch files it is.
- Curtis
http://ShipItOnTheSide.com - Learn to ship profitable software as a side job.
Here is what finally worked: Instead of using "start /w pkgmgr ...", which really just tells Windows to run an app and wait for it to return before returning you to the CMD prompt, I removed the "start /w" and called Process.WaitForExit(), after calling
"pkgmgr" with the requested command line.
Process process = new Process();
process.StartInfo.FileName = Environment.GetFolderPath(Environment.SpecialFolder.System) +
"\\" + "pkgmgr.exe";
process.StartInfo.Arguments = "/iu:IIS-WebServerRole;IIS-WebServer...";
process.StartInfo.CreateNoWindow = true;
process.StartInfo.ErrorDialog = true;
process.StartInfo.UseShellExecute = false;
process.Start();
process.WaitForExit();
Hope this helps someone.
IIS7installationpkgmgr
- Curtis
http://ShipItOnTheSide.com - Learn to ship profitable software as a side job.
PhilDanger
Member
2 Points
5 Posts
Installing MSMQ Programatically
May 14, 2009 06:06 PM|LINK
Hi all.
I'm trying to create a Setup project for a Windows Service to install a few components of MSMQ programatically if certain registry keys don't exist.
I figured out that I can open up a command prompt manually and type: "start /w pkgmgr /iu:MSMQ-Container;MSMQ-Server" and it will fire off the installer and install the two components I want.
When I tried to execute a command prompt programatically to do this:
public override void Install(IDictionary stateSaver) { // if msmq isn't installed, run a shell command to install it if (!this.IsMsmqInstalled()) { string command = @"start /w pkgmgr /iu:MSMQ-Container;MSMQ-Server"; Process process = new Process(); process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardError = true; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.Arguments = string.Format("/c {0}", command); process.StartInfo.FileName = "cmd.exe"; process.Start(); process.WaitForExit(); process.Close(); } base.Install(stateSaver); }the installer has problems. An error message pops up saying that it cannot find pkgmgr.exe, even though I'm able to run this command manually via cmd.exe and it works fine!Any suggestions?
wildmoose
Participant
1466 Points
218 Posts
Re: Installing MSMQ Programatically
May 14, 2009 09:28 PM|LINK
Try putting in the full path to the EXE. Your own user context may have the source folder included but the installer might not be able to find it.
blog.andrewrivers.co.uk
PhilDanger
Member
2 Points
5 Posts
Re: Installing MSMQ Programatically
May 14, 2009 11:19 PM|LINK
Interesting issues I've run into trying to resolve this.
I'm officially stumped.
RE: the suggestion above, including the full path also has that same error.
CurtisGray
Member
7 Points
6 Posts
Re: Installing MSMQ Programatically
May 15, 2009 03:16 PM|LINK
Did you ever figure this out? I'm using the same method to install IIS on Vista for users. After building a small app that calls a .CMD file with the script:
start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-Security;IIS-RequestFiltering;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;IIS-LegacyScripts;IIS-LegacySnapIn;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI
That worked... until I included it in the install package. Then it returned an error "Invalid characters in path." I have no idea what this is about, so I'm going to try putting the packages in an unattend.xml file and call it that way.
It is uncanny that there is NO information floating around how to do this straightforward thing.
IIS installation and setup pkgmgr
http://ShipItOnTheSide.com - Learn to ship profitable software as a side job.
CurtisGray
Member
7 Points
6 Posts
Re: Installing MSMQ Programatically
May 15, 2009 08:23 PM|LINK
I decided to install IIS7 in a pre-install setup using the bootstrapper with Visual Studio. After many hours trying to get a .NET app to fork the "start /w pkgmgr ..." call I gave up and just put the call in a batch file. Even though there is a big ugly CMD prompt window onscreen it does work.
Another thing, the Visual Studio bootstrapper uses a UNC command-line to launch executables:
\\?\<path to executable file>
... and the .NET Process launcher doesn't like that one bit. It returns the error: "Invalid characters in path." If anyone knows how to get around this it would be helpful, otherwise, batch files it is.
http://ShipItOnTheSide.com - Learn to ship profitable software as a side job.
CurtisGray
Member
7 Points
6 Posts
Re: Installing MSMQ Programatically
May 28, 2009 12:59 PM|LINK
Here is what finally worked: Instead of using "start /w pkgmgr ...", which really just tells Windows to run an app and wait for it to return before returning you to the CMD prompt, I removed the "start /w" and called Process.WaitForExit(), after calling "pkgmgr" with the requested command line.
Process process = new Process();
process.StartInfo.FileName = Environment.GetFolderPath(Environment.SpecialFolder.System) + "\\" + "pkgmgr.exe";
process.StartInfo.Arguments = "/iu:IIS-WebServerRole;IIS-WebServer...";
process.StartInfo.CreateNoWindow = true;
process.StartInfo.ErrorDialog = true;
process.StartInfo.UseShellExecute = false;
process.Start();
process.WaitForExit();
Hope this helps someone.
IIS7 installation pkgmgr
http://ShipItOnTheSide.com - Learn to ship profitable software as a side job.