How to protect files/folders from being copied/moved/deleted/cut on Windows
To configure the drive to read-only you can use Microsoft's Diskpart like this (The "Attributes Readonly" function is available only on Windows 7):
- Open a Command line prompt and enter these commands
- Diskpart
- List Volume
- Select Volume
<The volume letter of the external HD>
- Attributes Volume Set ReadOnly
- Attributes Disk Set ReadOnly
This should protect your external HD from any changes. As for coping files from you EHD to a local computer, I don't think you can control it - if he can read it he can copy it.
Another option is to put on your HD a bootable OS (probably Linux would be a good place to look for), that blocks all local HDs and encrypt everything on the EHD, so it can be accessed only through this specific OS.
I've read that this thing can be done with Windows 8, but I've no online sources to give you.
Related videos on Youtube
![Sean Lee](https://i.stack.imgur.com/c3xwp.png?s=256&g=1)
Sean Lee
Updated on September 18, 2022Comments
-
Sean Lee almost 2 years
I have variable called out and I stored value there is:
b'0,0.0372549,0.00653595,0,0.00490196,0.00653595,0.897386,0.00653595,0.0294118,0.00653595,0,0,0,0,0,0.00490196,0,0,0,0\n0,0.0158333,0.0179167,0.00277778,0.116111,0.327083,0.0265278,0.174167,0.0623611,0.116806,0.055,0.0270833,0,0,0.01875,0.0333333,0,0,0,0.00625\n0,0.997554,0.00133297,4.75327e-05,0.000118379,6.65359e-05,0.000253487,0.000141784,0.000183293,0.000220498,7.08961e-05,0,0,0,0,0,1.10967e-05,0,0,0\n0,0.082346,0.890084,0,0.000346861,0.0161043,0.0105323,0.000354988,0.00011562,0.00011562,0,0,0,0,0,0,0,0,0,0\n0,0.654957,0.306633,0,0.00150356,0.000466853,0.00273321,0.000933707,0.00233427,0.00186741,0,0,0,0,0.0190476,0.00952381,0,0,0,0\n0,0.429955,0.0543849,0.106071,0.0297159,0.0876241,0.16761,0.0435997,0.0293692,0.0167052,0.00492931,0.0143504,0.00664048,0.00127352,0.000520984,0.00405789,5.78871e-05,0,0,0.00313481\n0,0.372212,0.459023,0.00909091,0.0183902,0.00273224,0.0897315,0.00666667,0.0163417,0.000546448,0.000208333,0.00929924,0.00666667,0,0,0,0,0,0,0.00909091\n0,0.916784,0.0557399,0.00127288,0.0044239,0.00263795,0.00418008,0.00522153,0.00448012,0.0016537,0.0015471,0.00140777,0.00011532,4.21977e-05,4.21977e-05,5.76602e-05,0,0,0,0.000393295\n0,0.817223,0.10791,0.0119181,0.00617358,0.00279979,0.027469,0.00652177,0.00186348,0.00522515,0.0121172,0.000151166,0,0,0,0,0.00017316,0,0,0.000454545\n'
Now I am writing following code:
for p in out.rstrip().split('\n'): print(p)
Now I am getting following error:
TypeError: a bytes-like object is required, not 'str'
How to solve this error ? I tried unicoding but doesn't work. what would be the for loop code to get desired output.
-
nixda over 10 yearsit's available only on Windows 7. Huh? Diskpart is one of Microsoft's oldest tools. It was and is included in all versions since Windows 2000
-
EliadTech over 10 yearsThat is correct, but this specific function is new.
-
Admin almost 6 yearsAccording to your code b is coming at first, I don't want that.
-
theonlygusti almost 6 yearsYou are removing byte statement manually. That is not correct
-
Carlo Beccarini almost 6 yearsRead better what i said :)
-
Carlo Beccarini almost 6 yearsSince you're not giving us complete needs, i'm gonna guess the solutions, and btw the last solution is what you're looking for, it will still be a byte statemnent.
-
Carlo Beccarini almost 6 yearshe just need to use splitlines() instead of split('\n'), since it is used for str-objects not byte-like objects.
-
Patrick Maynard almost 6 yearsThis should work to get rid of byte b'' at the beginning you must decode the string
-
Admin almost 6 yearsboth are incorrect. I want just the values not b before any string. you written foo by removing the character b from the front.
-
Carlo Beccarini almost 6 yearsWell, i'm gonna call. You're question doesn't say that. Fix it.
-
Carlo Beccarini almost 6 yearsWe both answered your question. Please, edit you question if you need anything else from what you asked.
-
Dimosthenis almost 6 yearsIf you don't want to decode the string then split it with
out.rstrip().split(b'\n')
. That isb'\n'
instead of'\n'