how to make batch file for simple msbuild commands - msbuild

I have below a ms build command which want to execute as a batch file so that i can automate it further.
So can any one tell me how to make a batch file (*.bat) which will execute the command bellow with one click of a button ?
Commands:
set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319
call %msBuildDir%\msbuild.exe "D:\tmc600\WIX_Related_files\RIO600_ConnPack_Ver.1.5_WIX\tmc_SetupProject.wixproj" /p:Platform="x86" /p:configuration="Release"

Try running your set command as written and replace "call" with "start" in the call command.
#echo off
Your set command
start "" "%msBuildDir%\msbuild.exe" "D:\tmc600\WIX_Related_files\RIO600_ConnPack_Ver.1.5_WIX\tmc_SetupProject.wixproj" /p:Platform="x86" /p:configuration="Release"
pause
Save as name.bat. You may need to work on the parameters in the Start. There's a good explanation here: http://ss64.com/nt/start.html

Related

Copy a file using .mshs script

I am trying to copy a file, export.txt from one directory to another within a .mshs script. I currently have:
shell copy 'E:\RPTG\Export.txt' 'E:\FCST\';
I'm getting an error that says "end of file breaks the statement."
Is there a command to copy a file with .mshs?
Thanks!
Typically you would perform the copy from a batch file itself. For example, your batch file would do the copy, run a MaxL script, and then do other things. That said, you can run shell commands from within MaxL if you need to (I don't usually recommend it though). In this case, you need to pass the whole statement to the shell command. Your statement should work if you write it like this instead:
shell "copy 'E:\RPTG\Export.txt' 'E:\FCST\'";
Note that I have enclosed your command in double quotes. There are some nuances to using double quotes and single quotes at the same time, but in this case you should be okay.

want to run multiple SQL script file in one go with in SQLPLUS

I have to run multiple SQL script file in one go.
Like every time i have to write command in SQLPLUS
SQL>#d:\a.txt
SQL>#d:\a2.txt
SQL>#d:\a3.txt
SQL>#d:\a4.txt
is there any way put all file in one folder & run all script file in one go without missing any single file like #d:\final.txt or #d\final.bat
There is no single SQL*Plus command to do that, but you can create a single script that calls all the others:
Put the following into a batch file
#echo off
echo.>"%~dp0all.sql"
for %%i in ("%~dp0"*.sql) do echo #"%%~fi" >> "%~dp0all.sql"
When you run that batch file it will create a new script named all.sql in the same directory where the batch file is located. It will look for all files with the extension .sql in the same directory where the batch file is located.
You can then run all scripts by using sqlplus user/pwd #all.sql (or extend the batch file to call sqlplus after creating the all.sql script)
If you're using gnu linux, you could use process substitution:
sqlplus USERNAME/PASSWORD#DOMAIN < <(cat a.txt a2.txt a3.txt a4.txt)
# ... or a for loop on input files, inside the process substitution
Alternatively, you can create a .pdc file and list your sql scripts:
-- pdc file
#a.txt;
#a2.txt;
#a3.txt;
#a4.txt;
and call sql plus:
sqlplus USERNAME/PASSWORD#DOMAIN < my_scripts.pdc
Some tricks and command can help you to generate master.sql file and you can run from that location.
c:\direcotory_location\dir *.sql /-t /b >master.sql
Go to the parent directory open master.sql open using notepad++
remove master.sql line and use regular expression to replace
\n with \n #
go to cmd
From cmd
C:\root_directory\sqlplus user/password #master.sql
I find this process very convenient if i have 30 to 40 scripts placed in a single directory.
Use *.PDC extension file like this
install.pdc file content
whenever sqlerror exit sql.sqlcode
prompt started!
prompt 1.executing script 1
##install/01.script_1.sql
prompt 2.executing script 2
##install/02.script_2.sql
prompt 3.executing script 3
##install/03.script_3.sql
prompt finished!
where ##install/ points in which directory is the SQL script located
It might be worth the time to write a shell script that runs multiple files.
#!/bin/ksh
sqlplus user/password#instance <<EOF
#a.txt
#a1.txt
exit
EOF
For more on the syntax, look into Here Document
here is similar solution but you do not have to iterate and to have special formated an sql file names. You compose an one sql file and run it once.
cat table_animal.sql > /tmp/temp.sql
cat table_horse.sql >> /tmp/temp.sql
cat table_fish.sql >> /tmp/temp.sql
sqlplus USERNAME/PASSWORD#DOMAIN #/tmp/temp.sql
For Windows try
copy /b *.sql +x final.sql
sqlplus user/password #final.sql
Special Thanks to Joseph Torre
sqlplus login/password#server #filename
reference link

ActiveTCL - Unable to run a batch file from an Expect Script

I was originally trying to run an executable (tftpd32.exe) from Expect with the following command, but for some unknown reason it would hanged the entire script:
exec c:/tftpd32.351/tftpd32.exe
So, decided to call a batch file that will start the executable.
I tried to call the batch file with the following command, but get an error message stating windows cannot find the file.
exec c:/tftpd32.351/start_tftp.bat
I also tried the following, but it does not start the executable:
spwan cmd.exe /c c:/tftpd32.351/start_tftp.bat
The batch file contains this and it run ok when I double click on it:
start tftpd32.exe
Any help would be very much appreciated.
Thanks
The right way to run that program from Tcl is to do:
set tftpd "c:/tftpd32.351/tftpd32.exe"
exec {*}[auto_execok start] "" [file nativename $tftpd]
Note that you should always have that extra empty argument when using start (due to the weird way that start works; it has an optional string in quotes that specifies the window title to create, but it tends to misinterpret the first quoted string as that even if that leaves it with no mandatory arguments) and you need to use the native system name of the executable to run, hence the file nativename.
If you've got an older version of Tcl inside your expect program (8.4 or before) you'd do this instead:
set tftpd "c:/tftpd32.351/tftpd32.exe"
eval exec [auto_execok start] [list "" [file nativename $tftpd]]
The list command in that weird eval exec construction adds some necessary quoting that you'd have trouble generating otherwise. Use it exactly as above or you'll get very strange errors. (Or upgrade to something where you don't need nearly as much code gymnastics; the {*} syntax was added for a good reason!)

Start /WAIT Program.bat

I am trying to write a batch file that starts another batch file, waits for that batch file to complete its job, and then continue once that other batch file has exited. However, when I manually close the batch file launched by the first batch file, it comes up with a prompt saying:
^CTerminate batch job (Y/N)?
Is there a way to automatically select 'N', because it needs to delete some temporary files on exit.
Purpose/Premise of Script: To be able to remove a flash drive and lock the station (hence copying files to external source).
Summary of Script:
Program Copies files to %homedrive%
Program launches another script (one of the files copied to homedrive)
After that program quits, it deletes the copied files
Solutions Tried:
Different command switches inside of START /WAIT +/I +/B (Adding /I
or /B did not produce anything useful)
Using /C and /K switches after the START /WAIT program.bat +/C +/K
(had no affect)
Well, you could use echo n | program.bat to automatically respond n to ^CTerminate batch job (Y/N)?, but an easy way to fool this method is to hit and keep pressed [Ctrl]-C.
There simply is no reliable way to disable the interruption of any program (much less a batch file). What stops the user from just closing the window?
You would want a command like this:
start /wait program.bat|echo n>nul
">nul" will hide the "n" that shows up afterwards. But there doesn't seem to be a way to stop "^C" from showing up.

How to call MSBuild tasks from FinalBuilder?

The only way I see now is to create xml file for MSBuild containing needed tasks invocations and then run MSBuild directly by calling "Execute Program" action. Is there any standard way of doing this using FinalBuilder?
In FinalBuilder 6 you can use a MSBuild Task. However to be honest in our build script I found that using a batch file and the 'Execute Program' to be a better solution.
Edit: Quickly doing some reading on this topic I now remember why I used a batch file. The FB6 MSBuild action is a little counterintuitive as not all the properties are accessible from the 'default view' and you need to change to the 'property grid'.
Update: From your comment; if you want to run an individual MSBuild task and not use the 'Execute Program' action then you will need to create your own FB action. I have never created an custom action myself but apparently they are really simple.
This is the batch file that I used:
#ECHO off
SET Action=%1
SET Configuration=%2
SET Platform=x86
SET CommonTools=%VS90COMNTOOLS%
SET SourceDir=%CD%\..\..
SET SolutionFilename=Solution.sln
SET MSBuild=C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe
IF "%Action%" == "" SET Action=Rebuild
IF "%Configuration%" == "" SET Configuration=Release
:BUILD
%MSBuild% "%SourceDir%\%SolutionFilename%" /v:m /t:%Action% /p:Configuration=%Configuration% /p:DenEnvDir="%CommonTools%..\IDE\" /p:SolutionDir="%SourceDir%" /p:Platform=%Platform%
:END
ECHO.
ECHO ErrorLevel: %ERRORLEVEL%
EXIT /B %ERRORLEVEL%
You cannot just run an msbuild task from within another application without instantiating the msbuild environment on which it depends. You will need an msbuild project file at the very least.