Run batch file AFTER all other programs at Windows inicialization - initialization

I have a set of programs running at Windows startup, some called from Registry and others called from Start Menu (Initialization).
I'm trying to have a batch file loaded and showed its screen AFTER all other programs has had loaded.
I tried changing their entries in Registry (Run subkey, also Wow6232Node) and Start Menu without success. That batch file is almost always the first screen I got and it is not desirable as I need. It has to be the last screen showed.
Firefox uses to be the last one.
So, how to load Firefox (and all others) BEFORE that batch file?
How to delay or put a "sleep" command within Windows start up for a given program?
Thx.

For those users with the same question on how to put a delay, after some searching, I found a solution. My script ended being like this:
#echo off
rem PING 111.111.111.111 -n 1 -w 15000 >NUL
timeout /t 15
"C:\Program Files (x86)\PGP Corporation\PGP Desktop\PGPtray.exe" /m "somefile.pgd"
start C:\somefolder\somefile.exe
exit

Related

Blinking cursor forever during tailwind install process

Command Image
I am unable to search on SO hence detailing it here, this can be a duplicate question.Refer the Step 4:'Start the Tailwind CLI build process' TailwindInstallation the question is once I run the MSDOS command for CSS processing: npx tailwindcss -i input.css -o output.css --watch , the rebuilding and done is OK with no errors (refer attached command image) but after that my cursor keeps blinking forever, so I cant issue any more DOS commands so then I need to hit CTRL C (say couple of times) to get a message 'Terminate Batch Job(Y/N)' and I choose Y and then its normal command line prompt.This is an irritant.What am I doing wrong , please advise
That command ends with --watch, so the process will keep running monitoring changes to the files and constantly update the Tailwind css output.
The idea is to leave it running while you are working on the site. If you still need the terminal for something else then open another terminal.

Udev does not have permissions to write to the file system

I have been fighting with udev all afternoon. Basically I have created a rule that detects when a mass storage device is plugged into the system. This rule works and I can get it to execute a script without any issues, here it is for review purposes:
ACTION=="add", KERNEL=="sd?*", SUBSYSTEM=="block", RUN+="/usr/local/bin/udevhelper.sh"
The problem I am running into is that the script is executed as some sort of strange user that has read-only permissions to the entire system. The script I am executing is quite simple:
#!/bin/sh
cd /usr/local/bin
touch .drivedetect
echo "1" > .drivedetect
exit
Basically I would like udev to run this script and simply output a 1 to a file named .drivedetect within the /usr/local/bin folder. But as I mentioned before it sees the rule and executes the rule when I plug in a drive however when it tries to run the script it comes back with file system is read-only script quit with error code 1.
I am currently running this on a raspberry pi zero and the latest Debian image. udev is still being run from init.d from what I can tell because there is no systemd service for it registered. Any help would be great and if you need any more information just ask.
Things I've tried:
MODE="0660"
GROUP="plugdev"
Various combinations of RUN+="/bin/sh -c '/path/to/script'" and /bin/bash
OPTIONS="last_rule"
And last but not least I tried running the script under the main username as well
#!/bin/sh
su pi drivedetect
I had same issue, when I just used
udevadm control --reload-rules
after editing a udev rule. But, if I do:
sudo /etc/init.d/udev restart
The script can edit a file.
It's not enough to reboot. I have to do the restart after booting. It then works as expected until the next reboot.
This is on an rpi with stretch-lite.

udev mounted drive unmounts after script is done

I have a fedora23 live cd spin created in which I created a udev script
the udev rule states:
SUBSYSTEMS=="scsi", KERNEL=="sd[a-z]", GOTO="mount_through_script"
# Else
GOTO="script_end"
LABEL="mount_through_script"
ACTION=="add", RUN+="/usr/bin/mount_usb.sh %N"
ACTION=="remove", RUN="/usr/bin/rmdir %N"
# Exit
LABEL="script_end"
the mount_usb.sh script does multiple things, like doing some work when a specific USB is inserted, but the most important command executed is:
mount -ouser,umask=0000 \${mount_source} "/media/mountpoint";
where mount_source is the path provided by the ADD action.
until the last line of the script the mounted drive seems fine, auto mounted and scripts executed, but when it exits, the freshly mounted drive is unmounted.
When I run the script with the same parameters as root in a console everything works just fine.
Formerly with fedora 19 everything seemed to work, but now we are upgrading to fedora23 and it starts failing.
I can not find any logs stating a reason why it is unmounted and besides the occasional "not correctly unmounted" warning everything looks ok.
Anyone a hint what might be going on

What is the condition for iexpress restart

I use iexpress.exe to quickly create a simple installer based on a batch file. The IExpress Wizards provides the option "Only restart if needed".
But how can I tell from the batch file that a restart is required? I tried using exit code 3016 as in windows updates. But that doesn't work.
BTW: I call the batch file with
cmd.exe /c my.bat
The contents of my.bat:
exit /b 3010
I tried to get IExpress to recognize the return code. I think you want 3010, not 3016, though. Also the command would be:
exit 3010
[No /b – we want to return an exit code from cmd, not set errorlevel].
But it didn’t work, which makes me wonder if IExpress even bothers to check that.
Anyhow, I did a bit of investigation with Process Monitor. Immediately after the install process runs, it seems IExpress checks the PendingFileRenameOperations registry value to see whether files have been marked for rename (or deletion). If there are any, it determines that a reboot is needed, and takes the action you specified in your SED file (eg prompt the user for a reboot; or just reboot; or nothing).
In case you’re not familiar with it, the PendingFileRenameOperations registry value is a list of files to be moved or deleted on the next system boot.
You can use Sysinternals MoveFile to simulate one of these scheduled-at-next-startup renames. Add movefile.exe to your IExpress archive, and add a line like this in your batch file:
movefile.exe -accepteula foo bar
The actual filenames aren’t important – just use a file that you know is certain to not exist. (As long as you didn’t change directory in the batch file, that’ll still be a file in, eg, %temp%\IXP000.TMP.)
Note that you need to be running elevated for that (Run as administrator).
Worked well here. IExpress pops up after each run, prompting the user to reboot.

Running different versions of the same binary, same file

I have a single binary that can run in server or client mode. It can be used like this:
$ ./a.out --server &
$ ./a.out --client &
They talk to each other, and this is working well. My question is what is the expected behavior when I launch the server:
$ ./a.out --server &
But then I forget to kill it, and go about my development work, editing and building, and running the client:
$ edit client.c
$ make
$ ./a.out --client
^C
<repeat>
Now without the sticky bit set, is my OS (Ubuntu) running two different versions of my binary? Or is it taking a shortcut and using the in-memory instance and therefore ignoring my latest build? Are there any other side effects to this mistake?
make replaces the executable by deleting the original file. However, since it is executing in the background, there is a reference to it. The file isn't completely deleted until the reference is cleared (though directory entries are cleared to make way for the new executable file).
So, in your example there are two versions of the program running. One side-effect is if you make changes which cause major incompatibility b/w your server & client code - such as changes in packet structures. You'll probably see weird, unexplainable behavior, crashes, etc. Its always a good idea to kill the background server and re-run your entire test.
If you do not change server code, the just copy your a.out into 'my_server' e.g. Then run it as my_server --server. make will replace a.out, but not my_server.
Another way - tell make to kill all running a.out-s just before recompile: add target 'all' (it must be first in makefile), which depends on a.out and executes 'killall a.out'.

Resources