I am trying to extract the VolumeGuid of EFI partition. I have been able to do it successfully on Windows 10 Machine using WMI query and Via code using C# ManagementObjectSearcher. I created a VHD with a GPT partition type within it I created the following, a recovery partition, EFI system partition and a basic data partition. The following is the WMI query I run in powershell after mounting the VHD.
I am unable to extract the same in a Windows 2012 R2 machine. Rest of the partitions volume guid I am able to extract in Window 2012 R2 machine.
Sample DiskPart script
CREATE PARTITION PRIMARY SIZE=450 OFFSET=1024 ID=de94bba4-06d1-4d40-a16a-bfd50179d6ac
FORMAT FS=NTFS LABEL="Recovery" UNIT=4096 QUICK
CREATE PARTITION PRIMARY SIZE=99 OFFSET=461824 ID=c12a7328-f81f-11d2-ba4b-00a0c93ec93b
FORMAT FS=FAT32 LABEL="" UNIT=512 QUICK
CREATE PARTITION PRIMARY SIZE=129481 OFFSET=579584 ID=ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
FORMAT FS=NTFS LABEL="" UNIT=4096 QUICK
WMI Query
"Get-WmiObject -Query "SELECT * FROM Msft_Volume" -Namespace Root/Microsoft/Windows/Storage"
In powershell on windows 10, I can see out for the EFI partition as shown below.
__GENUS : 2
__CLASS : MSFT_Volume
__SUPERCLASS : MSFT_StorageObject
__DYNASTY : MSFT_StorageObject
__RELPATH : MSFT_Volume.ObjectId="{1}\\\\computer\\root/Microsoft/Windows/Storage/Providers_v2\\WSP_Volume
.ObjectId=\"{efe10384-2fc4-11e9-bb16-806e6f6e6963}:VO:\\\\?\\Volume{f2f37b30-47b8-4553-804d-9b14
f6b32e1b}\\\""
__PROPERTY_COUNT : 18
__DERIVATION : {MSFT_StorageObject}
__SERVER : computer
__NAMESPACE : Root\Microsoft\Windows\Storage
__PATH : \\computer\Root\Microsoft\Windows\Storage:MSFT_Volume.ObjectId="{1}\\\\computer\\root/Micros
oft/Windows/Storage/Providers_v2\\WSP_Volume.ObjectId=\"{efe10384-2fc4-11e9-bb16-806e6f6e6963}:V
O:\\\\?\\Volume{f2f37b30-47b8-4553-804d-9b14f6b32e1b}\\\""
AllocationUnitSize : 512
DedupMode : 4
DriveLetter :
DriveType : 3
FileSystem : FAT32
FileSystemLabel :
FileSystemType : 6
HealthStatus : 0
ObjectId : {1}\\computer\root/Microsoft/Windows/Storage/Providers_v2\WSP_Volume.ObjectId="{efe10384-2fc4-
11e9-bb16-806e6f6e6963}:VO:\\?\Volume{f2f37b30-47b8-4553-804d-9b14f6b32e1b}\"
OperationalStatus : {2}
PassThroughClass :
PassThroughIds :
PassThroughNamespace :
PassThroughServer :
Path : \\?\Volume{f2f37b30-47b8-4553-804d-9b14f6b32e1b}\
Size : 99614720
SizeRemaining : 99613696
UniqueId : **\\?\Volume{f2f37b30-47b8-4553-804d-9b14f6b32e1b}\**
PSComputerName : computer
However the above WMI query does not return details for EFI partition when running on the "Windows 2012 R2". Even the same query run using c# code doesnt work.
Is there any restriction on Windows 2012 R2 that prevents it from displaying the EFI partition details?
Is there any other way to extract the volume guid of EFI partition?
Currently I had to assign a drive letter to EFI partition in order to read it, I would prefer using the \?\Volume{guid} syntax to open the drive and read it programmatically as it will avoid unnecessarily assigning a drive letter.
Kindly suggest.
Related
I need to retrieve all documents from a collection in mongodb. There's nothing special about the query, I just need all the documents to be returned.
The statuses of my collection are:
{
"ns" : "MyDb.MyCollection",
"size" : 206553804,
"count" : 123663,
"avgObjSize" : 1670,
"storageSize" : 30953472,
"capped" : false,
"nindexes" : 1,
"totalIndexSize" : 1122304,
"indexSizes" : {
"_id_" : 1122304
},
"ok" : 1.0
}
In my C # function, I wrote the following code:
var client = new MongoClient("mongodb://localhost:27017");
var database = client.GetDatabase("MyDb");
var collection = database.GetCollection<BsonDocument>("MyCollection");
var documents = collection.Find(new BsonDocument()).ToList();
The problem is that in the line of the function find() takes about 60 seconds to return all documents and this is hindering my application performance. This simple query in other collections is also taking longer than usual to return something. The database is running locally.
I'm using:
MongoDb 3.6.10;
MongoDb.Driver 2.7.0
.NET Framework 4.7
Windows 10
Also, my machine is a 7th generation i7 with 16gb ram and 256 SSD. Queries take the same time when the application is on the production server.
Is there anything I can do to improve this?
Thanks in advance
I am connecting to a Magicblue Bluetooth LE LED light with C# on Windows 10 and want to be able to change its colors.
I am able to get the GattDeviceService and access its single characteristic just fine. However, I'm not able to figure out how to get to the device's other two services. One of them has a write characteristic to set the RGB Color.
Using both my iPhone with the LightBlue App and Microsofts BthGATTDump.exe I'm able to see the services and characteristics. I was thinking once I get the GattDeviceService, I could "GetAllIncludeServices()" but this returns an empty list. If I try to get a specific service for which I have the Guid, it also fails (see below):
//Watcher for Bluetooth LE Services
private void StartBLEWatcher()
{
int discoveredServices = 0;
// Hook up handlers for the watcher events before starting the watcher
OnBLEAdded = async (watcher, deviceInfo) =>
{
Dispatcher.RunAsync(CoreDispatcherPriority.Low, async () =>
{
Debug.WriteLine("OnBLEAdded: " + deviceInfo.Id);
GattDeviceService service = await GattDeviceService.FromIdAsync(deviceInfo.Id);
var services = service.GetAllIncludedServices();
int count0 = services.Count; //returns 0
Guid G = new Guid("0000ffe5-0000-1000-8000-00805f9b34fb");
var services2 = service.GetIncludedServices(G);
int count = services2.Count; //returns 0 although this service "should" exist
var characteristics = service.GetAllCharacteristics();
int count2 = characteristics.Count; //return 1 This is the Gatt service with Notify
In case it is useful for anyone helping me, below is the bthgattdump.exe output for the LED BLE device.
C:\Program Files (x86)\Windows Kits\10\Tools\x64\Bluetooth\BthGATTDump>bthgattdump
Microsoft Bluetooth GATT database viewer v1.00 Copyright (c) Microsoft Corp.
Please select device
0 - LEDBLE-CA913BE2
1 - HID OVER GATT
2: To quit
0
Selected device - LEDBLE-CA913BE2
Device Address - eb0cca913be2 (STATIC)
[Service] Handle=0x0001 Type=0x1800(GAP)
[Characteristic] Handle=0x0002 ValueHandle=0x0003 Type=0x2a00(Device Name) Properties=(Read/Write)
[Value] LEDBLE-CA913BE2
[Characteristic] Handle=0x0004 ValueHandle=0x0005 Type=0x2a01(Appearance) Properties=(Read)
[Value] [4000]
[Characteristic] Handle=0x0006 ValueHandle=0x0007 Type=0x2a04(Peripheral Preferred Connection Parameters) Properties=(Read)
[Value] [100018000000C800]
[Service] Handle=0x0008 Type=0x1801(GATT)
[Service] Handle=0x0009 Type=0xfff0
[Service] Handle=0x000a Type=0xffe5
[Characteristic] Handle=0x000b ValueHandle=0x000c Type=0xffe9 Properties=(WriteWithoutResponse)
[Service] Handle=0x000d Type=0xffe0
[Characteristic] Handle=0x000e ValueHandle=0x000f Type=0xffe4 Properties=(Notify)
[Descriptor] Handle=0x0010 Type=0x2902(Client Configuration)
[Value] No subscription
C:\Program Files (x86)\Windows Kits\10\Tools\x64\Bluetooth\BthGATTDump>
What silly thing am I missing?
You probably don't want to get the "included services". Included services is a special concept in BLE which I doubt you are using that is used to link one service from another.
In your watcher, watch for BLE devices rather than a specific service. With that BLE device you get, you can get a list of all primary services.
I am trying to change some windows settings by group policy settings using C#.
My application creates sub-keys in the group policy objects section successfully,
But some times they doesn't work.
For example i am trying to disable desktop using Group policy, I take these steps :
I run Process monitor and configure it to show me the registry changes relating to mmc.exe
Then run gpedit.msc and navigate to the desired option and change it
I copy the registry change which is shown in Process monitor and use it
in my app like this :
mmc.exe RegSetValue HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\{FD0F8A58-1909-410F-8860-4CFF7766FA89}User\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDesktop SUCCESS Type: REG_DWORD, Length: 4, Data: 1
And use it like this :
string regPath = #"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer";
string option = "NoDesktop";
SetGroupPolicySetting(regPath, option, 1);
SetGroupPolicySetting uses a dll which can be downloaded from here and is written like this :
private void SetGroupPolicySetting(string registryKeyPath,
string option,
int value ,
GroupPolicySection groupPolicySection = GroupPolicySection.User)
{
var gpo = new ComputerGroupPolicyObject();
RegistryKey registryKey = gpo.GetRootRegistryKey(groupPolicySection);
registryKey.CreateSubKey(registryKeyPath).SetValue(option, value , RegistryValueKind.DWord);
gpo.Save();
}
After that , there are two subkeys created which are:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\{27D2FEFF-E5C6-4D8B-B657-0D1E1F2E4BAE}Machine
and
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\{27D2FEFF-E5C6-4D8B-B657-0D1E1F2E4BAE}User
and finally the NoDesktop option in Explorer section is created in this address :
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\{27D2FEFF-E5C6-4D8B-B657-0D1E1F2E4BAE}User\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
though still its not working ! Whats wrong ? its driving me insane!
Setting a GPO alone does not make it active. GPOs usually get reapplied at boot or after a certain period of time. You can probably run something like gpupdate /force (as Administrator) to force reapplying GPOs.
I am using c#.net for writing the map and reduce function.I have basically followed the example being given here
Final command
Hadoop jar hadoop-streaming.jar -files "hdfs:///example/apps/map.exe,hdfs:///example/apps/reduce.exe" -input "/example/apps/data.csv" -output "/example/apps/output.txt" -mapper "map.exe" -reducer "reduce.exe"
The Job ran successfully
Now from the Interactive JS mode, if I write
js> #cat /example/apps/output.txt
cat: File does not exist: /example/apps/output.txt
Where as :
js> #ls /example/apps/output.txt
Found 3 items
-rw-r--r-- 3 xxxx supergroup 0 2013-02-22 10:23 /example/apps/output.txt/_SUCCESS
drwxr-xr-x - xxxx supergroup 0 2013-02-22 10:22 /example/apps/output.txt/_logs
-rw-r--r-- 3 xxxx supergroup 0 2013-02-22 10:23 /example/apps/output.txt/part-00000
What is the mistake I am making and how can I see the output?
The -output flag specifies an output folder, not a file. Since there can be multiple reducers, each one will produce a file in this folder.
In this case, you have one reducer, and it produced one file: part-00000. If there were more reducers, they would be named part-00001, part-00002, etc.
The command cat /example/apps/output.txt/part-00000 will display your output. In the future, don't name your output folders something.txt, as that will just confuse you and others :)
I'm using a Mongo db on 32bit system and I need to create a large capped collection with a max size of 1GB. Everything works fine on 64bit system, but on 32bit I'm getting the error:
com.mongodb.CommandResult$CommandFailure: command failed [command failed [create] {
"serverUsed" : "localhost:27017" ,
"errmsg" : "exception: assertion db\\pdfile.cpp:437" ,
"code" : 0 ,
"ok" : 0.0}
The total storage size for the server is 2GB on 32bit system, but even with this size I can't create a collection larger than 500MB. What does this magic number mean?
Mongo db server version is 2.0.6
Additional info:
I have a couple of database files, the total size of which is 34MB. Before running a mongo db, I'm copying those files into the 'data' directory, starting Mongo db and then in shell I see the same number for the totat size - 35651584 (34MB) (the command used is taken from the comments below). If I try to create a collection of size 500MB I see a new file added (512MB). But if for example I will try to create a collection of size 600MB, I have an error discribed above (but the 512MB file still added).
The Mongo db server log
The Mongo db is started with the command line options:
> db.adminCommand("getCmdLineOpts")
{
"argv" : [
"mongod.exe",
"--dbpath",
"..\\data",
"-vvvvvv",
"--logpath",
"..\\log\\server.log"
],
"parsed" : {
"dbpath" : "..\\data",
"logpath" : "..\\log\\server.log",
"vvvvvv" : true
},
"ok" : 1
}
>
MongoDB runs much better on a 64-bit system, can you change to x64? As Stennie said you're must likely hitting a mmap limit due to other data in your database.
Can you test this hypothesis by connecting with the mongo shell and trying to create a new by running a new collection that is 1 byte larger than 512 MB -
db.createCollection("mycoll6", {capped:true, size:536870913})
You should hopefully get the following error message -
"errmsg" : "exception: can't map file memory - mongo requires 64 bit build for larger datasets",
In the Mongo shell, connect to the admin database and view the size of your database to see how much data you have -
use admin
show dbs
Update: based on some additional testing (I used Ubuntu 12.04 32-bit), this seems like it could be a bug.
Ubuntu Testing
db.createCollection("my13", {capped:true, size:536608768})
{
"errmsg" : "exception: assertion db/pdfile.cpp:437",
"code" : 0,
"ok" : 0
}
db.createCollection("my13", {capped:true, size:536608767})
{ "ok" : 1 }`
536608767 bytes is a little under 512 MB, leaving room for some sort of header in the file.
I thought it was maybe related to [smallfiles][2] as all 32-bit installs run with that option, however, an x64 build with the smallfiles does not display the same symptoms.
I have logged SERVER-6722 for this issue.