Using standard commands, I have scripted PrntUsrCpr.bat to return the distinguished names of the logged on user, it's OU or container,
the logged on computer, and it's OU or container, using standard commands.
The syntax for using PrntUsrCpr.bat is:
\[Call\] PrntUsrCpr UserDN UserPrnt ComputerDN ComputerPrnt
Where:
UserDN is a call directed environment variable that will contain the quoted distinguished name of the logged on user. UserPrnt is a call directed environment variable that will contain the quoted distinguished name of the user's OU or container. ComputerDN is a call directed environment variable that will contain the quoted distinguished name of the computer that the user is logged on from. ComputerPrnt is a call directed environment variable that will contain the quoted distinguished name of the computer's OU or container.PrntUsrCpr.bat contains:
@echo off if \{%4\}==\{\} @echo Syntax Call PrntUsrCpr UserDN UserPrnt ComputerDN ComputerPrnt&exit /b 1 if exist "%TEMP%\PrntUsrCpr.vbs" goto doit @echo DIM IUsr, UsrP, Cmp, CmpP>"%TEMP%\PrntUsrCpr.vbs" @echo Set objSysInfo = CreateObject("ADSystemInfo")>>"%TEMP%\PrntUsrCpr.vbs" @echo set objUser = GetObject("LDAP://" ^& objSysInfo.UserName)>>"%TEMP%\PrntUsrCpr.vbs" @echo Set objComputer = GetObject("LDAP://" ^& objSysInfo.ComputerName)>>"%TEMP%\PrntUsrCpr.vbs" @echo Usr = objSysInfo.UserName>>"%TEMP%\PrntUsrCpr.vbs" @echo Cmp = objSysInfo.ComputerName>>"%TEMP%\PrntUsrCpr.vbs" @echo UsrP = Replace(objUser.Parent, "LDAP://", "")>>"%TEMP%\PrntUsrCpr.vbs" @echo CmpP = Replace(objComputer.Parent, "LDAP://", "")>>"%TEMP%\PrntUsrCpr.vbs" @echo Wscript.Echo Usr ^& ";" ^& UsrP ^& ";" ^& Cmp ^& ";" ^& CmpP>>"%TEMP%\PrntUsrCpr.vbs" :doit for /f "Tokens=1-3* Delims=;" %%c in ('cscript //Nologo "%TEMP%\PrntUsrCpr.vbs"') do ( set %1="%%c" set %2="%%d" set %3="%%e" set %4="%%f" ) exit /b 0
0 comments
Hide comments