It is currently March 28th, 2024, 12:38 pm

identify virtual drives

General topics related to Rainmeter.
Yue
Posts: 59
Joined: March 23rd, 2023, 1:10 pm

identify virtual drives

Post by Yue »

Hi! I guess, this question rather belongs to "general" than "skin editing". Although I searched for it, I could not find anything, maybe I am blind...
Is there a way to identify whether a drive is a virtual drive?
Last edited by Yue on April 9th, 2023, 7:54 am, edited 1 time in total.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm
Contact:

Re: identify virutal drives

Post by SilverAzide »

Yue wrote: April 6th, 2023, 12:34 pm Hi! I guess, this question rather belongs to "general" than "skin editing". Although I searched for it, I could not find anything, maybe I am blind...
Is there a way to identify whether a drive is a virtual drive?
What exactly do you mean by a "virtual drive"? Do you mean a RAM disk? a SUBSTed drive? a mapped network drive? a RAID array? There are really only 2 kinds of drives, "physical" and "logical". How you address them and fetch data about them can get rather complicated.

On the Rainmeter side, the FreeDiskSpace measure with Type=1 will return the type of drive, but if you want anything more precise than that, you'll need to use WMI or Powershell.
Yue
Posts: 59
Joined: March 23rd, 2023, 1:10 pm

Re: identify virutal drives

Post by Yue »

Thanks for your fast reply! My excuses. I did not think that far. I meant a virtual disk drive to emulate images [like you can create with DAEMON Tools].
FreeDiskSpace [with type] did not help with that issue [already had read about it]. I have a pale memory of WMIC from creating .bat...but I have read that will be quit by Microsoft. So I guess I will have to read about Powershell. Too bad I only know DOS and never used Powershell until today [yes, I know, I know...easier, more capable...^^]. Thanks for that advice! Now at least I know where to look - I will put that on my list. Learning about Powershell [too] I do not have the time at the moment, so I will keep that in mind [for, sadly, much later]. Thank you!
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm
Contact:

Re: identify virutal drives

Post by SilverAzide »

Yue wrote: April 7th, 2023, 12:19 am Thanks for your fast reply! My excuses. I did not think that far. I meant a virtual disk drive to emulate images [like you can create with DAEMON Tools].
FreeDiskSpace [with type] did not help with that issue [already had read about it]. I have a pale memory of WMIC from creating .bat...but I have read that will be quit by Microsoft. So I guess I will have to read about Powershell. Too bad I only know DOS and never used Powershell until today [yes, I know, I know...easier, more capable...^^]. Thanks for that advice! Now at least I know where to look - I will put that on my list. Learning about Powershell [too] I do not have the time at the moment, so I will keep that in mind [for, sadly, much later]. Thank you!
You don't need DaemonTools with Windows 10/11. You can just right-click an ISO file and select the Mount option. This will appear as a CD-Rom drive. Right-click the drive and select Eject to unmount the drive.

There are a number of PowerShell cmdlets you can use to get detailed information about drives. Get-PhysicalDisk (or Get-PhysicalDisk | Select *) will get physical disk info, but for logical drive info you'll need to use WMI (which is still supported), like Get-WmiObject -Class Win32_LogicalDisk | Select *. A virtual CD-Rom will appear exactly like a real one.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: identify virutal drives

Post by balala »

Yue wrote: April 6th, 2023, 12:34 pm Is there a way to identify whether a drive is a virtual drive?
Based on SilverAzide's reply, here is a PowerShell RunCommand measure, which can return the drive letter of the mounted drive (for instance a mounted .iso image). This is an extremely simple case, returning only the associated drive letter of only a mounted drive. It doesn1t return the drive letter of a physical CD or DVD drive (if there is such a drive present).
Here is the code:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
OnRefreshAction=[!CommandMeasure "MeasureDriveType" "Run"]

[Variables]

[MeasureDriveType]
Measure=Plugin
Plugin=RunCommand
Program=PowerShell.exe
Parameter=Get-DiskImage -DevicePath \\.\CDROM1 | Get-Volume
OutputType=ANSI
RegExpSubstitute=1
Substitute=".*\n-.*\n(.).*":"\1","\n":""
DynamicVariables=1

