0 valutazioniIl 0% ha trovato utile questo documento (0 voti)
103 visualizzazioni23 pagine
The document discusses DOS batch tips and includes code examples for pushing and popping directories, setting variables, running FTP scripts, restoring database backups, and using command line parameters. It provides details on the ~ modifiers that can be used with command line arguments to expand them in various ways. The document appears to be an article about the top 10 tips for DOS batch scripts that includes code samples.
The document discusses DOS batch tips and includes code examples for pushing and popping directories, setting variables, running FTP scripts, restoring database backups, and using command line parameters. It provides details on the ~ modifiers that can be used with command line arguments to expand them in various ways. The document appears to be an article about the top 10 tips for DOS batch scripts that includes code samples.
The document discusses DOS batch tips and includes code examples for pushing and popping directories, setting variables, running FTP scripts, restoring database backups, and using command line parameters. It provides details on the ~ modifiers that can be used with command line arguments to expand them in various ways. The document appears to be an article about the top 10 tips for DOS batch scripts that includes code samples.
POPD Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 1 de 23 05/08/2014 10:12 a.m. set FTPADDRESS=ftp.myserver.com set SITEBACKUPFILE=FileToTransfer.zip set /p FTPUSERNAME=Enter FTP User Name: set /p FTPPASSWORD=Enter FTP Password: CLS > script.ftp USER >>script.ftp ECHO %FTPUSERNAME% >>script.ftp ECHO %FTPPASSWORD% >>script.ftp ECHO binary >>script.ftp ECHO prompt n :: Use put instead of get to upload the file >>script.ftp ECHO get %SITEBACKUPFILE% >>script.ftp ECHO bye FTP -v -s:script.ftp %FTPADDRESS% TYPE NUL >script.ftp DEL script.ftp FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server osql -E -d master -Q "BACKUP DATABASE [%DATABASENAME%] TO DISK = N'D:\DataBase\Backups\%DATABASENAME IF EXIST %SystemRoot%\$NtUninstallKB915865$\ GOTO KB_INSTALLED ECHO Installing Hotfix (KB915865) to allow tab support START /D "%~dp0/Installation/Update/" xmllitesetup.exe ECHO Waiting 15 seconds PING 1.1.1.1 -n 1 -w 15000 > NUL IF dummy==dummy%3 ( SET APPLICATIONPATH="C:\Program Files\MyApp\" ) ELSE ( SET APPLICATIONPATH = %3 ) Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 2 de 23 05/08/2014 10:12 a.m. PUSHD %BACKUPDIRECTORY% FOR %%A in (*.bak) do CALL :Subroutine %%A POPD GOTO:EOF :Subroutine set DBNAME=%~n1 ::RUN SOME OSQL COMMANDS TO RESTORE THE BACKUP GOTO:EOF @echo off echo %%~1 = %~1 echo %%~f1 = %~f1 echo %%~d1 = %~d1 echo %%~p1 = %~p1 echo %%~n1 = %~n1 echo %%~x1 = %~x1 echo %%~s1 = %~s1 echo %%~a1 = %~a1 echo %%~t1 = %~t1 echo %%~z1 = %~z1 echo %%~$PATHATH:1 = %~$PATHATH:1 echo %%~dp1 = %~dp1 echo %%~nx1 = %~nx1 echo %%~dp$PATH:1 = %~dp$PATH:1 echo %%~ftza1 = %~ftza1 C:\Temp>batchparams.bat c:\windows\notepad.exe %~1 = c:\windows\notepad.exe %~f1 = c:\WINDOWS\NOTEPAD.EXE %~d1 = c: %~p1 = \WINDOWS\ %~n1 = NOTEPAD %~x1 = .EXE %~s1 = c:\WINDOWS\NOTEPAD.EXE %~a1 = --a------ %~t1 = 08/25/2005 01:50 AM %~z1 = 17920 %~$PATHATH:1 = %~dp1 = c:\WINDOWS\ %~nx1 = NOTEPAD.EXE %~dp$PATH:1 = c:\WINDOWS\ %~ftza1 = --a------ 08/25/2005 01:50 AM 17920 c:\WINDOWS\NOTEPAD.EXE Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 3 de 23 05/08/2014 10:12 a.m. %~1 - expands %1 removing any surrounding quotes (") %~f1 - expands %1 to a fully qualified path name %~d1 - expands %1 to a drive letter only %~p1 - expands %1 to a path only %~n1 - expands %1 to a file name only %~x1 - expands %1 to a file extension only %~s1 - expanded path contains short names only %~a1 - expands %1 to file attributes %~t1 - expands %1 to date/time of file %~z1 - expands %1 to size of file %~$PATH:1 - searches the directories listed in the PATH environment variable and expands %1 to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found by the search, then this modifier expands to the empty string The modifiers can be combined to get compound results: %~dp1 - expands %1 to a drive letter and path only %~nx1 - expands %1 to a file name and extension only %~dp$PATH:1 - searches the directories listed in the PATH environment variable for %1 and expands to the drive letter and path of the first one found. %~ftza1 - expands %1 to a DIR like output line In the above examples %1 and PATH can be replaced by other valid values. The %~ syntax is terminated by a valid argument number. The %~ modifiers may not be used with %* Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 4 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 5 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 6 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 7 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 8 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 9 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 10 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 11 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 12 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 13 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 14 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 15 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 16 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 17 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 18 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 19 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 20 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 21 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 22 de 23 05/08/2014 10:12 a.m. Jon Galloway - Top 10 DOS Batch tips (Yes, DOS Batch...) http://weblogs.asp.net/jongalloway/top-10-dos-batch-tips-yes-dos-batch 23 de 23 05/08/2014 10:12 a.m.