InvokeProcess custom activity does not invoke - custom-activity

I'm doing my first steps on Customizing the TFS builds. I created an InvokeProcess that calls a batch file. I see in the log that the batch file is called, but I do not see that the batch file is executed. In the FileName I put the located and the name of the file (for example "C:\myBatch.bat".
Just to see it working, I called in the file name also "Notepad.exe" and also it did not work.
What can be the problem?
Thanks

Specify the WorkingDirectory property for the Invoke Process Activity, If you have file path as "C:\myBatch.bat" then set WorkingDirectory as "c:\"
Also, you can enable the logging for Invoke Process Activity. Check here:
https://blogs.blackmarble.co.uk/blogs/rfennell/archive/2010/02/23/logging-results-from-invokeprocess-in-a-vs2010-team-build.aspx

Related

Redirect stdout from Executable Custom Action to MSI log

I have a Custom Action that runs an executable within an msi installer package. The exe is compiled as a console application and stdouts necessary info.
I want that output redirected to the MSI log file.
I don't want the console to be shown during the installation.
For number 2 I suppose I can use windows as a subsystem, which will not open a console at all. But no output will be shown even if I run the exe from a terminal (PowerShell/CMD).
For number 1 I thought of running an executable as a subprocess called within a Custom Action DLL, but it is not possible since the exe is stored in a binary table and won't be generated when I need it. Moreover, it will have a random name.
The Custom Action's logic MUST be run as a separate process.
EDIT: Some colleagues wrote a free guide on installation testing. Maybe it will be useful in the future, to avoid such costly mistakes.
I don't think you can do it if you want to run the custom action as a separate process. I might be wrong. But I never tried this and it doesn't seem/sound possible.
Basically, the MSIEXEC process will own the handle of the log file created by the installation and I don't think you can share it with a separate process.
Why do you need to use a separate custom action process?
As a test - you could try to create an additional DLL custom action, that runs asynchronously. The purpose of this custom action is simply to communicate with your EXE process and write inside the log file any information you want to pass from the EXE custom action. I never tried this approach, but if you have time to kill and really need the main logic to remain in the EXE custom action, you could give it a try.

How to run a batch file in siebel escript and execute plsql package through a batch file by passing a variable and to get the output

My requirement is to execute a plsql package through siebel escript. For that, I am planning to write a batch file which can be invoked in the escript.
in the batch file, I want to execute the package. But stuck at passing the input to package and get the output from it. Please help me with the code.
Thanks.
The quickest answer might be using Clib Send Command Method. This can be used to run commands on the siebel server, on any OS. eg:
Clib.system("dir /p C:\Backup");
So you could try invoking your bat file
Clib.system("C:\custom.bat arg1 arg2");
You will have to handle the variables in the bat file (or .sh) file and invoke your PLSQL from there.
The flip side is that there is no way of getting any output from the command line back to Siebel.
https://docs.oracle.com/cd/E14004_01/books/eScript/C_Language_Reference101.html#wp1008859
You can get the output back into Siebel indirectly by having the command pipe it to a text file and having Siebel process that file.
The only way to do this is to call the batch with Clib.system and have it save the output into a file. You then need to have some BS/Workflow to read the file and delete it.
It will work reliably if you are careful with the file naming to avoid concurrency issues.

log4cplus - flush file before writing in it

My need is quite simple:
with log4cplus, I'd like to be able to write a log in a log file and to flush the log file everytime before I write in it. This way, while I run my application, I will only have one single line in my log file.
I've tryed the append=False property, but it only flush the log file at startup.
I could do it by hand in C++ but I don't want to write C++ code as the product is already in prod.
Any idea ?
Thanks,
Use the ImmediateFlush property to force the file appender to flush after each event.

Create a file which can be renamed while in use

I have a application which has two sub modules. Also their is custom Log class written to log module activities.Requirement I am working on is each module should create log file with same name and write log into that. To explain it better consider initial run in which module1 is wrting logs in app.log now when another session of application starts with module2 it should also create app.log and start writing. but before that old app.log should get rename to something app.log.1.
Issue I am facing when log file is open with one module function fails to rename. I am working in C++ on window 7. To create a file I am using -
std::ofstream s_ofs.open("app.log", std::ios::out | std::ios::app);
Windows does not allow this. When you open a file, for writing or for reading, it's locked and you can't do operations such as rename or delete while the file is open.
You might want to reconsider your design. Either so that each submodule have its own uniquely named log file. Or use a logging module that can receive logging input from multiple sources and multiplex those into a single file.
You can achieve this by synchronizing access to the Log class object. An approach could be as follows:
Application creates the Log class object on startup Create a
Synchronization object (say Mutex) which protects access to the
Logging
Have the Log method accept a flag which will differentiate
between accesses from two different modules
Module1 gains access and starts logging
When module2 wants to write, the Logger will detect that it has a Log request from another module, and will close the file and then rename it and create another log file with the same name

GetFileAttributes treat normal file as hidden file during frequent rename action

I am facing some issues with this function GetFileAttributes().
I am using C++ to get windows OS notifications and process them. For a particular case of frequent rename action on a single file, some times we are getting FILE_ATTRIBUTE_HIDDEN for those file. I am using Windows 7 Profession Service Pack 1.
Assume I have a pdf file say test.pdf. We are monitoring a directory say (D:\Test) using automatic directory monitoring in windows os. I am renaming the file (D:\Test\test.pdf) frequently as test1.pdf, test12.pdf, test123.pdf and so on.
I got rename notifications for each of the above actions. We used to check the file attributes for each notifications and if it is hidden file, we won't process further. While checking the file attributes, some times it shows as FILE_ATTRIBUTE_HIDDEN for the file. Is there any known issue with GetFileAttributes() ?
Is there any other thing I could try instead of GetFileAttributes ?