How can I change features in Windows Vista programatically? - powershell

I'm looking for a way to programatically change features ("Programs and Features" -> "Turn Windows Features on or off") in Windows Vista (and newer Redmond OS, e.g. Server 2008).
Ideal solution would be in the form of a Powershell script (Get-Features, Set-Features), however any pointers to MSDN/other documentation would be very welcome! (my initial quick Google/StackOverflow search came up empty).
Having an automatic way to turn features on or off would allow me to automate computer setup for different scenarios. For example, to develop ASP.NET applications using IIS a bunch of IIS features need to be installed that are not installed by default. My current process of "make sure at least the features shown in this screenshot are checked" leaves a lot to be desired.

I just found an extension that works for Windows 7. "PowerShell module to Add/Remove Windows 7 features" - https://psclientmanager.codeplex.com/

in windows server 2008, there is the ServerManagerCmd command. This can install IIS with or without the subfeatures you want. You can also install/uninstall most of the major Windows features.
You can setup your server the way you want then run ServerManagerCmd -query template.xml. This exports the configuration to an Xml file.
You need to transform the file to prepare it for use on other servers
Copy the transformed file to the server you want to configure and run ServerManagerCmd -inputPath transformTemplate.xml

The way to do this in Vista and Windows 2008 is with the PKGMGR command line tool. Search MSDN for this tool to find a list of features/packages.

It looks live Powershell V2 on Server 2008 R2 (Beta) has a module that does exactly this. Let's hope Windows 7 will have this functionality as well...
For more details, see Managing Server Features with PowerShell Cmdlets on Windows 2008 Server R2 Beta

There's unfortunately not a set of cmdlets, yet, nor is there anything in WMI or any other easily-accessible area. Interestingly, Server Core's script-based role management features will only work on Server Core :). Windows 7 may bring some relief in this regard - but it also might not. In the meantime, you're pretty much left with the native Win32 APIs mentioned in the other answer.
As an aside, I should point out that MS deliberately doesn't want applications installing major OS features due to the security considerations. Adding IIS isn't something done lightly, and it brings with it security considerations and responsibilities. Witness MS' own application setups, which check for pre-reqs like that, but do not offer to install them for you. While I understand wanting to make your app setup as painless as possible, there's also damage to be done in putting major functionality into the OS under someone's nose :). I personally would prefer that apps err on the side of caution, tell me what they need, and let me make the decisions about how and what to install things - especially major functionality that will open ports and be able to execute arbitrary code, like IIS.

Related

Comprehensive installer solution for solution targetting multiple platforms

I am developing an Outlook plugin solution that involves the plugin itself and a windows application working in tandem.
The plugin targets multiple versions of Outlook - 2007, 2010 and 2013.
The windows app uses different libraries for x86 and 64 bit processors.
Of course there are dependencies of both the plugin and the app.
In addition to pure installation, I would like to make automatic updates possible. It could be something as simple as custom code in the windows app to check for updates in a predefined location. But I would like to know my options.
The solution I have in mind right now, and which I would like to ask the SO community to evaluate is as follows:
Separate Windows Setup Projects (producing MSI files) for each combination of application and configuration (This could be as many as 8 different msi files)
One common bootstrapper project, detecting current system configuration and installing prerequisites and selected msis.
MSIs would not have prerequisites embedded in them, only the uber-installer/bootstrapper would have those.
Am I missing something? Is this solution viable? Are there third party alternatives to Windows Setup Projects that would make my life easier? Full featured Install Shield maybe?
In case this actually is helpful for someone, the solution I went with is the incredibly customizable installer solution: InstallMate 7 by Tarma.
You can find out more from their website, but the features that got me are:
Built in support for x86 and x64
Customizable prerequisites
Stand-alone update tool also provided by Tarma, which simplifies
automatic updates a lot.
PRICE! Forget about spending 5K on similar features elsewhere.

Automated Software deployment through SCCM 2012 using wmi

I was been looking for an option to automated deployment(Installation) of software in the client machines using SCCM 2012 by making calls to WMI classes through code. I have found the following URL
http://www.sepago.de/e/david/2012/03/17/microsoft-configuration-manager-2012-and-powershell-ae-create-deployments
But this only advertises the packages available for install. I want something that would allow me to actually install the software. Hope my query was clear.
Regards
Tiklu
Start-CMApplicationDeployment
Start-CMPackageDeployment
Start-CMTaskSequenceDeployment
And with the -DeployPurpose<DeployPurposeType> parameters set it to Required
You can't do it with Start-CMSoftwareUpdateDeployment.
I'd like to suggest the Total Software Deployment software for remote software installation. This tool is a new alternative to SCCM. It may be a bit less functional in the current version, but I beleive that it will develop into something bigger soon.

How does Win32_Product work?

While working on an auditing project I came across different problems regarding software and licenses. My project runs on Linux with Perl and I successfully retried remote machine software via both SNMP and WMI. The big issue is that the two protocols return quite different results. For instance one may find a program and the other may not, and vice versa.
I know that SNMP retrieves software wich have a related uninstall key on (correct me if I am wrong):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
But what about Win32_Product? This is what the documentation says about:
The Win32_Product WMI class represents products as they are installed
by Windows Installer. A product generally correlates to one
installation package.
What does that mean? And, last but not least, is there a way to improve how installed software are retrieved? I mean if I lookt at my installed software from the control panel and confront results with SNMP and WMI there are a lot of wierd things.
EDIT: Just a quick update, I developed a couple of programs in .NET C# that I installed on many computers. Too bad neither WMI and SNMP find them out. I installed these programs with the usual Visual Studio generated setup. Any hints?
People basically use WMI to query various system parameters. WMI exposes a lot of interfaces which one can leverage. It is mostly used with VBScript but one can also use C++/COM or C# to interact with it. This Wikipedia article can give you a detailed explanation about WMI and then you may understand what Win32_Product Class does. This is another great article and a must-read for someone beginning to work with WMI.
Also go through these articles without fail:
Retrieving a CLASS
Retrieving an Instance
Retrieving part of an Instance
Accessing a Qualifier
These articles will give you a good understanding of WMI concepts.
As far as Windows installer is concerned:
Windows installer is based on Server-Client architecture. The Windows Installer is actually a Windows Service. The various features that Windows installer supports has made it the most standard method of application life-cycle management. The Basic MSI(there is nothing Basic about it) package with the .msi extension is used to package and distribute apps.
The Basic MSI package is basically a DATABASE. The application binaries and other stuff may be packaged as CAB files and included in the MSI package or may exist outside of it.
This is known as TRANSACTIONAL install method. The Application Packaging developer just has to fill in the various tables in the database and the Windows Installer engine takes care of everything else. This may seem or sound easy but is very difficult and needs a lot of knowledge.
When the application is installed on to any sytem, Windows Installer writes all the Registry keys needed for proper management of all resources installed on to the system. As the life-cycle of an application is managed by Windows Installer, it can easily support:
1) Repair
2) Resilience
Once you go through all this, you may have a better idea of all the parties involved in your case. Then you will have clearer questions(or may not!), and we can help you better(or you may not need it at all!).

Run Internet Explorer 9 on Windows Xp Professional for testing purposes?

I want to test my web application on Internet Explorer 9 but I don't want to buy a copy of Vista/Win 7 on my developer machine with Windows XP.
Anyone knows a workaround, free and easy?
Use another machine.
Or better, get a set of Virtual Machines established which have an array of operating systems and browsers installed. Build enough VMs, and you are covered for all eventualities, regardless of whether you would personally use them or not.
Link to Internet Explorer Application Compatibility VirtualPC Images
You can't. The closest you'll get is IE9Preview.
I've found that IETester is not a bad way to quickly switch between browser versions for testing.
http://wiki.winehq.org/WineOnWindows
You can try running Wine on windows.
This will let you emulate a newer version of Windows
However, it will be really buggy (not mentioning how Wine is already buggy)
Its a unix/linux application ported for Windows
:)
IE 7,8,9
https://browserlab.adobe.com
Use
https://browserling.com
In unpaid version you have 3 minutes to test any site accessed from Internet on any browser.
In paid version you have unlimited sessions and ssh tunneling.

Setup project slow to install Windows service and client

I am currently using the Visual Studio 2010 Setup Project to deploy my application to an MSI installer file, which includes a Windows Service and a Windows Forms application. But I am disappointed with the performance and compatibility of this form of packaging.
My application is compatible with Windows XP and upwards, but several older XP user-testing boxes simply don't have the right version of the Windows Installer or the necessary service pack installed. (Un)installation can take dreadfully long for a program under 1MB in size and many systems do not support it. InstallState errors can crop up and ruin the (un)installation if the service has been deleted or already installed, or if any program files are missing (for uninstall).
What I need from an (un)installer:
Manage .NET dependencies.
Copy/remove my application files to a folder.
Add/remove menu and shortcuts to the desktop and Start menu.
(Un)install a Windows service, though I can also do this from my application. The stop and uninstall part is important.
Run my application when it's done.
This question's answers recommend NSIS (which I have used with good results) and WiX. Ironically there is no easy link to simple installer for WiX on their website.
Am I missing something with VS2010's setup project? It is optimized for speed, but it's just too slow.
You should run the installer/uninstaller explicitly with
msiexec /x thefile.msi /l*v thefile.log
(/i for install). Then inspect the log file; it will have time stamps telling you what action took what amount of time. Of course, the logging will affect that, but you should get an idea what makes it take so long.