Asatoma Sadgamaya
asked on
MS Dos Command to password protect a file
Hi,
Please find the MS Dos command below. I am trying password protect a file. I am looking for a MS Dos command to do this (I need to include this command in a bat file)
@echo off
attrib +r -a -s -h "C:\Rep\MonthlyReports\abc d.xlsx"
Please let me know.
Thank you
A
Please find the MS Dos command below. I am trying password protect a file. I am looking for a MS Dos command to do this (I need to include this command in a bat file)
@echo off
attrib +r -a -s -h "C:\Rep\MonthlyReports\abc
Please let me know.
Thank you
A
The first line is nonsense, that just hides the folder (making it a "system" hidden folder). No password involved.
But yes, there is nothing built-in you can use to password protect files or folders, you'll always need to use external tools - if you need a solution not bound to exactly one machine and user (NTFS encryption).
What's the primary purpose for protection?
But yes, there is nothing built-in you can use to password protect files or folders, you'll always need to use external tools - if you need a solution not bound to exactly one machine and user (NTFS encryption).
What's the primary purpose for protection?
Correct, to me the first approach is nonsense.
Only mentioned for completeness.
The best options will be zip for files which can actually be compressed for space savings + openssl for audio/video files which gain little or nothing by compression.
Only mentioned for completeness.
The best options will be zip for files which can actually be compressed for space savings + openssl for audio/video files which gain little or nothing by compression.
ASKER
Hi,
What I need is a Dos command which can make an excel workbook read only mode. If I copy this file and paste it in other folder, this file should exist in read only mode.
Also, I want a dos command to make the above excel workbook into Normal mode.
Thanks
A
What I need is a Dos command which can make an excel workbook read only mode. If I copy this file and paste it in other folder, this file should exist in read only mode.
Also, I want a dos command to make the above excel workbook into Normal mode.
Thanks
A
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Likely best if you explain what you're trying to accomplish, as the more I read over your comments... some detail seems missing to understand what you're trying to accomplish.
ASKER
Thank you for your code below to set a file read only. your code work for me because when I try to copy paste the file, still retains the read only mode. thats exactly I am looking for.
attrib +R filename
May I know the similar code to make the file back to normal mode please?
attrib -r filename
Given that this an Excel file you want to write protect, you'd be much better off using the built in capability of Excel for that. You can also assign a password as well if you wanted. Details below:
»bp
»bp
ASKER
Hi,
When i apply
Thank you
When i apply
attrib +R filename
on an excel file it converts it to read only mode. then I copy the file and paste manually, it retains the read only mode. But when I apply below code to migrate the excel file to another location, below code coverts the excel file into normal mode.ie the read only mode does not available. Please have a look. I like to see the read only mode on the file I exported using the code below.@echo off
setlocal
echo Start Copy
set SOURCE_DIR=C:\Reports\MonthlyReports
set DEST_DIRS="Y:\","S:\ Reports\"
set FILENAMES_TO_COPY="Report_New.xlsx"
pushd "%SOURCE_DIR%"
for %%F in (%FILENAMES_TO_COPY%) do (
for %%D in (%DEST_DIRS%) do (
echo file "%%~F" to "%%~D"
xcopy /Y "%%~F" "%%~D"
)
)
popd
echo. Done.
exit /b
Thank you
No version of DOS that I am aware of ships with any type of file encryption capability. Hence, there will be no "DOS" command line to do that. You require a third party application.
ASKER
Hi Bill, I have changed Xcopy to Robocopy on the above code. Nothing has happened.
Error: Invalid parameter after robocopy "/Y"
Thank you
A
Error: Invalid parameter after robocopy "/Y"
Thank you
A
You need to change the syntax to
robocopy . "%%~D" "%%~F"
In fact, this should be sufficient@echo off
setlocal
echo Start Copy
set SOURCE_DIR=C:\Reports\MonthlyReports
set DEST_DIRS="Y:\","S:\ Reports\"
set FILENAMES_TO_COPY="Report_New.xlsx"
for %%D in (%DEST_DIRS%) do robocopy %SOURCE_DIR% "%%~D" %FILENAMES_TO_COPY /njs /njh
echo. Done.
exit /b
@Asatoma, likely best to close out this question, as there are several answers to your original question.
Then open another question about how to do file copy operations + preserve file attributes.
Then open another question about how to do file copy operations + preserve file attributes.
ASKER
Thanks
You can password protect entire folders...
Open in new window
Or use zip to encrypt a file...
Open in new window
Or openssl to encrypt a file...
Open in new window