Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Permissions in cmd prompt

Status
Not open for further replies.

Crundy

Programmer
Jul 20, 2001
305
0
0
GB
Does anyone know how I can change file permissions in a windows command prompt? <--&quot;Didn't your code work? You must have made a mistake when you pasted it.&quot; - Mark Hazen-->

If this post was useful to you, click the link below
 
Depends what you want to do? If you want to view or change the files attributes then use attrib this allows you to set read only hidden system and archive attributes.
If you want to change user rights to files then you can use CACLS which will allow you to set user permissions on group or user level. If you type either command followed by /? it will out put the syntax and parameters.
Hope this helps
Chris

 
Excellent, thanks.
One more question: How do you do a whoami in the command prompt? <--&quot;Didn't your code work? You must have made a mistake when you pasted it.&quot; - Mark Hazen-->

If this post was useful to you, click the link below
 
Use a command called CACLS



CACLS filename [/T] [/E] [/C] [/G user:perm] [/R user [...]]
[/P user:perm [...]] [/D user [...]]
filename Displays ACLs.
/T Changes ACLs of specified files in
the current directory and all subdirectories.
/E Edit ACL instead of replacing it.
/C Continue on access denied errors.
/G user:perm Grant specified user access rights.
Perm can be: R Read
W Write
C Change (write)
F Full control
/R user Revoke specified user's access rights (only valid with /E).
/P user:perm Replace specified user's access rights.
Perm can be: N None
R Read
W Write
C Change (write)
F Full control
/D user Deny specified user access.
Wildcards can be used to specify more that one file in a command.
You can specify more than one user in a command.

Joseph L. Poandl
MCSE 2000


 
you can use this command
NET SESSION
or
NET NAME
the only advantage to NET SESSION is if you run it on a machine with multiple users it will list the client type and show all machine accounts with a $ after them
If you want to get this information for a batch job or command line the use the %username% variable which will insert this for you. ie

mybatch.bat %username%

for me would be the same as typing

mybatch.bat cnorris517

Finally if you aren't bothered by the format of the output but just want a quick and dirty way to identify your current user just type %username% at a command prompt. The system will respond with
'user' is not recognized as an internal or external command, operable program or batch file

user will be the currently logged on user id
 
Thanks. <--&quot;Didn't your code work? You must have made a mistake when you pasted it.&quot; - Mark Hazen-->

If this post was useful to you, click the link below
 
Another way to find out is to use the NBTSTAT command. Just type that with a /? and it'll give you all the help you'll need to find out who is logged on to a computer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top