I've looked at several objects in the "root\virtualization" name space but I have not been able to find where Hyper-V stores the path to the config file for a given virtual machine. I need to get this file path programmatically or at least just the home path of a given virtual machine would be fine as well. What WMI object and field stores the path to a given virtual machine (hint it's not Msvm_ComputerSystem) ?
Get the DefaultExternalDataRoot property of Msvm_VirtualSystemManagementServiceSettingData to get the vm root, and append the Name property of Msvm_ComputerSystem (guid) and ".xml". Even if the VM is created in a non-default location, you'll see a symlink in the default external data root directory referencing the config file.
This is not completely true. In WSS2008R2, when changing default VM data root, nothing is written in the system data root. To find the data root of a single VM, you need to look in Msvm_VirtualSystemGlobalSettingData, search for SystemName property matching your VM GUID and look in ExternalDataRoot and SnapshotDataRoot properties to see the VM related folders.
Related
I have a default website in my IIS where I have created one virtual directory "wsdls".
I would want to gather statistics on how many requests are triggered to my virtual directory. This would need a request interception at web server level and gather statistics. "HTTPModule" was one of the many solutions I have considered which is suitable for such scenario. Hence I have started building one.
For testing purpose, I wanted to create a HTTP Module and apply it on a particular extension files (say *.wsdl) and on every GET request of any .wsdl files in this virtual directory, I will want to redirect the application to "www.google.com". This would demonstrate a good example of how HTTP Module can be used and deployed on IIS.
HTTPModule which is written using Visual Studio is shown below,
namespace Handler.App_Code
{
public class HelloWorldModule : IHttpModule
{
public HelloWorldModule(){
}
public String ModuleName{
get { return "HelloWorldModule"; }
}
// In the Init function, register for HttpApplication
// events by adding your handlers.
public void Init(HttpApplication application){
application.BeginRequest +=
(new EventHandler(this.Application_BeginRequest));
application.EndRequest +=
(new EventHandler(this.Application_EndRequest));
}
private void Application_BeginRequest(Object source,
EventArgs e)
{
// Create HttpApplication and HttpContext objects to access
// request and response properties.
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
context.Response.Redirect("www.google.com");
}
private void Application_EndRequest(Object source, EventArgs e)
{
//Nothing to be done here
}
public void Dispose() { }
}
}
Now I have done a build of this project for x64 version and I am able to browser successfully the "dll" file. Now I have to register this dll in IIS and whenever I try to access the *.wsdl files, the requests automatically divert to "www.google.com". Here is the next step I have done,
Then I have enabled the Handler mappings as shown below,
I am assuming that is it!! Nothing more to be done. I should be able to intercept the requests for all HTTP requests which are of the form "*.wsdl". This means whenever I access any wsdl from the server, control should be going back to google(Because of the logic written in begin request ). But unfortunately, I failed in achieving it. What can be done here?
One thing I noticed is that when you are trying to redirect to an external URL use
http://
So change
context.Response.Redirect("www.google.com");
to
context.Response.Redirect("http://www.google.com", true);
I could solve the problem what I am facing and below are the observations which were missing in my understanding and which helped me in solving my problem:
Locating proper web.config file :
Every website in IIS will be having a web.config file to have control over the application.
Since I am working with "Default Website", this refers to the directory "C:\\inetpub\\wwwroot"
There will be a "web.config" file which would be present in this director. Please create it if not already present.
Modifying web.config :
Once you have identified the file which needs to be modified, just add necessary module configuration to web.config
In this case, we would want to add a Module to the default website, the probably setting would be shown below,
Adding contents to bin directory :
Now if you try to run the application, the IIS would not find any dll or executable to run and hence we would need to keep the executables at a particular location.
Create a director if not already present with the name "bin" at the root of the directory and place all the dlls which you would want this website to execute. Sample shown below,
General Points to be considered:
Proper access must be given for the folder which consists of dll.
It is ideally not suggested to modify the entire website. It would be ideal if one works only on their web application.
If web.config is not found, we can create one.
If bin is not present in the web root directory, we can create one.
I need to retrieve the proxy settings on Windows. They have been set by an admin, so they reside in the registry at locations:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings
ProxySettingsPerUser = 0x00000000 (0)
This entry is giving the information whether the proxy settings need to be read from HKCU(ProxySettingsPerUser=1) or HKLM(ProxySettingsPerUser=0).
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings
ProxyEnable = 0x00000001 (1)
ProxyServer = Host:Port
When I try to read them directly, the default value/string is returned (i.e. not the actual contents of the variable):
Code:
#define HKLM_INTERNET_SETTINGS_KEY "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"
//[...]
QSettings regHKLM( HKLM_INTERNET_SETTINGS_KEY, QSettings::NativeFormat );
QString read = regHKLM.value( "ProxyServer", "default" ).toString();
logDebug(QString("ProxyServer %1").arg(read));
Other entries in the same location, such as CodeBaseSearchPath = "CODEBASE" or WarnOnIntranet = 0x00000001 (1), can be read without a problem.
THe second approach tried was to read the proxy settings by using the MSDN functions ::WinHttpGetIEProxyConfigForCurrentUser and ::WinHttpGetProxyForUrl. The code is working fine when trying to read HKCU settings (given both manually host-port or as pac file). But when the settings need to be retrieved from HKLM, the following error is returned:
ERROR_WINHTTP_AUTODETECTION_FAILED
12180
Returned by WinHttpDetectAutoProxyConfigUrl if WinHTTP was unable to discover the URL of the Proxy Auto-Configuration (PAC) file.
Is there another approach to retrieving the HKLM proxy settings?
If the approaches described above should have worked, is there a special condition/privilage that needs to be fulfilled before the settings can be read? (in the first approached, the application already has elevated the privilage level to maximum possible, and the manifest file is set to level "asInvoker")
Best regards,
Kornrade
I have BitLocker enabled on my machine and I want to use the wbemtest.exe utility to view properties about the Bitlocker data.
According to the properties section at MSDN, some of the data that I want to retrieve are DeviceID, DriveLetter, PersistentVolumeID, and ProtectionStatus.
However, when I execute the query
SELECT * from Win32_EncryptableVolume
using wbemtest.exe, only one object gets returned, and that is BitLocker DeviceID. I also want this query to return the DriveLetter and the other properties. What do I do to retrieve these? The data should be there, because my C# app using System.Management is able to get data on the other properties without any trouble (by assigning the return value of a ManagementClass GetInstances() method to a a ManagementObjectCollection.)
It turns out that I am able to view the data I need quite simply by using the WMI Code Creator utility.
I found this information on windows-noob
I want to change the default search provider of IE (9) by editing the registry file. I have followed the steps given in the link: http://www.online-tech-tips.com/internet-explorer-tips/change-default-search-engine-ie/.
But when I change DefaultScope value to a scope in SearchScopes, then restart the computer, or open IE, make a search in address bar, or close IE. The value of DefaultScope is restore to previous value.
Why? Or what is my mistake?
How to change the search provider engine of IE programatically (not in IE, may be through registry, or in my C++ code)? (I write a C++ program that need to change IE's search provider engine)
I have written this function for Firefox or Chrome. It works well.
With Firefox, those information is stored in the prefs.js file. I can
read or write information requisite to this file easily. With Chrome,
those information is stored in two files in user profile folder:
Preferences and Web Data files. The Preferences file is a JSON file. I
get those information easily by parsing this JSON file. But to set
search engine provider information for Chrome. We need to change those
information in Web Data file. Web Data file is a SQLite file. I use
SQLite library to access this.
With Internet Explorer, I can get those information in that registry
path. But I can't set those information with that registry path. So, I
think, like Chrome, IE (or registry) needs to change those information
somewhere. But I don't know where.
Here is a detailed answer to your question.
There are two options you may choose from use IOpenServiceManager:
CComQIPtr<IOpenServiceManager> spManager;
check(spManager.CoCreateInstance(__uuidof(OpenServiceManager), CLSCTX_ALL));
CComQIPtr<IOpenService> spService;
check(spManager->InstallService(PU_POSTINSTALL_ANT_SEARCH_PROVIDER_XML, &spService));
if(makeItDefault)
{
// Request that the user change their search default
check(spService->SetDefault( TRUE, hPromptParent ));
}
or modify the registry:
LPCWSTR searchScopesKeyName = L"Software\\Microsoft\\Internet Explorer\\SearchScopes";
createKey(rootKey, HKEY_CURRENT_USER, searchScopesKeyName);
std::wstring clsidString = findProviderClsid(false);
if( clsidString.empty() )
clsidString = mc_providerClsidString;
if( makeItDefault )
setStringValue( rootKey, mc_defaultScopeValueName, clsidString.c_str() );
ATL::CRegKey subKey;
createKey(subKey, rootKey.m_hKey, clsidString.c_str() );
setStringValue( subKey, mc_displayNameValueName, mc_providerName );
setStringValue( subKey, mc_faviconUrlValueName, mc_providerFaviconURL );
setStringValue( subKey, mc_urlValueName, mc_providerURL );
Just giving a side note that SetDefault function was deprecated on Microsoft Edge browser. Also, after KB3148198 update, it's blocked. Function will return
OS_E_CANCELLED instead.
I'm writing a PloneFormGen custom action adapter in order to add a File object to a folder from the File Field in the form. Here is the script:
target = context.filefolder
form = request.form
uid = str(DateTime().millis())
target.invokeFactory("File", id=uid, file=form['arquivo-do-cv_file'])
obj = target[uid]
"filefolder" is the name of a folder inside the parent folder for the PFG FormFolder. This script is configured to run with a Manager proxy role.
Problem is that the File objects created this way won't show the "Click here to download the file" link when I view them. The files can be downloaded though, if I suppress the "/view" part from the end of the URL. What am I missing when calling invokeFactory to create the File object?
UPDATE: What I meant is that I don't get the "filename - filetype, size in KBs (size in bytes)" link for the document, below the byline. When I create a File object using the normal Plone UI, it does show up.
I suspect nothing; I think that is the default behavior in Plone 4.
I just added a File and I don't see any "Click here to download the file".
And a quick search does not reveal the string "click here to download":
aclark#Alex-Clarks-MacBook-Pro:~/Developer/test-4.1/ > grep -ir "Click here to download" parts/omelette
parts/omelette/plone/app/jquerytools/browser/jquery.tools.plugins.js: (root.tagName == 'A' ? "<p>Click here to download latest version</p>" :
parts/omelette/plone/app/jquerytools/browser/jquery.tools.plugins.min.js:" or greater is required</h2><h3>"+(g[0]>0?"Your version is "+g:"You have no flash plugin installed")+"</h3>"+(a.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='"+k+"'>here</a></p>");if(a.tagName=="A")a.onclick=function(){location.href=k}}if(b.onFail){var d=b.onFail.call(this);if(typeof d=="string")a.innerHTML=d}}if(i)window[b.id]=document.getElementById(b.id);f(this,{getRoot:function(){return a},getOptions:function(){return b},getConf:function(){return c},
I don't have a Plone instance to test it, but try to call processForm() after invokeFactory. It will:
unmark creation flag;
rename object according to title;
reindex the object;
invoke the after_creation script and fire the ObjectInitialized event.
These actions are detailed on Object Construction Lifecycle. Maybe some of these actions are needed to create the KB information you're after (I'm hoping it's the index).