I have an windows application developed in C#, I need to install it on a PC which will just have the Operating System and .Net Framework installed. Now I have to give an option to install SQL Server 2008 R2 Express edition on that PC, using this windows application. I have coded for installing/uninstalling a windows service, but struck with sql server installation. could someone help me out in doing this.
Follow the guidelines in How to Embed SQL Server Express in an Application. It covers everything you need, including pickiing up the right distribution, choosing an appropriate installation method (wpi vs. setup.exe) and how to configure the installation. the wiki even has a C# code on how to detect a previous Express instalation, how to invoke the WPI (Web Platform Installer) for SQL Express from C#:
System.Diagnostics.Process.Start(
#"C:\Program Files\Microsoft\Web Platform Installer\webplatforminstaller.exe",
" /id SQLExpress");
or using the "wpi://" URL handler:
System.Diagnostics.Process.Start("wpi://SQLExpress/");
or using the Web App Galery:
System.Diagnostics.Process.Start(
"http://www.microsoft.com/web/gallery/install.aspx?appsxml=&appid=SQLExpress");
and, finally, using the SQL Express setup (recommended for advanced configuration):
System.Diagnostics.Process processObj =
System.Diagnostics.Process.Start(#"c:\temp\sqlsetup\setup.exe",
#"/q /Action=Install /Hideconsole /IAcceptSQLServerLicenseTerms=True
/Features=SQL,Tools /InstanceName=SQLExpress
/SQLSYSADMINACCOUNTS=""Builtin\Administrators""
/SQLSVCACCOUNT=""DomainName\UserName"" /SQLSVCPASSWORD=""StrongPassword""");
and it has the full list of setup parameters.
You can use msiexec.exe. You can simply install an MSI by passing the MSI path. Using command you can set whether to show UI during the installation or make it a silent installation,
string installCommandString = "/i {0} /qn";
/qn: Set user interface level: None
/qb: Set user interface level: Basic UI
/qr: Set user interface level: Reduced UI
/qf: Set user interface level: Full UI (default)
C# code
string installCommandString = "/i {0} /qn";
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
process.StartInfo = startInfo;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardError = true;
startInfo.FileName = "msiexec.exe";
startInfo.Arguments = string.Format(installCommandString, "SQL Server MSI Path");
process.Start();
If you are using the standard MSI installer, built into Visual Studio then there is an option to set pre-requisites.
Right click the MSI
Select properties
Select prerequisites
Near the bottom there is an option for SQL Server Express and you can specify where to get the components from - vendor, or from a location on your servers.
Related
I used C# with a console program to create a new cmd process, did not redirect stdin or stdout, so I could type into the command line from here.
(I was having trouble using telnet from there, so this step was just an investigation.)
Able to type into the window and receive output.
When I switched to c:Windows\system32, typing dir te*.exe shows nothing.
In another command prompt I created directly, I see the file (telnet.exe).
Any suggestions about what is wrong?
{
ProcessStartInfo startInfo = new ProcessStartInfo(#"cmd.exe");
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.CreateNoWindow = false;
startInfo.Arguments = host;
using (Process p = new Process())
{
p.StartInfo = startInfo;
p.Start();
}
}
Since Windows 7, I believe, you have to install Telnet as a Windows Feature.
Here you have a guide to enable Telnet on Win 7, but it's applicable to Win 8.1 as well as Windows 10.
Just in case you can't read the site, the steps are:
Go to Control Panel -> Programs -> Turn Windows Features on or off -> Scroll down until you find the Telnet Client option
Based on the above article, looked at project build properties.
Platform target was set to x86.
Changing to "Any CPU" at least allows me to see the program!
BTW I have looked for the answer for several days before posting this, but in the margin in related - "C# New process created cannot access certain files" gave me the info - after I created this question
Thanks, heuristics!
This is a really devious one. When you are using windows explorer or opening a command prompt directly, you are starting a 64-bit process. When you are starting the "cmd.exe" with Process.Start(), you will get the same version as the process that's starting it. In your case, you are creating a 32-bit process, so you get the 32-bit version of the command prompt. If you change your project to create target x64, you will see the files!
Why is this so? Because, depending on whether you are accessing System32 through a 32-bit or 64-bit app, you will actually be accessing different System32 folders! For more on this, follow this link:
https://superuser.com/questions/330941/some-files-in-system32-not-accessible-outside-explorer-on-windows-7
Sometimes there is a PC that doesn't have IIS. Either it disabled or either it not installed. In this case I need to enable it myself according to those steps.
I'm trying to create application that will check if IIS is enabled (installed), and if not it will enable (install) it.
I tried to install IIS using .msi files from here, but it asking me to follow those stpes before the installation.
I tried to use Advanced Installer but apparently it installing the IIS 8.0 Express but still it keeps the IIS disabled.
What I need to do to enable IIS programmatically? It is also acceptable if I'll need to run an IIS installation file to make it done (I didn't find the right one).
You can install IIS via the command line. The following command will install IIS on Windows 8 (you can edit this to add/remove certain features. It's just a command I've used in the past):
PkgMgr:
start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-ApplicationDevelopment;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-NetFxExtensibility45;IIS-ASPNET45;IIS-NetFxExtensibility;IIS-ASPNET;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-RequestMonitor;IIS-Security;IIS-RequestFiltering;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;IIS-ManagementConsole;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI
DISM:
START /WAIT DISM /Online /Enable-Feature /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-ASP /FeatureName:IIS-ASPNET /FeatureName:IIS-BasicAuthentication /FeatureName:IIS-CGI /FeatureName:IIS-ClientCertificateMappingAuthentication /FeatureName:IIS-CommonHttpFeatures /FeatureName:IIS-CustomLogging /FeatureName:IIS-DefaultDocument /FeatureName:IIS-DigestAuthentication /FeatureName:IIS-DirectoryBrowsing /FeatureName:IIS-FTPExtensibility /FeatureName:IIS-FTPServer /FeatureName:IIS-FTPSvc /FeatureName:IIS-HealthAndDiagnostics /FeatureName:IIS-HostableWebCore /FeatureName:IIS-HttpCompressionDynamic /FeatureName:IIS-HttpCompressionStatic /FeatureName:IIS-HttpErrors /FeatureName:IIS-HttpLogging /FeatureName:IIS-HttpRedirect /FeatureName:IIS-HttpTracing /FeatureName:IIS-IIS6ManagementCompatibility /FeatureName:IIS-IISCertificateMappingAuthentication /FeatureName:IIS-IPSecurity /FeatureName:IIS-ISAPIExtensions /FeatureName:IIS-ISAPIFilter /FeatureName:IIS-LegacyScripts /FeatureName:IIS-LegacySnapIn /FeatureName:IIS-LoggingLibraries /FeatureName:IIS-ManagementConsole /FeatureName:IIS-ManagementScriptingTools /FeatureName:IIS-ManagementService /FeatureName:IIS-Metabase /FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ODBCLogging /FeatureName:IIS-Performance /FeatureName:IIS-RequestFiltering /FeatureName:IIS-RequestMonitor /FeatureName:IIS-Security /FeatureName:IIS-ServerSideIncludes /FeatureName:IIS-StaticContent /FeatureName:IIS-URLAuthorization /FeatureName:IIS-WebDAV /FeatureName:IIS-WebServer /FeatureName:IIS-WebServerManagementTools /FeatureName:IIS-WebServerRole /FeatureName:IIS-WindowsAuthentication /FeatureName:IIS-WMICompatibility /FeatureName:WAS-ConfigurationAPI /FeatureName:WAS-NetFxEnvironment /FeatureName:WAS-ProcessModel /FeatureName:WAS-WindowsActivationService
In C#, you can create a Process that executes this command like so:
string command = "the above command";
ProcessStartInfo pStartInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
Process p = new Process();
p.StartInfo = pStartInfo;
p.Start();
You tag your question with InstallShield so I mention that later versions of InstallShield have support for enabling windows features:
Enabling Windows Roles and Features During a Suite/Advanced UI Installation
That said, I don't typically like to do this because you are really be intrusive with the configuration of the PC. I prefer to author a check that the required features are installed and block if they aren't.
Another thought is that ASP.NET 5.0 now supports self hosting as have other technologies such as WCF in the past. It might make sense to simply ditch the need for IIS and kill the problem that way.
Regarding your experience with Advanced Installer. You ended up with IIS Express installed because you used our predefined support for prerequisites. You should have been using the predefined support to install Windows Feature Bundles.
Using this support you can easily select which OS feature should be enabled and also set custom conditions. On our YouTube channel you can find examples/tutorials:
in the following example you see exactly how IIS is configured for enabling
here is also a more generic video, with a walkthrough over the built-in support from Advanced Installer for enabling Windows Features
You can install IIS from command line. First you need to enable ASP.NET 3.5:
IIS-ASPNET;IIS-NetFxExtensibility;NetFx4Extended-ASPNET45
or 4.5:
IIS-ASPNET45;IIS-NetFxExtensibility45;NetFx4Extended-ASPNET45
After that you can install IIS8, basically like IIS7. Checkout the IIS7 instalation http://www.iis.net/learn/install/installing-iis-7/installing-iis-from-the-command-line
I use C# and need to install SQL Server 2005 Express edition in silent mode in my project and use code below, but for the first time, SQL Server do not install correctly . Sql database engine do not install.. When I uninstall SQL Server 2005 Express edition from windows and install it from my project, it correctly installs.
What's wrong in my project ?
ProcessStartInfo psSqlServer = new ProcessStartInfo(Application.StartupPath + "\\SQLEXPR\\setup.exe ", "/qn ADDLOCAL=ALL INSTANCENAME=MSSQLSERVER SECURITYMODE=SQL SAPWD=123 SQLAUTOSTART=1 DISABLENETWORKPROTOCOLS=0");
Process pSqlServer = Process.Start(psSqlServer);
pSqlServer.WaitForExit();
Process pro = new Process();
pro.StartInfo.FileName = Application.StartupPath + "\SQLEXPR\setup.exe";
pro.StartInfo.Arguments = "/qs ADDLOCAL=ALL INSTANCENAME=MSSQLSERVER SECURITYMODE=SQL SAPWD=123 SQLAUTOSTART=1 DISABLENETWORKPROTOCOLS=0";
pro.StartInfo.CreateNoWindow = true;
pro.Start();
pro.WaitForExit();
I need to write code to download and run a program, e.g. notepad++ (npp.5.9.3.Installer.exe) this can be found on the web.
I run it with the ProcessStartInfo class. However when I normally execute the notepad++ installer, it will show me a few steps before actually installing, like choose language, path etc.
Is there any way to programatically skip these steps, and install the software? I hope my question is clear. If it helps, I also attach the method that so far only starts the installer
private int RunFile()
{
ProcessStartInfo psi = new ProcessStartInfo(GetFileFullPath());
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.CreateNoWindow = true;
using (Process process = Process.Start(psi))
{
process.WaitForExit();
if (process.HasExited)
return process.ExitCode;
}
}
Shall I pass some arguments for this to work?
Thank you in advance.
Regards,
Use npp.5.9.3.Installer.exe /S for unattended installation of notepad++, and %ProgramFiles%\Notepad++\uninstall.exe /S for uninstall.
There are some installers which supports -s or -silent switches which means that when you install a software by passing -s switch to installer and it will silently install with default options. Try to find out whether your installer supports that or not
you have to drive the installation emulating the user. It is possible send kind of command(message) to the other window from a C# application
have a look at the below
http://social.msdn.microsoft.com/forums/en-US/winforms/thread/345d85e8-cc5f-4508-b3f2-74ee43521169/
Interact with other desktop-applications in windows using C# winforms
A wellwritten installer have options for silent installs with no user interface. If the installer is an .msi file there are options that can be passed to msiexec to make a silent install.
For other install systems there are sometimes options to. Automating installations without user involvement is a common task for system administrators, so if you have questions on a specific installation package I would suggerst asking at ServerFault or AppDeploy. Unfortunately there are many bad installation programs out there that doesn't support silent install.
This will ONLY depend on the installer (npp.5.9.3.Installer.exe). You have to search if the installer provides options that can be used in command line, such as silentinstall.
EDIT: You can use the /S (capital S) option for Notepad++ to perform a silent install.
I have some trouble installing Management Studio 2008 Express through C#-Code.
The code looks like this:
using (Process MMSInstall = new Process())
{
var psi = new ProcessStartInfo(PathExe.FullName, "/qs /Features=SSMS /Action=Install");
MMSInstall.StartInfo = psi;
MMSInstall.Start();
MMSInstall.WaitForExit();
}
PathExe is a FileInfo-Instance.
But the installation always fails:
Exception type: Microsoft.SqlServer.Setup.Chainer.Workflow.NoopWorkflowException
Message:
No features were installed during the setup execution. The requested features may already be installed. Please review the summary.txt log for further details.
When installing via command prompt
C:\>SQLMANAGEMENTSTUDIO_X86_DEU.EXE /qs /Features=SSMS /Action=Install
everything works fine.
I looked through the logfiles (Detail.txt), and spottet a difference:
When running from the command prompt, 'Setting: MEDIALAYOUT' is set to 'Advanced' (pastebin.org/36222), when installing from my little C#-App it's set to 'Core' (pastebin.org/36221)
I tried to append /MEDIALAYOUT=Advanced to the ProcessStartInfo-Arguments in my code, but this options is ignored. I don't know what this parameter does, and I could not find any documentation about it.
Any ideas how to solve this or where to look for?
I am testing on Windows Vista Ultimate SP1
instead of calling the executable directly call %windir%\system32\cmd.exe
Cmd has a /C switch which allows you to pass in a command to run. So you'd pass in '/c "SQLMANAGEMENTSTUDIO_X86_DEU.EXE /qs /Features=SSMS /Action=Install"'
as a parameter.