Skip navigation

JSI Tip 7437. How do I list all the folders/files on my clients hard disk(s) in a logon script?


To list all the folders/files on your clients hard disk(s), you must determine what drives are hard disks.

In this sample scriptlet, I have chosen to record the information in the NETLOGON share of the validating domain controller, but you can modify the scriptlet to place the output anywhere that you have granted the user write permissions.

NOTE: This code assumes that all your clients are Windows NT-based (Windows NT, Windows 2000, Windows XP, Windows Server).

NOTE: This scriplet will only execute once per client computer, per %LOGONSERVER%.

NOTE: Chkntfs only executes on hard drives using any files system. If returns a failure on other drive types, causing the && to NOT execute the dir.

NOTE: You can alter the format of the dir by replacing the /b switch.

The scriptlet contains:

set saveit="%logonserver%\NETLOGON\%computername%.txt"
if not exist %saveit% for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
 chkntfs %%a: 2>nul>nul && dir %%a:\*.* /b /s>>%saveit%
)



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