Check free space in c drive

Hi , I am new to UiPath
Can i check whether C drive is free or not ,using UiPath

2 Likes

Hey @prashanth_pachu

Yes

You have to import first System.IO namespace in your project.

DriveInfo drive_info = new DriveInfo(“C”);
Int64 Space_available= drive_info.AvailableFreeSpace;
Writeline((Space_available / (1024 * 1024*1024)).ToString) //will return available space in GB

Reference Sample: Drive space.xaml (5.6 KB)

Regards…!!
Aksh

4 Likes

Thanks a lot,
it worked for me:slight_smile:
@aksh1yadav

hi @aksh1yadav
Can i do the same for remote system?

hey @prashanth_pachu

Yes we can .
i am attaching one powershell script and use INvoke power shell activity with property IsScript to check.

disk_space_on_remote_servers.zip (429 Bytes)

Regards…!!
Aksh

3 Likes

Thanks for the idea.

1 Like

hi @aksh1yadav
I tried this, due to restricrions ,i cant execute powershell script
i tried Set-ExecutionPolicy Unrestricted also
And remote system need Credentials also
Thanks & Regards
Prashanth

One more way (non scripting). You will still have permission restrictions, explore the options mentioned in comments.

RemoteSpace.xaml (17.2 KB)

3 Likes

hi @vvaidya
Thanks for the code but now i am not able to pass the password,it is showing an errror saying that option.Password is WriteOnly.
I used the same logic in c# console application , it worked, but not in UiPath

The Method above by Vinay uses WMI.
Windows Management Instrumentation (WMI) is a set of specifications from Microsoft for consolidating the management of devices and applications in a network from Windows computing systems.

Note: - Connection credentials to the remote computer, not needed if the logged account has access.

First Let me know your account has access then omit this password property and username property because

and if not then try the Invoke Code Activity and paste the code inside that :slight_smile:

        Dim options As New system.Management.ConnectionOptions()
        options.Username = "Aksh"
        options.Password = "testAkshay"

if you have already created an options object for ConnectionOptions then use that inargument in invoke code.

Regards…!!
Aksh

3 Likes

hi @aksh1yadav
thank you for your explaination, it worked for me :grinning:

Can we get these information using objectquery

Thanks & Regards
Prashanth

Hey @prashanth_pachu

Yeah we can even with Process thread and Performance counter classes also you can get the information but you want this also for remote server or a local system where you are running your script?

Regards…!!
AKsh

1 Like

hi @aksh1yadav
i wanted it for remote server,
please let me know which approach to use.
Thanks & regards
Prashanth