How to remove periodically the NuGet\v3-cache folder, in case if there is low disk capacity on C drive?
Issue Description: There may be very limited space of local disk C, and because of that, some issues / errors may occur,
- Not able to download and install new software or use the installed programs
- The operating system will run slowly
- The system will run unstable
- Cannot store more data/files due to smaller storage space
Regarding NuGet\v3-cache folder, it is filled automatically when the UiPath Studio opens or when UiPath Assistant is connected to Orchestrator to get the processes list.
If the local disk C size is a problem, extend the storage space for the C drive, or delete periodically the v3-cache folder if exists from the %localappdata%\nuget\v3-cache for each user or empty its content periodically.
Resolution:
Disclaimer: UiPath is not responsible for the below scripts or solutions. Adapt the queries based on individual needs.
Approach #1: Extend C Drive by Using Disk Management when there is adjacent unallocated space
- Right-click the Windows button, choose "Disk Management".
- Right-click C drive and choose "Extend Volume...".
- Follow the on-screen instructions to finish extending C drive.
Approach #2: Increase C Drive with Diskaprt Utility when there is adjacent unallocated space
When there is a contiguous adjacent unallocated space behind the C drive, you can also increase C drive by using the Diskpart tool in CMD.
- Press the Win+R buttons to open the Run dialogue. Then, type diskpart and press Enter.
- Type the following command lines in order and press Enter after each one.
list disk
select disk x (x is the number of the system disk)
list partition
select partition x (x is the number of C drive)
extend size=x disk=N (x is the size in MB you want to add to the system partition, N is the number of your system disk.)
Approach #3: Example of a PowerShell script that can remove the $env:LOCALAPPDATA\NuGet\v3-cache if exists
- Create a remove_folders.ps1 file with the below content,
$FolderName = "$env:LOCALAPPDATA\NuGet\v3-cache"
if (Test-Path $FolderName) {
Write-Host "Folder Exists"
Remove-Item $FolderName -Recurse -Force
}
else
{
Write-Host "Folder Doesn't Exists"
}
- Create a new Task in Task Scheduler that will run the remove_folders.ps1 script periodically using the below PowerShell script (modify with your details and requirements),
$Trigger= New-ScheduledTaskTrigger -At 05:02pm –Daily # Specify the trigger settings
$User= "domain\username" # Specify the account to run the script. From a cmd.exe console run whoami to find the user details
$Action= New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "C:\FULL_LOCAL_PATH_OF_THE_SCRIPT\remove_folders.ps1" # Specify what program to run and with its parameters
Register-ScheduledTask -TaskName "Remove env_LOCALAPPDATA_NuGet_v3-cache" -Trigger $Trigger -User $User -Action $Action -RunLevel Highest –Force # Specify the name of the task
- Before the first run,
- After the first successful run,