Computing.Net > Forums > Programming > complex xcopy n password batchfile

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

complex xcopy n password batchfile

Reply to Message Icon

Name: alwaysk2
Date: July 30, 2008 at 08:58:53 Pacific
OS: 2000 Server
CPU/Ram: 2.8
Product: IBM
Comment:

Hi... i m trying to make a batch file which will move my (2 files on 2 different servers which are in C:test.log) log files on server's c:\backup. It will rename it to current date_in.log & in Current date_out.log format after that it will copy those renamed files on my local pc from where ill be executing this batch file.

well what worse i need is it will ask for a user name after matching specific user name it will execute the batch file otherwise it will exit.


what i have managed to make so far is here
===========================================
@echo off
setLocal EnableDelayedExpansion
set Pdate=%date:~4,2%%date:~7,2%%date:~10,4%%1
COLOR 1f
REM ECHO ---- THIS PROGRAM MUST RUN BY THE SYSTEM

ADMINISTRATOR ONLY ----

echo.
echo.
echo.
echo.
echo.
set cmd=xcopy /q /s /c /d /e /h /i /r /y
set a=\\server1\c$\test.log
set b=\\server1\c$\backup\
set c=\\server2\c$\test.log
set d=\\server2\c$\backup\
set e=c:\backuplogs

move /y %a% %b%\%Pdate%_in.log
Move /y %c% %d%\%Pdate%_out.log

%copycmd% %b%\%Pdate%_in.log %e%
%copycmd% %d%\%Pdate%_out.log %e%

pause>NUL
==================================
first of all above stated also not working hehe sorry for that... and the main thing what to add so that it can ask for the specified usernames and than executes itself or else exit..

like if i enters username testuser which is already in our batch file, if the username matches if will go further otherwise it will exit the batch program..

you kind help would be highly appreciated.

thank you

Chow....!!!



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: July 30, 2008 at 15:38:37 Pacific
Reply:

I suppose this next line is intended to avoiding typing the xcopy syntax.
[1] Using an internal or external command like CMD is a BAD idea.
[2] xcopy is not what you need.

set cmd=xcopy /q /s /c /d /e /h /i /r /y


::===========================
What you need is:

copy %b%\%Pdate%_in.log %e%
copy %d%\%Pdate%_out.log %e%

==================================
To get and check user:

set /p UN= user name ?
if not !UN!'==testuser' goto :eof


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: alwaysk2
Date: July 31, 2008 at 06:44:22 Pacific
Reply:

thanx for yo help...

actually i tried the way you told me but getting this kind of errors when i enters today's date

============================================
PLEASE ENTER DATE : - 07312008
The system cannot find the file specified.
'"\07312008_in.log"' is not recognized as an internal or external command,
operable program or batch file.
'"\07312008_out.log"' is not recognized as an internal or external command,
operable program or batch file.
=============================================

and sorry i wrote the cmd variable actually it was copycmd variable i just 4got to put copy as i know dat to make a system command or predefined variable is not allowed... but still its not copying...

Chow....!!!


0

Response Number 3
Name: Mechanix2Go
Date: July 31, 2008 at 06:59:02 Pacific
Reply:

So what have you got now?


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 4
Name: alwaysk2
Date: July 31, 2008 at 07:55:23 Pacific
Reply:

ACTUALLY let me put here my whole file so that you can understand


================================
set /p UN= user name ?
if not !UN!'==testuser' goto :eof
if EXIST goto DO

set call1=xcopy /q /s /c /d /e /h /i /r /y


set f=\\admin3\c$\IACopyL*.log

set h=\\admin3\c$\IAcopylog_IN

set e=\\admin\c$\IACopy.Log

set g=\\admin\c$\IAlog_out\

set a=C:\backup\logs\


REM COPYING LOG FILES TO THEIR SPECIFIC LOCATIONS (PLEASE REFER THE PATH

OF THE VARIABLES FOR THE LOCATIONS)
rem color ba
:DO
%call1% %f% %a%
%call1% %e% %a%

REM RENAMING THE LOG FILES WITH CURRENT DATE
ren %a%\IACopyLog.log %Pdate%_in.log
ren %a%\iacopy.log %Pdate%_out.log

%call1% %a%\%Pdate%_in.log %h%
%call1% %a%\%Pdate%_out.log %g%

rem i have put remark so that it wont delete in testing batch file later on it will be unremarked
rem del /s /q "%f%"
rem del /s /q "%e%"

=======================================

so when i executes it asks me to enter username but after that its doing NOTHING

if i disables entering username to test further... the xcopy command also not working at all... i tried to copy command but my senior told me that what will be the ERRORCONTROL to you copy or move command... now i dont know what to answer them... or how to solve dis out... actually we are having 5 ADMINISTRATORS working 24/7 so i need to put all 5's usernames to this file dat also i need to manage and put them in a log file which will show us that who had run the batch file at wat time... i think its being much complex now.. hhehehe sorry if i am asking a lot...


so if i want to use copy or move command rather than xcopy than how to set the errorcontrol which will tell me that here the batch file got the errors or sumthing like that.
so now wat you say... !

Chow....!!!


0

Response Number 5
Name: Mechanix2Go
Date: July 31, 2008 at 08:24:56 Pacific
Reply:

What is this trying to do:

if EXIST goto DO


=====================================
If at first you don't succeed, you're about average.

M2


0

Related Posts

See More



Response Number 6
Name: alwaysk2
Date: July 31, 2008 at 10:11:31 Pacific
Reply:

