dahhunter Posted September 16, 2009 Posted September 16, 2009 I have 400+ PC's that all have some log files i need to move off.. I want to make a script/Batch file that will do the following when the user logs in: Creates a Folder on a network share with the individual users name Moves the Log files from the Local PC to the create User folder Deletes the Local Files after the move Sounds simple enough.. Its the Creating a folder with the user name i cant figure out.. Im hoping its something simple.. Im trying to do this all with a batch file ATM.. THanks
ajbritton Posted September 16, 2009 Posted September 16, 2009 (edited) If you are using Windows batch commands then it will be something like; MD "\\servername\sharename\folder\%username%" This should work as long as the username does not contain any characters that are invalid in folder names. Without any error checking, the script will look something like; MD "\\servername\sharename\folder\%username%" COPY "Path to log file" "\\servername\sharename\folder\%username%" DEL "Path to log file" Edited September 16, 2009 by ajbritton
Hacksawbob Posted September 16, 2009 Posted September 16, 2009 MD "\\servername\sharename\folder\%username%" COPY /Y "Path to log file" "\\servername\sharename\folder\%username%" DEL /Q "Path to log file" will possibly overwrite log from previous login if the name is the same the user would need to have write permissions to the share and sub folders of course! which if they knew they could potentially access and delete
OutToLunch Posted September 17, 2009 Posted September 17, 2009 will possibly overwrite log from previous login if the name is the same the user would need to have write permissions to the share and sub folders of course! You could set the permissions to allow creation only and no deletion which would mitigate this slightly. To avoid overwriting log files, you could always tag the date onto the end of them - copy C:\blah\blah\log.txt \\server\blah\logs\%username%%date:/=-%.txt or if you wanted to get clever with it, copy C:\blah\blah\log.txt \\server\blah\logs\server\%date:~6,4%-%date:~3,2%-%date:~0,2%-%username%.txt which will give you the date at the start of the filename in a nice sortable order (YYYY-MM-DD) which if they knew they could potentially access and delete There's an awful lot of shares like that on the network which can't be avoided though - things like the Promissor exam software etc which demand a shared folder with full permissions.
dahhunter Posted September 17, 2009 Author Posted September 17, 2009 THanks for the answers guys.. I knew it was something simple, just having a brain fart..
ajbritton Posted September 17, 2009 Posted September 17, 2009 There's an awful lot of shares like that on the network which can't be avoided though - things like the Promissor exam software etc which demand a shared folder with full permissions. I really HATE it when suppliers/support staff ask you to set up Full Control when they obviously don't even understand what it means or implies. I have never seen any justification for Full Control for any application. Sorry. It's a pet peeve !! 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now