It is currently April 27th, 2024, 11:06 am

FreeDiskSpace - network drive label problem

Get help with installing and using Rainmeter.
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: FreeDiskSpace - network drive label problem

Post by Yincognito »

BSt86 wrote: October 5th, 2023, 6:26 am @Yincognito
I tried using Powershell's approach and actually managed to solve it. I just have to play around with the UpdateDivider to improve performance.

My solution now looks something like this:

Code: Select all

[Rainmeter]
Update		= 1000
OnRefreshAction	= [!CommandMeasure measureGetNetDrives "Run"

[Variables]
Drive01	= C:
Drive02	= D:
Drive03	= A:
Drive04	= B:
Drive05	= E:
Drive06	= F:
...

[measureGetNetDrives]
Measure		= Plugin
Plugin		= RunCommand
Program		= PowerShell
Parameter	= $SubKeys = Get-ChildItem -Path Registry::HKCU\Network | Where-Object {($_.Property -eq 'RemotePath')}; foreach($SubKey in $SubKeys) { $SubKey.Name.SubString($SubKey.Name.Length - 1, 1).ToUpper() + ':--' + (Get-ItemProperty -Path Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\$((Get-ItemProperty -Path Registry::$($SubKey.Name)).RemotePath.Replace('\','#')))._LabelFromReg + '---'; };
State		= Hide
OutputType	= ANSI
OutputFile	= #CURRENTPATH#_DATA_NetDrives.txt
RegExpSubstitute= 1


[measureDrive01Type]
Drive		= #Drive01#
IgnoreRemovable	= 0
Measure		= FreeDiskSpace
Type		= 1
IfCondition	= (measureDrive01Type = 3)
IfTrueAction	= [!SetOption imageDrive01Type ImageName "#@#\Images\drive_removable.png"][!UpdateMeter imageDrive01Type][!SetOption textDrive01Title2 MeasureName "MeasureDrive01Title"][!Redraw]
IfCondition2	= (measureDrive01Type = 4)
IfTrueAction2	= [!SetOption imageDrive01Type ImageName "#@#\Images\drive_fixed.png"][!UpdateMeter imageDrive01Type][!SetOption textDrive01Title2 MeasureName "MeasureDrive01Title"][!Redraw]
IfCondition3	= (measureDrive01Type = 5)
IfTrueAction3	= [!SetOption imageDrive01Type ImageName "#@#\Images\drive_network.png"][!UpdateMeter imageDrive01Type][!EnableMeasure measureDrive01NetName][!SetOption textDrive01Title2 MeasureName "measureDrive01NetName"][!UpdateMeter textDrive01Title2][!Redraw]

[measureDrive01NetName]
Disabled	= 1
FinishAction	= !DisableMeasure measureDrive01NetName
Measure		= Plugin
Plugin		= Webparser
Url		= file://#CURRENTPATH#_DATA_NetDrives.txt
RegExp		= (?siU)#Drive01#--(.*)---
StringIndex	= 1

[measureDrive01Title]
Drive	= #Drive01#
Measure	= FreeDiskSpace
Label	= 1

	[textDrive01Title2]
	DynamicVariables= 1
	Group			= Drive2
	MeasureName		= MeasureDrive01Title
	Meter			= String
	MeterStyle		= styleTextTitle
	StringAlign		= Left
	Text			= "%1"
	X			= 10R
	Y			= 0r


Thank you all for your help!
Excellent solution - well done! Was thinking of saying that you could corroborate stuff from other registry keys to achieve what you needed, but didn't know if it seemed too complicated - luckily you figured that yourself. :thumbup:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth