Can anyone tell me how can I list Directories and files on a remote computer using PSEXEC?

I issue the following commands :

PSEXEC \\remote_computer\ dir c:\

It returns with an error : "The system can not find the file specified"

Dir is a DOS Shell command and built into or OS Shell.

Does PSEXEC retreives/interprets with DOS/Windows Internal commands?

LVL 35
Nirmal SharmaSolution ArchitectAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I confused as to why you would want to use psexec to list the files? Could you not use dir \\remote_computer\c$ from a command prompt?
Nirmal SharmaSolution ArchitectAuthor Commented:
I know I can use above commands...I just have an query regarding how PSEXEC interacts with DOS internal commands since they are not created physically but exists logically.
David LeeCommented:
Greetings, SystmProg.

Since DIR is an internal command you have to call and pass it parameters.  Something like this:

PSEXEC \\remote_computer c:\windows\system32\ /c dir c:\

Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

Nirmal SharmaSolution ArchitectAuthor Commented:
Well, I'm not sure if that command works or not but it looks like it should work.

BTW: when I run the above command I get the following error:

login failure or bad password.

I have tried using -u user_name and -p password but to no avail.
Nirmal SharmaSolution ArchitectAuthor Commented:
Ok the above command runs without any exit code 0 but doesn't list anything...

It should list Directories of remote computer....I have also tried using > file_name.txt
Jeff BeckhamEngineerCommented:
The command "psexec \\<remote_computer> cmd.exe /c dir" works for me.  If you're having authentication problems, you should be able to use either the -s flag or -u in combination with -p.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nirmal SharmaSolution ArchitectAuthor Commented:
Not but CMD.exe.

Thanks for putting me on right track.
Nirmal SharmaSolution ArchitectAuthor Commented:
BTW: I don't have authentication problem. I'm specifying NetBIOS name of computer name. I should put FQDN so that authentication can be handled by Kerberos.

NetBIOS leads to broadcast - sometimes it is able to authenticate and sometimes not.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.