3

I'm not sure of the commands or syntax needed to complete this but I thought it would be easy considering what I need it to do. Essentially I want to search C:\users\ for .exe files and output the computer name, path file was found so I know the user, and the .exe file into a log. I've been playing with for loops and Find. I just discovered the path command so I'm trying to understand that and how it can be used.

I'm so jumbled I wouldn't even know how to code this. I just know some of the bits that would go in it but I don't know them well enough to make anything work out of it. Any assistance or guidance would help a lot.

Oh and if possible I'd like to omit searching the users /temp folders or at least ignore any that are found there so they aren't in the log file.

3
  • 1
    I was redirected here from stack overflow because I was told this wasn't a suitable question for them. The difference is that the first guy that responded was within a minute and he knew the solution but told me off instead. Here it just get's ignored... Commented Oct 1, 2014 at 16:14
  • Please take this in the helpful way it's meant: There's no doubt that lots of people can be rude and mean online (and offline as well!). However, asking a question on an online resource and then complaining in less than 15 minutes that you didn't get a response isn't going to help you get answers; for some questions it can take more time than that for someone to type up and check their answer, even if they see it immediately. Complaints such as yours are likely to annoy people who might otherwise be inclined to help and leave you to find your own solution.
    – GreenMatt
    Commented Oct 1, 2014 at 20:22
  • 1
    Yes. I understand. It was in frustration. I know he was just trying to guide me to get the help I was looking for. And I can definitely see how I came across as a whiny b. The lesson in patience has been learned. Commented Oct 2, 2014 at 13:11

1 Answer 1

8

To search folder C:\users\ for .exe files

dir C:\users\*.exe /s /b | find ^"temp^" /v /i | findstr /e .exe > UserExecutablePaths.txt

dir /s Lists the files in the folder and also the ones in the subfolders recursively.

dir /b Lists the subfolders/files names in bare format.

find /v exclude "temp" string

find /i not case sensitive

findstr /e : Matches the pattern .exe if at the end of a line

greater than ">" outputs to file UserExecutablePaths.txt

-EDIT-

Add computer name to file by using as you said echo %computername%

Use ampersand "&" to separate multiple commands on one command line and output to file change the greater than ">" from previous example to double ">>" so you dont overwrite the first output.

echo Computer Name = %computername% > UserExecutablePaths.txt & dir C:\users\*.exe /s /b | find ^"temp^" /v /i | findstr /e .exe >> UserExecutablePaths.txt
1
  • That makes so much sense. Thank you! I knew it would be simple. But I was lead down the wrong path. I was working with Fortfiles which works for just outputting the path of every .exe but anymore complicated I couldn't figure it out. Thanks for breaking everything down. It really helps with understanding how all these commands come together. Quick question. Say I also want the computer name put in the output, how would I work that in. Normally I'd do echo %computername% but I'm not sure where that would fit in. Commented Oct 1, 2014 at 17:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .