JSI Tip 4767. What user folders exit for which there is no account?


If you run UserFolder.bat on your local computer, it will report on local accounts. If you run it on the PDC emulator, it will report domain accounts.

The Syntax is:

Userfolder LocalPath ReportFile

where:

LocalPath is the full path to the parent user folder.

ReportFile is the full path to the output file.

Examples:

Userfolder "C:\Documents and Settings" "C:\Folder\Report.txt

Userfolder "D:\Users" "C:\Folder\Report.txt

UserFolder.bat contains:

@echo off
setlocal
if \{%1\}

\{\} goto syntax if \{%2\}

\{\} goto syntax set report=%2 if exist %report% del /q /f %report% pushd %1 for /f "Tokens=*" %%i in ('dir /b /ad') do call :usr "%%i" popd endlocal goto :EOF :syntax @echo Syntax: Userfolder Path Report endlocal goto :EOF :usr if /i %1 EQU "All Users" goto :EOF if /i %1 EQU "Default User" goto :EOF set folder=%1 call :getuser %folder%>>nul 2>>&1 goto :EOF :getuser for /f "Tokens=1,2*" %%a in ('net user %folder%') do if "%%a"

"User" if "%%b"

"name" set usr="%%c" if /i %usr% EQU %folder% goto :EOF @echo %folder%>>%report%


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish