I have one utility provided by Dev, Which takes the firmware package as input and decrypts its content. After decrypts, it asks for a physical device to flash this decrypted content into that device. But before flashing, it creates one locked folder on my machine.
I am trying to unlock that locked window file folder.
Nothing happened when I tried to open it by double-clicking on the folder icon. Also, Write error occurred When I wanted to rename it using PowerShell.
PS C:\Users\RajNegi\AppData\Roaming> rename-item
cmdlet Rename-Item at command pipeline position 1
Supply values for the following parameters:
Path: C:\Users\abc\AppData\Roaming\vsc.{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}
NewName: C:\Users\abc\AppData\Roaming\vsc
rename-item : Access to the path 'C:\Users\abc\AppData\Roaming\vsc.{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}' is denied.
At line:1 char:1
+ rename-item
+ ~~~~~~~~~~~
+ CategoryInfo : WriteError: (C:\Users\abc...f-00c04f60b9f0}:String) [Rename-Item], IOException
+ FullyQualifiedErrorId : RenameItemIOError,Microsoft.PowerShell.Commands.RenameItemCommand
Note: I already set Full control in folder permissions.
Related
In Powershell, when I try to delete a file with a hyphen in the nam like this:
remove-item 'C:\S3\op_netadmin-47.bak'
I get this error:
remove-item : Cannot remove item C:\S3\op_netadmin-47.bak: Access to the path 'C:\S3\op_netadmin-47.bak' is denied.
At line:1 char:1
+ remove-item 'C:\S3\op_netadmin-47.bak'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:\S3\op_netadmin-47.bak:FileInfo) [Remove-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
But if I rename the file to op_netadmin_47.bak, it works fine.
I've tried with and without double quotes as well as single quotes
I tried your file name with - and _, both work ok. I also tried to use " around file name which also works.
As #mklement0 mentioned in comments read-only files require -Force parameter
Make sure user running script has read/write access to given folder
I have this script:
$UserFile = Read-Host "Drag your file here"
Copy-Item -Path $UserFile -Destination .\input
I want user drag their file to console, so that the script can know the exact path of user file and copy user file to input folder. but i got this error
Copy-Item : Cannot find drive. A drive with the name '"C' does not exist.
At line:1 char:1
+ Copy-Item -Path $UserFile -Destination .\input
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: ("C:String) [Copy-Item], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
UPDATE:
It getting more weird guys, i think there is something wrong with my machine, i try to run the code on VM, and the code run with ZERO problem, and there's something different between my machine and VM, when i drag the file in my machine it will write like this "C:\path\to\my\file.something" but when i do that on my VM it write C:\path\to\my\file.something without "
UPDATE:
I just realized that i use different file, the file that i try on my machine is have white spaces in it file one.something but file that i use on VM don't have space file.something but i've tried to run the code like this
Copy-Item -Path "C:\path\to\my\file one.something" -Destination .\input
using " and it work. but that not what i want, i want user to drag their file no matter there is white space or not.
Try to add the -Prompt param
$UserFile = Read-Host -Prompt "Drag your file here"
*** drags file ***
Write-Host $Userfile ## should display the filepath
My guess is that this isn't an issue for you anymore and an extra " was entered into the terminal before dragging your file. For me, the code you've posted works without issue.
You might want to check out Cannot find drive. A drive with the name '"C' does not exist where the issue was the exact same thing.
Depending on the use of this script, you can trim/remove any characters before using and, in my experience, it is almost always better to use absolute paths instead of relative (here the ./input) unless you explicitly want to have the script be relative.
In my ongoing war with WSL2/VSCODE I'm trying to completely remove the .vscode-insiders directory from my machine.
rm -rf wont work, neither will delete from windows. Anyone know How I can destroy this thing?
I'm trying to get a dev environment set up with WSL2 VS CODE and Docker in Windows 10 insiders (18965).
I ran into problems trying to install the remote development pack, specifically the /ms-vscode-remote.remote-wsl-0.39.4 extension which is causing no end of problems.
However When I try to remove all vs code-insiders residue I get permissions problems with:
:/mnt/c/Users/micro/.vscode-insiders/extensions/ms-vscode-remote.remote-wsl-0.39.4/scripts/wslServer.sh
I cant delete it from the Ubuntu side with rm -rf
cannot remove 'wslServer.sh': No such file or directory
I cant delete it from windows explorer - no permissions
I cant delete it from powershell as admin running Remove-item.
Looked at all the existing answers on stack and none have a solution as far as i can see.
Would love some help?
Remove-Item : Access is denied
At line:1 char:1
+ Remove-Item wslServer.sh
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:\Users\micro...ts\wslServer.sh:String) [Remove-Item], Unauthorized
AccessException
+ FullyQualifiedErrorId : ItemExistsUnauthorizedAccessError,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : Cannot find path
'C:\Users\micro.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.39.4\scripts\wslServer.sh' because it does
not exist.
At line:1 char:1
+ Remove-Item wslServer.sh
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\micro...ts\wslServer.sh:String) [Remove-Item], ItemNotFoundEx
ception
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
Ctrl+alt+delete - right click 'Windows Subsystem For Linux' - end task.
Now try deleting the folder or let VScode do it for you.
I've tried a couple of solutions to unzip a file containing the path:
\Content\F_C\Jenkinsworkspace\workspace\BUILD.PROJECT.GENERICS\PROJECT_Generics\PROJECT.Generics\PROJECT.Generic\obj\Debug\Package\PackageTmp
but I get the error:
Exception calling "ExtractToFile" with "3" argument(s): "Could not find a part of the path
Expand-Archive -LiteralPath F:\Jenkinsworkspace\workspace\BUILD.GENERIC.GENERICS\GENERIC.Generic.zip -DestinationPath F:\Jenkinsworkspace\workspace\BUILD.GENERIC.GENERICS\UNZIPED2 -Force
Exception calling "ExtractToFile" with "3" argument(s): "Could not find a part of
the path 'F:\Jenkinsworkspace\workspace\BUILD.GENERIC.GENERICS\UNZIPED2\Content\
F_C\Jenkinsworkspace\workspace\BUILD.GENERIC.GENERICS\GENERIC_Generics
\GENERIC.Generics\GENERIC.Generic\obj\Debug\Package\PackageTmp\modules\
_protected\EPiServer.GoogleAnalytics\EPiServer.GoogleAnalytics.zip'."
At
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:1033 char:25
+ ... [System.IO.Compression.ZipFileExtensions]::ExtractToFile( ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DirectoryNotFoundException
I'm guessing it's because I have a zip within a zip.
In our case, though the path was short, we were getting the same error.
Sharing our solution which might be useful for someone.
We were trying to unzip the package on our application server through powershell script. Basically powershell script runs on our build server & remotely connect to our application server. It was then trying to unzip the package present on application server.
The above scenario was working fine for quite some time before it starts to throw the error during unzipping.
Solution:
We found the reason was anti virus policy, which was blocking the unzipping through remote powershell script.
Soved using this Blog :
https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/
changing the group policy solved the problem
I have been hopelessly trying to change the sector size of a freshly created Windows 10 VHDX file, to 4096 bytes per sector.
After searching the net and trying things, this comes closest (using Windows 10):
Install Hyper-V
Select Start button and type Powershell
Right mouse click "Run as Administrator"
Type command: Set-Vhd -Path 4Kn.vhdx –PhysicalSectorSizeBytes 4096
The latter command has been tried in all possible flavors, with full path, just the filename (after CD'ing to the folder) etc.
I always get errors:
Set-Vhd : The operation on computer 'DESKTOP-JCMNHRV' failed: Invalid class
At line:1 char:1
+ Set-Vhd -Path C:\Users\Peter\Desktop\4Kn.vhdx –PhysicalSectorSizeByte ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-VHD], VirtualizationException
+ FullyQualifiedErrorId : Unspecified,Microsoft.Vhd.PowerShell.Cmdlets.SetVhd
Any idea what to do or where to start? I don't see it anymore
The .vhdx is not attached, and I tried without any formatting inside, and later with an NTFS formatted volume.