Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8985089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:15:28+00:00 2026-06-15T21:15:28+00:00

I am trying to create a batch file to read a Microsoft Access .ldb

  • 0

I am trying to create a batch file to read a Microsoft Access .ldb lock file. The lock file contains a list of computer names and user names. I want to extract the computer names and eventually run them against an external command.

The format of the batch file is a single row with
(1) a computer name
(2) a NULL character (Hex 00)
(3) approximately 20 spaces
(4) the user name
(5) a NULL character
(6) approximately 20 spaces
repeating.

Example in Notepad++ with (NUL) representing Hex 00:

COMPUTER0123(NUL)                     Admin(NUL)                     COMPUTER0507(NUL)                     Admin(NUL)

I’ve tried several methods using FOR to read the file but can’t get past the first computer name.

setlocal EnableDelayedExpansion
set file=database.ldb

for /F %%a in ('type %file%') do (
    echo %%a
    )

For for most of my Access databases, the user name in the file is Admin. I’ve been able to use FIND to tell me how many occurrences of “Admin” are in the file (plus 1).

for /f "delims=" %%n in ('find /c /v "Admin" %file%') do set "len=%%n"
set "len=!len:*:=!"
echo %len% (minus 1) computer names to process 
<%file% (
  for /l %%l in (1 1 !len!) do (  
    set "line="
    set /p "line="
    echo(!line!)    
    )
)

Iterating through the found lines doesn’t work, probably because there only is one line in the file (no carriage returns).

I would like to find a solution that would work with a standard install of Windows XP.


After receiving an accepted answer, I combined that into a batch file that I’m posting below. I named the file ShowUsersInLDB.bat and put it in my SendTo folder.

@echo off
::===================================================================
:: Put this in your SendTo folder and it will let you right-click 
:: on an Access .ldb/.laccdb lock file and tell you the computer
:: names that have opened the database.  
::
:: After the computer names are shown, this will prompt you to 
:: search for the user names associated with each computer.  This
:: depends upon finding a 3rd party file named NetUsers.exe in
:: the user profile folder.  Feel free to change the path if you
:: want to store the file in another location.
:: 
:: NetUsers.exe can be downloaded from here:  http://www.optimumx.com/downloads.html#NetUsers
::
:: Notes:
:: 1) Keep in mind that sometimes after people leave the database 
:: the lock file still shows their computer name.  Don't jump
:: to conclusions.
:: 2) NetUsers.exe seems to report all users who have logged on
:: to the computer and not logged off, including services.  
:: If you aren't familiar with your user names or your users are
:: sharing remote desktops/Citrix/Terminal Services, you may have 
:: to guess who might have created the lock entry. 
::
:: Installation:
:: You may find a batch file named Install_UsersInLDB.bat that will 
:: copy this file to the SendTo folder and the NetUsers.exe file to 
:: the user profile (or a place you define).
::
:: Ben Sacherich - March 2014
:: Please let me know if you have any ideas for improvements.
::===================================================================

setlocal
set file="%1"

:: Make sure the file has a compatible extension.
if  "%~x1"==".ldb"    goto :ExtensionIsValid
if  "%~x1"==".laccdb" goto :ExtensionIsValid

echo.
echo "%~n1%~x1" is not the correct file type.
echo.
pause
goto :End

:ExtensionIsValid
echo The Access "%~n1%~x1" file contains
echo the following computer names:
echo.
set "compNameLine=1"
for /f %%A in ('more "%file%"') do (
  if defined compNameLine (
    echo %%A
    set "compNameLine="
  ) else set "compNameLine=1"
)

echo.
echo Are you ready to look up the user names on each computer?
pause

set "compNameLine=1"
for /f %%A in ('more "%file%"') do (
  if defined compNameLine (
    ::echo %%A
    "%userprofile%\netusers" \\%%A
    set "compNameLine="
  ) else set "compNameLine=1"
)

echo.
echo -- Validation finished at %time%  
pause
:End
exit
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:15:28+00:00Added an answer on June 15, 2026 at 9:15 pm

    CMD.EXE generally does not play nicely with NUL bytes. But there are a few external commands that can handle NUL bytes.

    You also have to worry about the length of the “line”. CMD.EXE does not like lines longer than 8191 bytes long.

    I think your best bet is MORE since it converts NULs into new lines.

    The following should echo your computer names.

    @echo off
    setlocal
    set "file=database.ldb"
    set "compNameLine=1"
    for /f %%A in ('more "%file%"') do (
      if defined compNameLine (
        echo %%A
        set "compNameLine="
      ) else set "compNameLine=1"
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a batch file to create a new user and
I'm trying to create a batch file which will loop around a list of
I'm trying to create a batch file that will convert an Excel file to
I am trying to create a simple batch file that will replace a line
I am trying to create a batch file that searches a folder for zipped
I am trying to create a batch file to parse a directory Z:\ (not
I trying to create a bat file using csharp which contains some commands. So
Trying to create a batch (cmd) file for backing up each database into a
I am trying to create a batch file that will loop a random number
I'm trying to create a large popup window from a batch file to display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.