My code is as below which is throwing error.Please help.I am new to batch file scripts.It is showing syntax error and (goto was unexpected this time error. My motive is to create a batch file which will accept a parameter from user.Based on that parameter, it will perform the tasks. Like if input is sql, it will execute an sql script.If input is foldercreation, it will create a new folder.
@echo off
cls
set /p FileType=Type of file :
if "%FileType%==SQL" (goto sql)
if "%FileType%==TXT" (goto text)
if "%FileType%==BAT" (goto bat)
if "%FileType%==FolderCreation" (goto FolderCreation)
if "%FileType%==FTP" (goto ftp)
:sql
set /p SName=Server Name :
set /p DbName=Database Name :
if exist _Deploy.txt del _Deploy.txt
@echo on
sqlcmd -S %SName% -E -d %DbName% -I -i "D:\Script\Execute_Script.sql" >>_Deploy.txt 2>&1
@notepad _Deploy.txt
exit /b
:text
if exist _Deploy.txt
@echo on
move /-y "D:\artifacts\Art1\test1.txt" "D:\artifacts\Art2\">>_Deploy.txt 2>&1
@notepad _Deploy.txt
exit /b
:bat
if exist _Deploy.txt
@echo on
call testbatchcreatefolder.bat>>_Deploy.txt 2>&1
@notepad _Deploy.txt
move /-y "D:\artifacts\Art1\testbatchcreatefolder.bat" "D:\artifacts\Art2\"
exit /b
:FolderCreation
set /p Mypath=Path please :
set /p Myfoldername=folder name :
set folder_path=%Mypath%\%Myfoldername%
md "%folder_path%"
exit /b
:FTP
if exist _Deploy.txt
@echo on
move /-y "D:\artifacts\Art1\test2.txt" "D:\artifacts\Art2\">>_Deploy.txt 2>&1
@notepad _Deploy.txt
exit /b
pause
set /p delExit=Press the ENTER key to exit...:
:end
Aucun commentaire:
Enregistrer un commentaire