I have a library which runs as a command line program. I'd like to give the user the option of setting up a lock so the command line program can't be run twice - that is - if it starts up, it can't be executed again until it finishes, from any terminal session.
The lock should work for any user logged onto a system - I assume we use some atomic operation on a file, but what kind of operation would that be? It has to be failsafe. The user would be able to override the lock with a --force option, in case of some error.
Any ideas on how to implement this without having to setup any third party software?
Potential implementation: Perhaps the simplest way to do it would be to write a file to the filesystem and delete it on program exit. Any program that comes in second will attempt to write the same file and get an EEXIST error.
Try to create the lock file in some shared area and check if it exit before starting
Also make sure the permission on deleting files in that shared are only for a group of admins
Related
They might be quite obscure: i enjoy RazorSQL for all it can do, and it is the only tool i found that talks properly is Clarions's ODBC driver. It also allows for awesome command line calls to export data.
Trouble is: RazorSQL stores profile connection information based on the user that installed it, and when you set a Windows task to run the batch files of all the groovy export commands, the internal batch file fail without external notification because the user is SYSTEM (as we don't want this tied to any one user)..
I do not recall if there was an option on install allowing profiles to be seen by all, as i normally set this to everyone on my dev box (as it is only me).
So the question: has anyone encountered this obscure scenario, and knows how to have RazorSQL look in a generic location for connection details?
RazorSQL checks for system property named "razorPortable". When defined with a value of "portable" it keeps all its stuff in a RazorSQL folder under its main directory, so shared by all users launching it with said property defined.
So you know the drill: edit some of the bundled bat files and add -DrazorPortable=portable to the command line.
You'll need to re-enter yout registration code, connection profiles, preferences, etc. Or you can manually move them.
How can I sync the command line to the setup project installer that it will not proceed until the task of the command line is done?
The installer needs to run BATCH scripts and it needs to log on to the database credentials. But even before logging on to the database, the installer still proceeds and finish the installation process.
You could give a bit more context, but in general the answer is don't use bat files. You could have a custom action VB script that runs the external executeables (if that's what they are) and waits for them to finish. In general, whenever bat files show up during an install it's a red flag that something isn't right in the design. Usernames can be entered in UI dialogs at the front, for example, and passed to custom action programs; also many clients like silent installs where property values (like a username) can be passed on the msiexec command line and again get passed into a custom action, and it all just works - I suspect your install cannot be run silently because you are collecting a user name at the end of the install in a custom action.
I've made a installer via Inno Setup and now I'm need to restart computer after some files were run.
So, i have code:
....
[Files]
....
[Run]
Filename: firstfile
RESTART
Filename: secondfile
....
Is this possible? I have found one example script github, but i cant understand how to use this DetectAndInstallPrerequisites functions.
If someone can advise or provide some simple example, I would be very gratefull
Have a look at the CodePrepareToInstall.iss example script included with Inno. It shows how to arrange for a reboot and have the installation automatically resume afterwards. (You may need to make further changes or save further values if your installation is more complex or prompts for further user input.)
The missing link in that example is that you need to fill in the DetectAndInstallPrerequisites function by using ExtractTemporaryFile to retrieve the appropriate files (as it runs before the main [Files] section is processed) and Exec(ExpandConstant('{tmp}\yourfile.exe'), ...) to actually run the file. If this is a subinstaller you can then check its exit code to determine if a reboot is actually required or not rather than unconditionally requesting a reboot.
Note that this code will be executed again following the reboot, so you also need some way to detect that the subinstall has succeeded and skip trying to run it again. Typically this is done by trying to detect the version of the installed subcomponent.
I want to run a windows app (the 'target') from another app (the 'runner')
I dont own the target.
Is there any way I can do this without having the params I pass show up in process explorer (I am passing a password)
Unfortunately there is no way. If I understand well you want to pass a password in CLEARTEXT to the target. The only way to not have it show would be for the target program to look for some file where the password is stored, or to look for some key to read the encrypted password.
I assume that by not owning the target you can't ask for that modification to be made. Your best luck would be looking into the manual of the target app
i hope it was useful
Take a look at this blog post and comment thread. Indicates a method under which one process can get at the command line of another. Could the runner launch the process, then go in after some interval (allowing the launched process to first make use of the command line parameters) and change the command line, so that the reported command line is not the original?
I have been using the at command to schedule the task
ex: at 14:45 my.bat
and i am getting the o/p on the command prompt as
"JOB ID is added"
But this command is not getting fired on the time which i have scheduled..
Can anyone please help me.......
I suspect the issue is not that the BAT file is not executing at all, but rather either or both of i) individual commands within the BAT file are failing, or ii) the output isn't getting sent to the place you're looking for it. (Things get even weirder if anything in the batch file requests input, since a) by default batch files may not be able to interact with the "console" at all and b) the system is probably unattended anyway at the time the batch file executes.) If my suspicion is right, there is no one "fix-everything" but rather a whole bunch of small fixes ...and you have to hit every one of them.
Find out the needed password to actually login as 'admin' (rather than your usual user), open a DOS box, and try to run the batch file. There should be some sort of error message that you can see. Fix that problem. Then try again ...and fix the next problem. Keep correcting problems and trying again until finally everything works.