Invoke batch file in .msi or .exe - visual-studio-2010

I have a requirement which needs a batch script to be invoked before the .msi or .exe package can deploy files to the desired location. I created a setup project and I am ablr to get a .msi and .exe when I build it. My main concern here is that, when I run the exe or msi, the installer deploys the code to the desired location but I have to stop the service brfore copying and start it back after the files are copied. Is there anyway that I can invoke a batch scrip to stop the service before the files are deployed and then invoke another batch script after the files are deployed. I tried using custom action but didnt work, any suggestions are highly appreciated. Thank you.

#ECHO OFF & ECHO This is an Install.bat
NET STOP "the service"
START /WAIT "Installation in progress..." "The installer.msi"
NET START "the service"

Related

How to run bat file in jenkins

My jenkins is installed in C:\Program Files (x86)\Jenkins
bat file is located in C:\Users\Admin\workspace\demoWork\run.bat
When i run this bat file from cmd everything works fine. But when i try from jenkins executing batch command as mentioned in Image, Jenkins displays error as
Build step 'Execute Windows batch command' marked build as failure
Also inside jenkins folder automatically workspace folder gets created with Job title name. Can you guys please explain me in detail
Tatkal, you can't execute a command like in your image,
why don't you simply try
C:\users\admin\workspace\demowork\run.bat
or
call "C:\users\admin\workspace\demowork\run.bat"
"Also inside jenkins folder automatically workspace folder gets created with Job title name. Can you guys please explain me in detail" -
Jenkins creates folder with job title name automatically, saves jobs data and other build info... this is how it works. By default in jenkins job you can access your workspace using $WORKSPACE variable
You have put very little detail into this so I'm going by pure guess..
The Execute Windows batch command is to literally execute code, not execute a file.. to execute the file you could use this command :
start cmd.exe /c C:\myprj\mybat.bat
or you could take the contents of the .bat file and rewrite in in that command line..
The way Jenkins works is it creates its own workspace for each job, essentially to sandbox the environment, its a testing framework so it should be used to stage changes to code, which will then be pushed to your live(working) environment. People use it to automate some tasks, but this isnt the primary use of Jenkins.. if the above doesn't help you let me know more details of the error and I can try help you with it.
node {
bat 'D:\\gatling-charts-highcharts-bundle-3.0.2\\bin\\gatling.bat'
}

bat file can not be executed in TeamCity

I have a bat file in which I perform the copying folder from my computer to a remote computer in a shared folder. If I run it on your computer from the command line, everything works. If I add this bat file TeamCity it gives an error "error in Access." If I instead of the path to the shared folder write path to a folder on my computer, it is normally all copies TeamCity.
so looks bat file when copying to the local computer
cls
SET ARTPATH="C:\myfolder\"
cd %ARTPATH%
xcopy DatabaseUpgrader /e /Y C:\example\
cd c:\
so looks bat file when copying to a remote computer in a shared folder
cls
SET ARTPATH="C:\myfolder\"
SET DBPATH=\\10.73.0.3\DBUpdater\DatabaseUpgrader\
cd %ARTPATH%
xcopy DatabaseUpgrader /e /Y %DBPATH%
folder DBUpdater now shared all network users. I think that launches White TeamCity file under the user has no rights. how to fix it but do not know
If your build agent is installed as a service, try the following:
Run the service under account that has enough rights for the share, by default it is installed under SYSTEM account that can't go outside of the box.
Change agent installation from service to console app, here's a TeamCity doc saying that you need to do it to access network shares: http://confluence.jetbrains.com/display/TCD8/Known+Issues#KnownIssues-Windowsservicelimitations
My knowledge of Windows is very poor, but try to compare the permissions of these two users (the one that you are logged in as, and the second that TC agent is run by).

Windows Bat file run from Autosys - Failed to load the sqljdbc_auth.dll

