|
Answer» Hello CH members
Im currently writing a SIMPLE batch file with the below two lines for now:
CODE: [Select]@echo off DIR C:\temp1%1 /s > output.txt
Yes very simple indeed. My purpose though is getting the folder contents of a user profile folder under c:\documents and settings\%USERPROFILE%\Desktop folder.
The 20 machines I am trying to output from have different usernames, is there a global string which can be used to suit the purpose of this batch file.
Could anyone please help with the above?This may help:
Code: [Select]dir "%userprofile%\desktop" /s > output.txt
%userprofile% should expand to C:\Documents and Settings\UserName The quotes are for the embedded spaces
Good luck. Thanks SW worked a treat. Heres the full batch script for, somenoe might find it useful
Code: [Select] for /f "tokens=1" %%a in (myList.txt) do ( ECHO ----------------------------------------- ECHO %%a ECHO ----------------------------------------- ECHO Searching for files... %%a start rclient %%a /R dir "%userprofile%\desktop" /s > c:\output.txt REM )
Modify the myList.txt with the list of machines your to CONNECT to.A little more to my question, I have successfully used the batch to search userprofiles on user PC's, I need now to figure out how to check the servers.
I cannot simply user the %USERPROFILE%\Desktop variable because these folders are located under c:\documents and settings\username\desktop.
Using c:\documents and settings\%USERPROFILE%\Desktop returns a blank output.
Any suggestions on how I could do this?I should really clarify my response...
Using the %userprofile%\desktop variable return contents of C:\documents and settings\Username\desktop on a PC but does not output the folder contents when running the batch file on a server.how about? Code: [Select]"c:\documents and settings\%username%\Desktop"Quote from: mat123 on February 11, 2011, 12:35:32 PM how about? Code: [Select]"c:\documents and settings\%username%\Desktop" Thanks mat123, this was the second variable I tried after %userprofile% and the output file is blank. So Im not sure why this wouldnt work on the server but works on the PC. Cd "c:\documents and settings\%username%\Desktop" Dir Pause I have tried the below and only gives the output of the folder the batch file executes in. e.g. c:\test
Code: [Select]start rclient %%a /R DIR Pause cd "c:\documents and settings\%username%\Desktop" /s > c:\test\output.txtRemove pause and cd from that and try againThe output file is the same... blank. I can do this for folders outside of documents and settings, Im beginning to think this could have a security restiction even though I have ADMINISTRATIVE rights from the account Im using.
|