0

I am using the hyper v role of windows server 2008 R2. I want to install OS in the virtual machine through C# code.

Also if there is an existing VHD of other VM can I able to link that VHD to a new VM with C# code. Waiting for your help.

2 Answers 2

2

Ah. No. You can not never ever install an OS from C# code, you know. How would you do that on a physical server?

There are some ways to autoamte the setup process. They are windows integrated (unattended install) and a prepared image could possibly use a .NET program to pull an answer file automatically, but that is something different than you asked for.

can I able to link that VHD to a new VM with C# code

All the configuration you can easily do from any windows integrated language (which includes any .net language). Hyper-v, being a windows system feature, is fully exposed through WMI.

http://blogs.technet.com/b/benp/archive/2008/08/11/scripting-hyper-v-with-wmi-and-powershell-part-1-introduction-querying-state.aspx

has some starts for using PowerShell, the same principles apply for any WMI capable language.

1

C# is just a language, and much like any other. The question you're asking has little to do with language.

If you're asking if you can programmatically manipulate a VM under Hyper-V, the answer is yes. Hyper-V is entirely managed through WMI interfaces, as defined here:

http://msdn.microsoft.com/en-us/library/cc136992(VS.85).aspx

You can interact with that in C#, using the .Net WMI classes, or you can (probably more easily) drive PowerShell cmdlets with your C# code. Whichever you're more comfortable with, they'll be more similar than different, as they both resolve down to .Net classes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .