Reg Query wiping computer when using remotely - batch-file

Recently I got a script to query the reg set a value and then delete folders under the folder I puled from the query. Looks like this:
pause
FOR /F "TOKENS=2*" %%I IN ('REG QUERY "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\14.0\Outlook\Security" /V OutlookSecureTempFolder') Do SET "ValueData=%%J"
pause
echo Delete Outlook Temp. Files???
echo Enter to continue or Ctrl+C to cancel.
pause
del /q /f /s "%valuedata%\*.*"
del /q /f /s "%systemdrive%\Jacob'sTemp"
pause
echo --------------------------------------------------------------------------------
echo Complete! Goodbye!
echo --------------------------------------------------------------------------------
timeout /t 3
Works great when used locally. So I set up a robo copy to copy a folder with this script in it then use psexec to execute it remotely and it looks like this:
set /p cpu=
robocopy "\\nmcfs01\software\scripts\Jacob's Awesome Outlook Scripts" \\%cpu%\c$\Jacob'sTemp
pause
psexec \\%cpu% -u administrator "%systemdrive%\Jacob'sTemp\outlooktempdelete.bat"
pause
Now it works and it will run but here is the kicker when it goes back to the reg query batch to do the reg query it will run but it skips the 1st pause following the query and it always says it can not find the registry key but I can follow the path and it is there. The worst part is once I end the script there it wipes the computer of everything the user has access to. Not folders but all files/subfiles everywhere. Any insight is greatly appricated!

