How can we lock folder using Command Prompt, without setting the user permissions and without using the attrib command either.
First goto the folder directory and then type cacls folder_name /e /p everyone:n to lock and
cacls folder_name /e /p everyone:f to unlock.
Related
I'm playing around with hacking on my virtual machine and in that tried to delete a folder which Windows created by default - "Videos" or "Documents", etc.
I would like to delete that folder from the cmd (I tried as an admin) but it doesn't seem to work. When deleting it from the GUI there were no issues.
I tried the following:
rmdir /s /q folderpath
And always get: Access is denied
start cmd in admin mode
takeown /F C:\{folder-name}\* /R /A
icacls C:\{folder-name}\*.* /T /grant administrators:F
rmdir /S /Q C:\{folder-name}\
From this StackOverflow answer:
RMDIR or RD if you are using the classic Command Prompt (cmd.exe):
rd /s /q "path"
If it tells you you have no access/permission to remove the directory, it's most likely an important Windows directory you shouldn't remove. You could try opening the CMD as Administrator, but be sure to check that it's safe to delete the folder.
I'm setting up a pair of logon and logoff scripts that will download and upload the users Outlook signatures automatically to and from their home directory (Z:\ drive).I'm using the scripts below, which work fine when run manually, but do not seem to be running at all (or at least not working) when set up as logon and logoff scripts with group policy. I have verified with gpresult that the scripts are indeed applied.
Logon Script (to download signatures):
#echo off
set LOGFILE=Z:\batch.log
call :LOG >> %LOGFILE%
exit /B
:LOG
if exist "Z:\Signatures\" (
xcopy /e /Y /D Z:\Signatures %appdata%\Microsoft\Signatures
)
Logoff Script (to upload signatures):
#echo off
set LOGFILE=Z:\batch.log
call :LOG >> %LOGFILE%
exit /B
:LOG
if not exist "Z:\Signatures\" (
mkdir Z:\Signatures
attrib +h Z:\Signatures /s /d
)
xcopy /e /Y /D %appdata%\Microsoft\Signatures Z:\Signatures
Does anyone have an idea why this wouldn't be working?
Fixed by using %homeshare% instead of the mapped Z:\ drive
How to change permission of all files with extension .pyc in a folder and its sub-folder?
individually it will be like this:
c:\folder1> cacls *.pyc /P everyone:F
c:\folder1\a> cacls *.pyc /P everyone:F
c:\folder1\b> cacls *.pyc /P everyone:F
and so on.
Try Following code:
icacls filename /grant everyone:F /T
/T works for me.
I'm trying to find a way using, hopefully, a batch file to copy a modified user profile to the default user profile so that any user that logs in to the computer will adopt the profile setup. We're using a utility called pGina to call the default profile for a user logged in through a RADIUS server, as opposed to having the user log in to the domain directly. Currently, we're trying to use robocopy for this.
cd C:\Users\
rmdir Default /s /q
robocopy /COPY:DAT /R:5 /E C:\Users\user1 C:\Users\Default
pause
Does anyone have any idea how to successfully copy the profile? Thanks in advance.
This is what I found when searching for an answer to your problem
rem delete old Default User profile
RD /s /q "%systemdrive%\Profiles\Default User"
rem copy current user profile to default user profile
xcopy "%USERPROFILE%\*.*" "%systemdrive%\Profiles\Default User" /e /c /I /H /R /K /Y
rem delete non-need some files
del /f /q "%systemdrive%\Profiles\Default User\*.*"
rem set default attributes
attrib +h "%systemdrive%\Profiles\Default User"
rem registry trick
rem no directly copy locked ntuser.dat file
rem use reg tools to save current user registry to file
reg save HKCU "%systemdrive%\Profiles\Default User\ntuser.dat"
rem set default attributes to hive file
attrib +H +S "%systemdrive%\Profiles\Default User\ntuser.dat"
I need to know how to program a batch file to prompt user for source and destination paths.
Once paths are entered by the user, the application will copy all files/folders
from [SOURCE] to [DESTINATION]
The solution should not require any user input beyond source and destination paths
It should use a system of variables to contain the paths
It should log copy process
So far i have :
xcopy "c:\source" "c:\destination" /e /h /k /o
pause
Set command can take input from user: set /p source=Enter Source path.
Read help (set /?) for more information.
set /p source=Enter Source path
xcopy %source% "c:\destination" /e /h /k /o