Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.
@echo offREM create the vb script>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))REM extract todays date less 7 daysfor /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate = %%AREM tidydel evaluate.vbsREM break up the date into constituent partsREM Note - the date is parsing UK format dates,REM swap the MM and DD in the lines belowREM for US formatset MM=%OldestDate:~3,2%set DD=%OldestDate:~0,2%set YYYY=%OldestDate:~6,4%REM reconstruct US format with '-' separatorsset OldestDate=%MM%-%DD%-%YYYY%REM list the files that would be copied if we really were doing a copyREM force it to believe that the target NonExistentDirectory is a directoryREM and echo the name & time for eachfor /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.* NonExistentDirectory ' ) do echo %%A %%~tA
@echo offCD /d F:\FolderForFilesSet LogFile="d:\logs\NewFiles.Log"REM create the vb script>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))REM extract todays date less 7 daysfor /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate = %%AREM tidydel evaluate.vbsREM break up the date into constituent partsREM Note - the date is parsing UK format dates,REM swap the MM and DD in the lines belowREM for US formatset MM=%OldestDate:~3,2%set DD=%OldestDate:~0,2%set YYYY=%OldestDate:~6,4%REM reconstruct US format with '-' separatorsset OldestDate=%MM%-%DD%-%YYYY%REM add the new entry to the log>> %LogFile% Echo %DATE% %TIME% REM list the files that would be copied if we really were doing a copyREM force it to believe that the target NonExistentDirectory is a directoryREM and echo the name & time for eachfor /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.* NonExistentDirectory ' ) do call :ProcessEach %%AREM tidy up the log>> %LogFile% Echo ========================================goto :EOF:ProcessEach>> %LogFile% echo %%~fA %%~tAgoto :EOF
@echo offCD /d e:\picturesREM grab todays date into variablesset MM=%Date:~3,2%set DD=%Date:~0,2%set YYYY=%Date:~6,4%REM Add the date variables to the log nameREM putting the date in this order will sort the files sensiblySet LogFile="e:\NewFiles_%YYYY%-%MM%-%DD%.Log"REM create the vb script>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))REM extract todays date less 7 daysfor /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate = %%AREM tidydel evaluate.vbsREM break up the date into constituent partsREM Note - the date is parsing UK format dates,REM swap the MM and DD in the lines belowREM for US formatset MM=%OldestDate:~3,2%set DD=%OldestDate:~0,2%set YYYY=%OldestDate:~6,4%REM reconstruct US format with '-' separatorsset OldestDate=%MM%-%DD%-%YYYY%REM add the new entry to the log>> %LogFile% Echo %DATE% %TIME% REM list the files that would be copied if we really were doing a copyREM force it to believe that the target NonExistentDirectory is a directoryREM and echo the name & time for eachfor /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.* NonExistentDirectory ' ) do call :ProcessEach %%AREM tidy up the log>> %LogFile% Echo ========================================goto :EOF:ProcessEach>> %LogFile% echo %%~fA %%~tAgoto :EOF
set MM=%OldestDate:~3,2%set DD=%OldestDate:~0,2%set YYYY=%OldestDate:~6,4%REM reconstruct US format with '-' separatorsset OldestDate=%MM%-%DD%-%YYYY%
@echo offCD /d e:\picturesREM grab todays date into variablesset MM=%Date:~3,2%set DD=%Date:~0,2%set YYYY=%Date:~6,4%REM Add the date variables to the log nameREM putting the date in this order will sort the files sensiblySet LogFile="e:\NewFiles_%YYYY%-%MM%-%DD%.Log"REM create the vb script>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))REM extract todays date less 7 daysset OldestDate=for /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate=%%AREM tidydel evaluate.vbsREM break up the date into constituent partsREM Note - the date is parsing UK format dates,REM swap the MM and DD in the lines belowREM for US formatset MM=set DD=set YYYY=set MM=%OldestDate:~3,2%set DD=%OldestDate:~0,2%set YYYY=%OldestDate:~6,4%REM reconstruct US format with '-' separatorsset OldestDate=%MM%-%DD%-%YYYY%REM add the new entry to the log>> %LogFile% Echo %DATE% %TIME% REM list the files that would be copied if we really were doing a copyREM force it to believe that the target NonExistentDirectory is a directoryREM and echo the name & time for eachfor /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.* NonExistentDirectory ' ) do call :ProcessEach %%AREM tidy up the log>> %LogFile% Echo ========================================goto :EOF:ProcessEach>> %LogFile% echo %~f1 %~t1goto :EOF
@echo offCD /d e:\picturesREM grab todays date into variablesset MM=%Date:~3,2%set DD=%Date:~0,2%set YYYY=%Date:~6,4%REM Add the date variables to the log nameREM putting the date in this order will sort the files sensiblySet LogFile="e:\NewFiles_%YYYY%-%MM%-%DD%.Log"REM create the vb script>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))REM extract todays date less 7 daysset OldestDate=for /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate=%%AREM tidydel evaluate.vbsREM break up the date into constituent partsREM Note - the date is parsing YYYY-MM-DD format dates,set MM=set DD=set YYYY=set MM=%OldestDate:~5,2%set DD=%OldestDate:~8,2%set YYYY=%OldestDate:~0,4%REM reconstruct US format with '-' separatorsset OldestDate=%MM%-%DD%-%YYYY%REM add the new entry to the log>> %LogFile% Echo %DATE% %TIME%>> %LogFile% Echo Since : %OldestDate%REM list the files that would be copied if we really were doing a copyREM force it to believe that the target NonExistentDirectory is a directoryREM and echo the name & time for eachfor /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.* NonExistentDirectory ' ) do call :ProcessEach %%AREM tidy up the log>> %LogFile% Echo ========================================goto :EOF:ProcessEach>> %LogFile% echo %~f1 %~t1goto :EOF
>> %LogFile% echo %~f1 %~t1
[code]>> %LogFile% echo %~f1 %~t1
for /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.* NonExistentDirectory ' ) do call :ProcessEach "%%A"
>> %LogFile% echo End of LOGpausegoto :EOF:ProcessEach
net use p: /deletenet use p: \\computer name1\share namecall e:\batchfile.batnet use p: /deletenet use p: \\computer name2\share namecall e:\batchfile.batnet use p: /deletenet use p: \\computer name3\share namecall e:\batchfile.batnet use p: /delete
net use p:|find "Remote name">> %LogFile%
@echo offCD /d p:\REM grab todays date into variablesset MM=%Date:~3,2%set DD=%Date:~0,2%set YYYY=%Date:~6,4%REM Add the date variables to the log nameREM putting the date in this order will sort the files sensiblySet LogFile="e:\NewFiles_%YYYY%-%MM%-%DD%.Log"REM create the vb script>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))REM extract todays date less 7 daysset OldestDate=for /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate=%%AREM tidydel evaluate.vbsREM break up the date into constituent partsREM Note - the date is parsing YYYY-MM-DD format dates,set MM=set DD=set YYYY=set MM=%OldestDate:~5,2%set DD=%OldestDate:~8,2%set YYYY=%OldestDate:~0,4%REM reconstruct US format with '-' separatorsset OldestDate=%MM%-%DD%-%YYYY%REM add the new entry to the log>> %LogFile% Echo %DATE% %TIME%>> %LogFile% Echo Since : %OldestDate%net use p:|find "Remote name">> %LogFile% REM list the files that would be copied if we really were doing a copyREM force it to believe that the target NonExistentDirectory is a directoryREM and echo the name & time for eachfor /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.* NonExistentDirectory ' ) do call :ProcessEach "%%A"REM tidy up the log>> %LogFile% Echo ========================================goto :EOF:ProcessEach>> %LogFile% echo %~f1 %~t1goto :EOF
E:\>call e:\batchfile.batAccess is denied.Could Not Find P:\evaluate.vbsThe network connection could not be found.More help is available by typing NET HELPMSG 2250.Invalid number of parametersThere are open files and/or incomplete directory searches pending on the connection to p:.
Could Not Find P:\evaluate.vbs
Is it OK to continue disconnecting and force them closed? (Y/N) [N]:
echo Y|net use p: /delete
START /wait NET USE [driveletter:] \\ComputerName\ShareName
echo Y|net use p: /delete /yes
E:\>call e:\batchfile.batThe option / is unknown.The syntax of this command is:NET USE[devicename | *] [\\computername\sharename[\volume] [password | *]] [/USER:[domainname\]username] [/USER:[dotted domain name\]username] [/USER:[username@dotted domain name] [/SMARTCARD] [/SAVECRED] [[/DELETE] | [/PERSISTENT:{YES | NO}]]NET USE {devicename | *} [password | *] /HOMENET USE [/PERSISTENT:{YES | NO}]More help is available by typing NET HELPMSG 3506.Press any key to continue . . .
echo Y|net use p: /deleteSTART /wait NET USE p: \\server1\MDPRD\distributions\Inbound\70\70_Customer_flat\Archivecall e:\batchfile.batecho Y|net use p: /deleteecho Y|net use p: /deleteSTART /wait NET USE p: \\server1\MDPRD\distributions\P31\BW__RACUGRP\Archivecall e:\batchfile.batecho Y|net use p: /deleteSTART /wait NET USE p: \\server1\MDPRD\distributions\Archivecall e:\batchfile.batecho Y|net use p: /delete
@echo Y|net use p: /delete
START /wait e:\disconnect_P.bat
START /wait e:\disconnect_P.batSTART /wait NET USE p: \\server1\MDPRD\distributions\Inbound\70\70_Customer_flat\Archivecall e:\batchfile.batSTART /wait e:\disconnect_P.bat START /wait NET USE p: \\server1\MDPRD\distributions\P31\BW__RACUGRP\Archivecall e:\batchfile.batSTART /wait e:\disconnect_P.batSTART /wait NET USE p: \\server1\MDPRD\distributions\Archivecall e:\batchfile.batSTART /wait e:\disconnect_P.bat
@echo Y|net use p: /deleteexit
echo Y|net use y: /deleteSTART /wait NET USE y: \\server1\MDPRD\distributions\Inbound\70\70_Customer_flat\Archivecall e:\batchfile.batecho Y|net use y: /deletepauseecho Y|net use y: /deleteSTART /wait NET USE y: \\server1\MDPRD\distributions\P31\BW__RACUGRP\Archivecall e:\batchfile.batecho Y|net use y: /delete
E:\>echo Y | net use y: /deletey: was deleted successfully.E:\>START /wait NET USE y: \\server1\MDPRD\distributions\Inbound\70\70_Customer_flat\ArchiveE:\>call e:\batchfile.batThe device is being accessed by an active process. <---- here net use delete is failingMore help is available by typing NET HELPMSG 2404. Press any key to continue . .