yea if a user enters username testuser than it will execute the commands or else it will exit did i made it right or its wrong ?


or else guide me how can i specify 5 usernames which will be entered by USER and if from those 5 usernames any username is not in list than it will exit otherwise it will execute the batch file by verifying the username which is entered by USER
K2™
System/Network Engineer


0

Response Number 7
Name: Mechanix2Go
Date: July 31, 2008 at 10:21:11 Pacific
Reply:

same question


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 8
Name: alwaysk2
Date: July 31, 2008 at 21:55:09 Pacific
Reply:

not getting your point dear... do you want me to remove that or sumthing else...?

K2™
System/Network Engineer


0

Response Number 9
Name: Mechanix2Go
Date: July 31, 2008 at 22:03:24 Pacific
Reply:

What is this trying to do:

if EXIST goto DO


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 10
Name: alwaysk2
Date: August 1, 2008 at 05:45:58 Pacific
Reply:

yea if the username exists dan it will point itself to DO string which is written in batch file

K2™
System/Network Engineer


0

Response Number 11
Name: alwaysk2
Date: August 2, 2008 at 08:30:04 Pacific
Reply:

Okie... i have managed that thing to verify the username now... but can you guide me how can i make it a LOG file in which it will save a log file which user had run the batch file on which date ?


========================
set /p UN= PLEASE PROVIDE YOUR IDENTIFICATION :-
if /I %UN%'==testuser1' CALL :do
if /I %UN%'==testuser2' CALL :do
if /I %UN%'==testuser3' CALL :do
if /I %UN%'==testuser4' CALL :do
if /I %UN%'==testuser5' CALL :do
if /I %UN%'==testuser6' CALL :do
) ELSE
goto :error
)
========================

K2™
System/Network Engineer


0

Response Number 12
Name: Mechanix2Go
Date: August 2, 2008 at 08:50:22 Pacific
Reply:

>> %UN% echo %date%


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 13
Name: alwaysk2
Date: August 2, 2008 at 08:58:26 Pacific
Reply:

where to put it bro... i m not getting it

K2™
System/Network Engineer


0

Response Number 14
Name: alwaysk2
Date: August 7, 2008 at 06:48:27 Pacific
Reply:

okie... i have managed this issue and completed my self.. ill post the whole batch file tomorrow as rite now m not at my job.

thanks a lot for your support dear

K2™
System/Network Engineer


0

Response Number 15
Name: alwaysk2
Date: August 7, 2008 at 20:39:05 Pacific
Reply:

here is the batch file i managed to make so far for any one who wants to use it

=================
@echo off
TITLE GENERATE LOG -

set Pdate=%date:~4,2%%date:~7,2%%date:~10,4%%1
COLOR 1f

NET USE K: \\server1\C$
cls
NET USE j: \\server2\C$
cls
echo.
ECHO ---- THIS PROGRAM MUST RUN BY THE SYSTEM ADMINISTRATOR ONLY ----
echo.
echo.
echo.
echo.
echo.

echo.
echo.
echo.
echo.
echo.

set /p UN= PLEASE PROVIDE YOUR IDENTIFICATION :-
if /I %UN%'==testuser1' CALL :do
if /I %UN%'==testuser2' CALL :do
if /I %UN%'==testuser3' CALL :do
if /I %UN%'==testuser4' CALL :do
if /I %UN%'==testuser5' CALL :do
if /I %UN%'==testuser6' CALL :do
) ELSE
goto :error
)
REM COPYING LOG FILES TO THEIR SPECIFIC LOCATIONS
color ba
:DO
k:
MOVE /Y test.log K:\locopy~1\%Pdate%_in.log
copy /y K:\locopy~1\%Pdate%_in.log "C:\Logs\brd" >>"C:\Logs\%Pdate%_%UN%.LOG"
cls
j:
MOVE /Y iacopy.log J:\IAlog_~1\%Pdate%_out.log >>C:\TEST.LOG
copy /y J:\lolog_~1\%Pdate%_out.log "C:\Logs\brd" >>"C:\Logs\%Pdate%_%UN%.LOG"
cls

NET USE K: /delete /y
CLS
NET USE j: /delete /y


COLOR 1f

echo.
echo.
REM GENERATING OUTPUT TO ADMINISTRATOR THAT THE TASK SUCCESSFULLY COMPLETED
echo - LOGS HAVE BEEN SUCCESSFULLY GENERATED -
echo --------------------
echo.
echo.
echo.
echo.
echo.
echo -- THANK YOU "%UN%" PLEASE PROCESS TAT NOW --
echo.
echo ---- PRESS ANY KEY TO EXIT ----
pause>NUL
exit


:error
NET USE K: /delete /y
CLS
NET USE j: /delete /y
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo.
ECHO ---- "%un%" YOU ARE NOT ALLOWED TO PROCESS LOG FILES ----
echo.
echo.
echo.
echo ---- PLEASE CONTACT SYSTEM ADMINISTRATOR----
echo.
pause>NUL
==========================

I hope any one can suggest me any ideas for how can I manage to as ask this batch file the Active Directory user names and passwords i think its not possible by batch file or else any one had done before can suggest something.

K2™
System/Network Engineer


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: complex xcopy n password batchfile

hiding a password in C++ www.computing.net/answers/programming/hiding-a-password-in-c-/3514.html

Password hiding in C++ www.computing.net/answers/programming/password-hiding-in-c/4439.html

freeze desktop www.computing.net/answers/programming/freeze-desktop/12158.html