Here's a quick tidy up of your script:
#Echo Off
SetLocal EnableExtensions
(Set OV=14.0)
Choice /C YN /M "Delete Outlook Temp Files?"
If ErrorLevel 2 Exit/B
Set "BK=HKCU\SOFTWARE\Microsoft\Office\"
Set "EK=\Outlook\Security"
Set "VN=OutlookSecureTempFolder"
For /F "Tokens=2*" %%I In ('Reg Query "%BK%%OV%%EK%" /V %VN%') Do Set "VD=%%J"
PushD "%VD%" && (RD/S/Q "%VD%" 2>Nul) && PopD
REM The below commands will empty Jacob'sTemp:
If Exist "%SystemDrive%\Jacob'sTemp" (PushD "%SystemDrive%\Jacob'sTemp" && (
(RD/S/Q "%SystemDrive%\Jacob'sTemp" 2>Nul) && PopD
REM The below commands without the first two characters will remove Jacob'sTemp
::If Exist "%SystemDrive%\Jacob'sTemp" (RD/S/Q "%SystemDrive%\Jacob'sTemp"
Pause
Echo(------------------------------------------------------------------------------
Echo( Complete! Goodbye!
Echo(------------------------------------------------------------------------------
Timeout 5 >Nul
Give that a try exactly as it is just to see if it makes any difference.
I left the lonely but editable 'set' at the top because this is the only bit that need's changing to cater for earlier or later editions of outlook.

Related

How to ask for Admin with batch

I want to make a batch file which enables the Seconds in the Taskbar (There where you see the time).
I know you can do that manually when you open registry editor and go to
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
And create there a DWORD-Value (32-Bit) and name it ShowSecondsInSystemClock and set the value on 1 and then Restart the Computer.
But now I want to make this in a batch file and that the User gets asked to enter his Password (The Password of the Computer) to continue (to make sure it is really the owner of the Computer). Is there a way to do that?
I'm really new to batch and I have only done basic stuff until now, I'm collecting my first experiences with programming.
Refer to the comment above posted by #Compo:
You don't need admin rights to change this setting in registry
And you don't need to restart the computer, just restart the exploer process
#echo off
Title Show Or Hide Seconds In System Clock
Color 9E & Mode 80,10 & SetLocal EnableDelayedExpansion
Set "Key=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
::--------------------------------------------------------------------------
:GetInfo
#REM Get Opened Folders with PowerShell code in a batch file
Set PSCommand="#((New-Object -com shell.application).Windows()).Document.Folder | ForEach { $_.Self.Path }"
REM Populate the array with existent and opened folders
SetLocal EnableDelayedExpansion
Set /a Count=0
for /f "delims=" %%a in ('Powershell -C %PSCommand%') do (
Set /a Count+=1
Set "Folder[!Count!]=%%a"
)
::===========================================================================
:menuLOOP
::===========================================================================
echo(
echo(
echo( ***************************** Menu ******************************
echo(
#for /f "tokens=2* delims=_ " %%A in ('"findstr /b /c:":menu_" "%~f0""') do (
echo( %%A %%B)
echo(
echo( *****************************************************************
echo( &Set /p Selection=Make a Selection or hit ENTER to quit: || Goto :EOF
echo( & Call:menu_[%Selection%]
GOTO:menuLOOP
::===========================================================================
::---------------------------------
:menu_[1] Show Seconds In SystemClock
reg Add "%Key%" /V ShowSecondsInSystemClock /T REG_DWORD /D 1 /F 1>NUL
Call:Restart_Explorer
#rem Restore all closed folders
#for /L %%i in (1,1,%Count%) do Start /MAX Explorer "!Folder[%%i]!"
Exit /B
::---------------------------------
:menu_[2] Hide Seconds In SystemClock
reg Add "%Key%" /V ShowSecondsInSystemClock /T REG_DWORD /D 0 /F 1>NUL
Call:Restart_Explorer
#rem Restore all closed folders
#for /L %%i in (1,1,%Count%) do Start /MAX Explorer "!Folder[%%i]!"
Exit /B
::---------------------------------
:Restart_Explorer
powershell -C "gps explorer | spps"
Exit /B
::---------------------------------
Remark about alias used in PowerShell command to restart the explorer process:
gps is the Alias for Get-Process
spps is the alias for Stop-Process

Is there's a way to write a batch function to increment the value name of the registry?

I'm writing a batch file to add a new time server in windows which connects to my server(domain) and sync the device time with my server.
But in my devices, in some there are 2 time servers and in some more than 2 time servers. So I can't hard code the value name in the batch file and I need to come up with a way to get the value name from the registry(auto increment the value and assign it to the value name).
The code I wrote so far is as follows:
#echo off
reg add HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/DateTime/Servers /v 3 /t REG_SZ /d 13.127.xx.xxx
net stop w32time
w32tm /config /syncfromflags:manual /manualpeerlist:13.127.xx.xxx
net start w32time
w32tm /config /update
w32tm /resync /rediscover
#echo Time Sync Successful
pause
As you're already parsing the registry key from your batch-file, you may as well use it to perform the majority of the task. This, once you've updated the variable value on line 3, should:
Leave the key untouched if the server is already listed and set as default.
Change the server to be default if it is listed but not set as the default.
Add the server if it isn't listed and set it to be the default server.
Synchronise the time using the default server.
#Echo Off
SetLocal EnableDelayedExpansion
Set "TSvr=13.127.xx.xxx"
Set "RKey=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers"
Set "#=_=0"
Set "$="
For /F "EOL=HTokens=1-2*" %%A In ('"Reg Query "%RKey%" 2>Nul|Sort"')Do (
If "%%A"=="(Default)" (Set "DVal=%%C")Else If %%A Gtr !#! Set "#=%%A"
If "%%C"=="%TSvr%" Set "$=%%A")
If Defined $ (If "%DVal%"=="%$%" (Echo %TSvr% is already the default server.
GoTo End)Else (Echo %TSvr% is listed but not the currently the default.
Echo Setting it as the default entry...
Reg Add "%RKey%" /VE /D %$% /F>Nul 2>&1))Else (Set /A #+=1
Echo %TSvr% is not listed.
Echo Adding it and setting it as the default entry...
Reg Add "%RKey%" /V !#! /D "%TSvr%">Nul 2>&1
Reg Add "%RKey%" /VE /D !#! /F>Nul 2>&1)
SC Query state= inactive|Find "W32Time">Nul&&(Set "_=1"
SC Start W32Time>Nul 2>&1)
Echo Synchronising the time using %TSvr%.
W32Tm /ReSync>Nul
If %ErrorLevel%==0 (Echo %TSvr% was added and your time was synchronised to it.
)Else Echo %TSvr% was added but the time was not synchronised.
:End
Pause
If Defined _ SC Stop W32Time>Nul 2>&1
EndLocal
GoTo :EOF

RENAME function not renaming in batch script

EDIT: I have updated this post to include the entire script.
EDIT: While not ideal, this is meant to be an automation of a fix provided by the company that makes the software.
I have a batch file that I am running as Administrator.
I am running a batch file based on the file system input by the user.
One of the first commands renames a file.
If I execute this command on its own, from an elevated command prompt, it renames the file.
When I nest the command inside the IF statement, it doesn't rename the file.
I have commented out all of the other lines to simply rename the file if the user enters "1".
I have tried encapsulating the file path and file each individually within quotes, which I shouldn't need, and still do not get it to rename the file.
I am running the batch script as Admin.
#echo off
setlocal EnableDelayedExpansion
if "%$ecbId%" == "" (
echo Welcome to the ADaPT
echo Choose '1' for 32 bit
echo Choose '2' for 64 bit
echo Type anything else to abort.
echo.
set "UserChoice=abort"
set /P "UserChoice=Type your choice: "
if "!UserChoice!"=="1" (
echo Executing 32 bit sequence...
echo Regsvr32.exe /u C:\Windows\System32\MSCOMCTL.OCX
echo REN C:\Windows\System32\MSCOMCTL.OCX MSCOMCTL.bak
xcopy C:\install\MSCOMCTL.OCX C:\Windows\System32 folder
Regsvr32.exe C:\Windows\System32\MSCOMCTL.OCX
Regsvr32.exe /u C:\Windows\System32\MSCOMCTL.OCX
del "C:\Windows\System32\ MSCOMCTL.OCX"
echo REN "C:\Windows\System32\MSCOMCTL.bak" "MSCOMCTL.OCX"
Recho Regsvr32.exe C:\Windows\System32\MSCOMCTL.OCX
shutdown.exe /r /t 00
)
if "!UserChoice!"=="2" (
echo Regsvr32.exe /u C:\Windows\SYSWOW64\MSCOMCTL.OCX
echo REN "C:\Windows\SYSWOW64\MSCOMCTL.OCX" "MSCOMCTL.bak"
xcopy C:\install\MSCOMCTL.OCX C:\Windows\SYSWOW64 folder
Regsvr32.exe C:\Windows\SYSWOW64\MSCOMCTL.OCX
Regsvr32.exe /u C:\Windows\SYSWOW64\MSCOMCTL.OCX
del "C:\Windows\SYSWOW64\ MSCOMCTL.OCX"
echo REN "C:\Windows\SYSWOW64\MSCOMCTL.bak" "MSCOMCTL.OCX"
echo Regsvr32.exe C:\Windows\SYSWOW64\MSCOMCTL.OCX
REM... shutdown.exe /r /t 00
)
if not "!UserChoice!"=="1" (
echo toto3
if not "!UserChoice!"=="2" (
echo toto4
echo Unknown input ... Aborting script
endlocal
exit /B 400
)
)
)
endlocal
I have simplified your entire script structure so as not to require parenthesised blocks, or the need to delay expansion:
#Echo Off
If Defined $ecbId GoTo :EOF
Echo Welcome to the ADaPT
Choice /C CQ /M "Continue or Quit"
If ErrorLevel 2 GoTo :EOF
Set "Dest=TEM32"
Set PROCESSOR_ARCHITE|Find "64">Nul&&(Set Dest=WOW64)
Set "Dest=%SYSTEMROOT%\SYS%Dest%"
Echo Executing sequence . . .
RegSvr32 /U "%Dest%\MSCOMCTL.OCX"
Rem To backup and replace MSCOMCTL.OCX:
Rem Uncomment the next three unRemarked lines
Rem and comment the next three unRemarked lines below them.
::Del /A /F "MSCOMCTL.bak" 2>Nul
::Ren "%Dest%\MSCOMCTL.OCX" "MSCOMCTL.bak"
::XCopy "C:\install\MSCOMCTL.OCX" "%Dest%"
Rem To recover MSCOMCTL.OCX from the backup:
Rem Comment the next three unRemarked lines
Rem and uncomment the previous three unRemarked lines above them.
If Not Exist "MSCOMCTL.bak" RegSvr32 "%Dest%\MSCOMCTL.OCX" & GoTo :EOF
Del /A /F "%Dest%\MSCOMCTL.OCX"
Ren "%Dest%\MSCOMCTL.bak" "MSCOMCTL.OCX"
RegSvr32 "%Dest%\MSCOMCTL.OCX"
ShutDown /R /T 0 /D P:2:4
Notes:It is probably safe to delete lines 3 and empty line 4, I left them in only because no explanation was provided as to the purpose of the %$ecbId% variable value comparison.I have added Remarks for toggling the script for the backup or recovery methods, but not knowingly altered any of your command sequence, (I have however added the /A and /F options with Del, just in case, and included the /D option with ShutDown to ensure that the logs show it as a planned shutdown event).

Batch File Skipping over FOR LOOP

UPDATE
I removed the tokens=4 and it started outputting data. It is not skipping past the FOR LOOP. I was skipping too far ahead with the tokens. I am still a little confused as to why it works as a single batch and not from this batch but now at least I know what the issue was. Thank you to everyone that was looking into this for me.
I am writing a script to copy over data from one computer to another. The issue is that it is skipping over the FOR LOOP that I am calling from another FOR LOOP. If you are testing the script it requires two PC's and a mapped T: drive to somewhere on the second computer. I can write the script so it looks for an external drive if that is more helpful to someone.
FOR /F "tokens=4 skip=1" %%a in ('REG QUERY "%_regshell%" /v "%_regdesktop%"') DO (
SET _dt=%%a
echo robocopy "!_dt!" "!_NetworkDrive!\!_fndesktop!" !_params!
echo attrib -h -r "!_NetworkDrive!\!_fndesktop!"
)
If I write the FOR LOOP above in a batch by itself and just echo out %%a then it works without a problem. In this, I can see that it is indeed calling :_backup but it skips directly over the FOR Loop and I am not sure why. I have written scripts like this many times but never had any that just completely ignore the FOR Loop. Can anyone take a look and assist? Thank you.
#echo off
:: Set Variables
SET _driveID=T:
SET _params=/Z /E /COPY:DT /R:1 /W:0 /XD LocalService NetworkService temp "temporary internet files" winsxs Content.IE5 cache /XF ntuser.* *.tmp /XJ /FP /NC /NS /NP /NJH
SET _regshell=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
SET _regdesktop=Desktop
:: Set Current Directory
pushd %SystemDrive%\
:: Start Menu - Create Choices and Options. Send to various places to perform the actions.
:_start
cls
ECHO Please type either option 2 or 3 and then press ENTER on the keyboard?
Echo 2. TRANSFER FILES FROM DESKTOP TO LAPTOP
Echo 3. EXIT THE PROGRAM
echo.
set /p choice=Enter Number:
if '%choice%'=='2' goto _desktopToLaptop
if '%choice%'=='3' goto :EOF
echo "%choice%" is not a valid option. Please try again
echo.
goto _start
:: Detect Drive Letters
:_desktopToLaptop
setlocal EnableDelayedExpansion
FOR /F "usebackq skip=1" %%a IN (`WMIC logicaldisk where DeviceID^="%_driveID%" get caption`) DO (
SET _NetworkDrive=%%a
if exist %%a (
CALL :_backup
goto :EOF
) else (
echo.
echo The laptop does not appear to be attached to the computer.
echo.
pause
goto :EOF
)
)
:_backup
:: Detect the folder locations and begin to backup each location to the laptop.
FOR /F "tokens=4 skip=1" %%a in ('REG QUERY "%_regshell%" /v "%_regdesktop%"') DO (
SET _dt=%%a
echo robocopy "!_dt!" "!_NetworkDrive!\!_fndesktop!" !_params!
echo attrib -h -r "!_NetworkDrive!\!_fndesktop!"
)
echo we are past the for loop
pause
:: Return to directory program was run from
popd
If anyone else runs into this issue or something similar, check your tokens and your skip. Mine worked just fine as a single batch but when I included as a call I had to change the options from tokens=4 skip=1 to tokens=3* skip=2 in order to get the correct output.
The correct tokens in that FOR LOOPS should be:
#echo off
:: Set Variables
SET _driveID=T:
SET _params=/Z /E /COPY:DT /R:1 /W:0 /XD LocalService NetworkService temp "temporary internet files" winsxs Content.IE5 cache /XF ntuser.* *.tmp /XJ /FP /NC /NS /NP /NJH
SET _regshell=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
SET _regdesktop=Desktop
:: Set Current Directory
pushd %SystemDrive%\
:: Start Menu - Create Choices and Options. Send to various places to perform the actions.
:_start
cls
ECHO Please type either option 2 or 3 and then press ENTER on the keyboard?
Echo 2. TRANSFER FILES FROM DESKTOP TO LAPTOP
Echo 3. EXIT THE PROGRAM
echo.
set /p choice=Enter Number:
if '%choice%'=='2' goto _desktopToLaptop
if '%choice%'=='3' goto :EOF
echo "%choice%" is not a valid option. Please try again
echo.
goto _start
:: Detect Drive Letters
:_desktopToLaptop
setlocal EnableDelayedExpansion
FOR /F "usebackq skip=1" %%a IN (`WMIC logicaldisk where DeviceID^="%_driveID%" get caption`) DO (
SET _NetworkDrive=%%a
if exist %%a (
CALL :_backup
goto :EOF
) else (
echo.
echo The laptop does not appear to be attached to the computer.
echo.
pause
goto :EOF
)
)
:_backup
:: Detect the folder locations and begin to backup each location to the laptop.
FOR /F "tokens=3* skip=2" %%a in ('REG QUERY "%_regshell%" /v "%_regdesktop%"') DO (
SET _dt=%%a
echo robocopy "!_dt!" "!_NetworkDrive!\!_fndesktop!" !_params!
echo attrib -h -r "!_NetworkDrive!\!_fndesktop!"
)
echo we are past the for loop
pause
:: Return to directory program was run from
popd
Given that the main issue in your script appears to be the setting of a variable to the data within the defined registry key and value, you could use:
Set "_regshell=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
Set "_regdesktop=Desktop"
Set "_dt="
For /F "EOL=H Tokens=2*" %%A In ('Reg Query "%_regshell%" /V "%_regdesktop%"'
) Do Set "_dt=%%~B"
If Not Defined _dt GoTo :EOF
Echo "%_dt%"

Two For Loops Using %1 - Delayed Expansion?

My working batch file scans a long list of remote servers, copies anything there to a local server, checks the log file for a keyword, and if the keyword is found sends an email. I noticed it is always sending emails, even with a blank log file.
I discovered both FOR loops are using the %1 variable for their output - as seen in ECHO %1 and each line of the called :servermove. For lack of a better explanation it is not resetting %1 to null between loops.
I reviewed almost a dozen SO posts and am somewhat confident using SETLOCAL ENABLEDELAYEDEXPANSION would resolve this. That is where my understanding ends and I am unsuccessful thus far.
Here is the relevant code:
SET DATE=%date:~4,2%-%date:~7,2%-%date:~10,4%
SET HH=%time:~0,2%
SET MN=%time:~3,2%
SET TSTAMP=Time Run is %HH%%MN%
SET DATETIME=%DATE% at %HH%%MN%
SET LOGFILE="\\nt980a3\CreditFileImagesTransmission\LogFiles\%DATETIME%-File Move Log.txt"
SET MailDst=
SET MailSrc=
SET MailSrcName=Center to LDSD File Mover
SET OKMailSub=A Branch Has Sent You Some Files
ECHO %DATETIME% > %LOGFILE%
ECHO. >> %LOGFILE%
FOR /F "tokens=1" %%A IN (%~dp0SourceServers.txt) DO CALL :ServerMove %%A
:cleanuplogs
PUSHD "\\nt980a3\CreditFileImagesTransmission\LogFiles" &&(
FORFILES /S /M *.txt /D -45 /C "CMD /C DEL /Q #path"
) & POPD
:mailtest
FOR /F "tokens=*" %%A IN (%LOGFILE%) DO CALL :searchlog "%%A"
:searchlog
ECHO %1 | find "\\nt">NUL
IF NOT ERRORLEVEL 1 GOTO successmail
GOTO exit
:successmail
IF EXIST %temp%\to.txt DEL %temp%\to.txt
FOR %%a IN (%MailDst%) DO ECHO %%a>>%temp%\to.txt
"%~dp0sendmail.exe" /TO=%temp%\to.txt /FROM=%MailSrcName% ^<%MailSrc%^> /REF=%OKMailSub% /MESSAGE=%LOGFILE% /HOST=
:exit
EXIT
:ServerMove
DIR /S /B \\%1\CreditFileImagesTransmission\*.* >> %LOGFILE%
XCOPY /E /C /I /Y "\\%1\CreditFileImagesTransmission\*.*" "\\nt980a3\CreditFileImagesTransmission\%DATE%\%HH%%MN%\"
FOR /D %%P IN ("\\%1\CreditFileImagesTransmission\*.*") DO RMDIR "%%P" /Q /S
DEL /Q /S "\\%1\CreditFileImagesTransmission\*.*"
I tried changing :mailtest to use %%B in both instances but that also fails. Placing SETLOCAL ENABLEDELAYEDEXPANSION and its counterpart ENDLOCAL before one or the other loop and changing the %%A to !A! does not work either.
Would someone kindly point out the error in my ways and offer suggestions or resources that will help me resolve this?
%1 is the first parameter provided to the procedure - either from the command-line (in the main procedure) or the parameter following the procedure name in call :procedurename parameter1.
In your case, %1 to :servermove is an entry from SourceServers.txt and %1 to :searchlog is each line from %LOGFILE%.
Since you've censored your batch, what you've posted makes little sense. For instance, the :searchlogs routine will take the first line from %LOGFILE% and go to successmail or cleanlogs depending on whether that first line contains the target string \\nt. What it does from there, we can't tell.
We're faced with an XY problem - trying to fix a solution, not a problem.
First problem: Don't use date as a user-variable. It's a "magic variable" which contains the date but it's overridden by a specific set statement.
Having run :servermove for each entry in SourceServers.txt, you are
- accumulating a directory list from \CreditFileImagesTransmission\*.* on that server.
- copying those files to server nt980a3 with a date/timestamp but not including the source-servername so any duplicate name anywhere will overwrite an earlier version. I suggest you include %1 into your destination-name.
- deleting subdirectories
- deleting files.
I'd suggest you simply remove the directory \\%1\CreditFileImagesTransmission\, then re-create it.
I'd also suggest that you add an extra line
goto :eof
after the del /q /s... line. This will cause execution to be transferred to the end-of-file (the colon in :eof is required) and may seem superfluous, but it ensures that the routine has a defined endpoint - if you add a further routine, there is no way the :servermove routine will continue into your new code.
After each server has been processed, you proceed to the :cleanuplogs routine, which I presume deletes logs older than 45 days.
Your next statement is a real problem. What it will do is grab the very first line of the logfile (which contains "%DATE% at %HH%%MN%" with the date resolved as you've set at the start and it then processes this line in :searchlog; there is no \\nt in this line, so errorlevel is set to 1, and the batch proceeds to :EXIT (not a good label in my view, since it's a keyword); executes an exitand should terminate the batch.
This appears not to be what it is actually doing, and I'm at a loss to explain why.
I'd suggest changing
:mailtest
FOR /F "tokens=*" %%A IN (%LOGFILE%) DO CALL :searchlog "%%A"
:searchlog
ECHO %1 | find "\\nt">NUL
IF NOT ERRORLEVEL 1 GOTO successmail
GOTO exit
to
:mailtest
find "\\nt" %LOGFILE%>NUL
IF NOT ERRORLEVEL 1 GOTO successmail
:failmail
echo "\\nt" was found in the log
pause
GOTO exit
but I can't test that...
:mailtest
FOR /F "tokens=*" %%A IN (%LOGFILE%) DO CALL :searchlog "%%A"
You are missing a GOTO :EOF or similar goto here because it will drop through to the routine below once the above is finished.
:searchlog
ECHO %1 | find "\\nt">NUL
IF NOT ERRORLEVEL 1 GOTO successmail
GOTO exit
I feel you can not carry the %1 of first for loop to others. Try to transfer that to another variable like below.
:ServerMove
set servername=%1
DIR /S /B \\%servername%\CreditFileImagesTransmission\*.* >> %LOGFILE%
XCOPY /E /C /I /Y "\\%servername%\CreditFileImagesTransmission\*.*" "\\nt980a3\CreditFileImagesTransmission\%DATE%\%HH%%MN%\"
FOR /D %%P IN ("\\%servername%\CreditFileImagesTransmission\*.*") DO RMDIR "%%P" /Q /S
DEL /Q /S "\\%servername%\CreditFileImagesTransmission\*.*"
Cheers, G

Resources