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!

[batch] obtaining owner ( tokens, delims )

Status
Not open for further replies.

0318

Programmer
Jan 18, 2004
25
0
0
NL
hello.
when i run a script to obtain the owner of a file, i get more then only the owner.
here an example of a output:
BUILTIN\Administrator

or

Domain\MyUsername

u must know, i only need the username offcourse, thats the owner. so let say all users will be obtained like 'Domain\Username' then 'Domain\' must be deleted..
i guess that happends with codes like tokens and delims but i dont know anything about that. can someone give me a example.?
 
Hello 0318,

Suppose the %ownerspec% is the name of the variable holding the owner in the form of domain\username, then you can store the strip down info username in %ownername% like this:
Code:
for /f "token=2 delims=\" %%u in ('%ownerspec%') do set ownername=%%v
It is for batch file, else use % instead of doubling up.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top