[MeterDrive]
Meter=STRING
MeasureName=MeasureDriveType
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
FontEffectColor=0,0,0
StringEffect=Shadow
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=Mounted drive: %1
Yue
Posts: 59
Joined: March 23rd, 2023, 1:10 pm

Re: identify virutal drives

Post by Yue »

SilverAzide » Today, 3:19 am
You don't need DaemonTools with Windows 10/11. [...]
If I were not using an older Windows, I would know that. :lol:
Windows 8 felt somewhat unfinished, so I skipped that. Then Microsoft announced the ambition to manage the OS without version number and even make it stream-based in the future as we already knew from using thin clients, so I intended to observe the development. Well, it did not happen, yet. Seems the plan was changed to a longer period and they first tested the reaction of customers by a smaller project [Office 365] as we now have the same concept if you look at steam or Adobe.
But the last three years I did not have the time to revise the setup of my system to adjust it to changes through version alterations. I will do it when I buy the next computer.
Thanks. Now I know that, I will be able to customize my skin that way from startup instead of later having to change things! So I keep that one in mind!
balala » Today, 7:39 am
Here is the code:
Thank you for the explanation and the code example! This will help much understanding how to do in Rainmeter.
...and as I see, I will have to read about RegExp. I thought that would come much later [had it on my list for, well, not so near future^^]

Thank you two very much. Because of circumstances I will have to save that for much later, but will need it and it will help!
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: identify virutal drives

Post by balala »

Yue wrote: April 7th, 2023, 2:34 pm Thank you for the explanation and the code example! This will help much understanding how to do in Rainmeter.
You're welcome.
Yue wrote: April 7th, 2023, 2:34 pm ...and as I see, I will have to read about RegExp. I thought that would come much later [had it on my list for, well, not so near future^^]
Regular expressions are the one of the most complicated things related to Rainmeter codes (this is my opinion, at least). Worth to work with them when needed, to get used on how to use them.
Yue wrote: April 7th, 2023, 2:34 pm Because of circumstances I will have to save that for much later, but will need it and it will help!
The Easter is right here, right?
Alright. If anytime in the future you need further assitance, feel free to come back anytime.
Yue
Posts: 59
Joined: March 23rd, 2023, 1:10 pm

Re: identify virutal drives

Post by Yue »

balala » Yesterday, 5:23 pm
Regular expressions are the one of the most complicated things related to Rainmeter codes
That´s what my impression was. So I put it on my list for later when first time needed inevitably and not just for expanding a skin [that can be done later].
balala » Yesterday, 5:23 pm
The Easter is right here, right?
Alright. If anytime in the future you need further assitance, feel free to come back anytime.
Correct! One more reason why I am occupied.
No need to come back, I stay.^^ But I thought perhaps I could add the option of identifying virtual drives easily to the script I am working on instead of changing the code later [once more]. Anyway I am working on my codes when I have time for it. But since this thread´s idea won´t be that easy for me, I have put that on the list of future work.
I wish you an enjoyable Easter! :welcome:
User avatar
Yincognito
Rainmeter Sage
Posts: 7018
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: identify virutal drives

Post by Yincognito »

Regex is quite easy when it comes to basics, it's literally just about 30 or so symbols used to refer to categories of characters, that's all. What makes it look complicated is the fact that one must get creative to exploit its full potential and this results in longer, more complex and harder to decipher expressions without proper coloring applied to those (relatively similar) symbols to make expression parts easier to notice ... especially when one is not the author of it.

I doubt there is an easy way (if there is a way, that is) to identify virtual drives, like SilverAzide already mentioned. If it were so easy, then DaemonTools and other standard mounting techniques would not be able to simulate a "real", "physical" drive. In a way, it's like with virtual machines or even flash drives: you know they're what they are because you are aware of the process or the device, but a computer sees only what it's "served" to it, i.e. the exact replica of a "real" drive / machine, which is the whole point of these techniques in the first place.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: identify virutal drives

Post by balala »

Yue wrote: April 8th, 2023, 6:26 pm I wish you an enjoyable Easter! :welcome:
Wishing the same to all members who are celebrating it.
Yincognito wrote: April 9th, 2023, 12:15 am I doubt there is an easy way (if there is a way, that is) to identify virtual drives,
https://forum.rainmeter.net/viewtopic.php?t=42226#p213859
Post Reply