I have a question and wondering if you guys could help.. Here are the details -
Program Flow ->
Autosys Job -> Windows .bat job on network path-> Internally calls java program along with few other components
When the .bat runs through Autosys job, it gives below warning and does partial processing and exits out without any failure
(i guess the internal code might not have good error handling..but sadly I do not have access to view/modify the same). However, when I logon to that
windows box and run the .bat file from cmd prompt, it works like a charm and throws no error.
Warning in Logs - "WARNING: Failed to load the sqljdbc_auth.dll"
Things I tried-
I tried creating a wrapper bat file in windows C drive (not the netwrok path where the actual .bat is in) and placed sqljdbc_auth.dll in that custom folder.
Job went to SU , after partial processing.
Appreciate your help.
Many Thanks,
Raj
I'd suspect there is a path error. Try echo %path% just before calling your batch, even simply run
echo %path%>alogfile
call yourbatch
and if the displayed path doesn't include a directory in which your .dll resides, add it into the path before calling yourbatch.
It may very well be that your logon includes the required directory as part of your user-defined path and the username under which the job runs does not include the directory.
Or, you could try moving the dll into somewhere like system32 which should be common to everyone.
(Windows should use the standard path-scanning algorithm to locate any required dll that isn't invoked from a full pathname)

Update blocked binaries after build

I want to copy binaries to stage server as the last step of build. Previously I was doing it for asp.net web sites powered by IIS. There were no problems as IIS doesn't block any boundaries. Now I need to do the same for executable server application (it executes some background tasks) which blocks at least its exe file. So I need somehow to close application, update binaries and then run application again.
What is the best way to achieve it using TeamCity?
I'm seems like your staging server is a windows machine. If that's the case, I'd recommend using two executables from the PsTools Suite (PsKill and PsExec) to kill/start your process. Here's how I would set everything up in TeamCity:
Download the PsTools Suite, and copy the contents of the zip file to a folder on the build server. I'll be using C:\Program Files\PsTools in my example.
Create a batch file that kills the executable server application, copies the appropriate binaries, and starts the application again. The batch file would look something like this:
"C:\Program Files\PsTools\PsKill" -accepteula \computername -u username -p password name_of_process_to_kill.exe
copy files - I'm assuming you copied binaries to your ASP.Net staging site using the command line. If not, I can provide more details later.
"C:\Program Files\PsTools\PsExec" -accepteula \computername -u username -p password -d "path_and_name_of_executable_on_remote_server" optional_commandline_args_here
Add a new command line build step to your TeamCity build configuration that executes the batch file created in step #2.
I hope this helps!
Here is how I solved it. I added Command Line step with following Custom Script:
taskkill /IM MyApplicationProcessName /F
xcopy RelativePathToBuildBinaires PathWhereToDeployBinaries /s /e /y
start PathToMyApplicationExeInDeployFolder
Initially it didn't work as TeamCity build agent worked as service (which do not have UI). Then I disabled service and started build agent as console (by TeamCityFolder/builagent/bin/agent.bat). And it worked.

Visual Studio post-build copy failing (but works on the command line)

In VS 2010, I have a post-build event copying project assemblies into a common .dll folder. The .dll folder is mapped by a virtual drive (R:).
On running, I get the following: The command "copy /y "C:\CommonDLLs\Utilities.dll" "R:\"" exited with code 1.
The thing is, when I run copy /y "C:\CommonDLLs\Utilities.dll" "R:\" at the command prompt, it works correctly. I'm running VS as an admin, so I should have permissions to execute the command. Other people using the same code from source control are having no problems, but I'm stumped as to what to fix to get the copy to work correctly. Anyone have any suggestions?
EDIT: more information
The R drive is mapped/created/populated initially by a .bat script that I run as an admin as well. if I update my scripts to run to the location the R drive points to, everything runs ok, so I think this might be a drive mapping issue. The thing is, I(as a local admin) have full control over both the folder and the drive mapping.
I would guess that the virtual drive does not exist under the Admin account and as such cannot be found.
Either don't run VS as Admin, or set up the virtual drive in an command prompt running as Admin.

Resources