Hi!
I am writing some Java code that needs to be able to write a pidfile on Unix-like as well as windows machines. On the unix machines I write out a bash shell script that contains something like this
command 1>/dev/null 2>&1 &
echo $! > pidfile
It executes a command, redirects all output into nirwana and puts command into the background (detaches it from the shell). The pidfile contains the process id of the command. I can then later go and read the process id out of the file. That all works fine.
Now on Windows I think I should do something like
start command
and then somehow the equivalent for the Unix way. Problem is I have no control where the program will be used in terms of windows version or what is installed on the machine. I also don't have access to a Windows machine to test things out and I could not find anything simple on the web. I know there is the get-process function in powershell but I do not know if powershell will be installed on the machine so I can't rely on that.
Is there some simple DOS batch file command or syntax that does what I need?