Hi..
I have requirement in which to remove the spaces with the short file name from the Environment Variables
Below is my code..but it is throwing an error..please suggest.
$fso = New-Object -comobject "scripting.filesystemobject"
$shortpaths = @();
foreach ($path in $env:Path.Split(";"))
{
$shortpaths += $fso.GetFolder($path).ShortPath;
}
$shortpaths -join ";";
$Reg = "Registry::HKLM\System\CurrentControlSet\Control\Session Manager\Environment"
$OldPath = (Get-ItemProperty -Path "$Reg" -Name PATH).Path
$shortpaths
Set-ItemProperty -Path "$Reg" -Name PATH –Value $shortpaths
Umeed4u