Hi,
Can we start the service (PiServiceLauncher) and stop it (and Pimax related tasks) with a single .bat file?
I mean start with a .bat, use the headset and stop with that same .bat (like we can do with Oculus services).
Checkout this thread
You can start TaskManager from a batch file, but that just starts the GUI. I did some research and you can stop tasks and exes in a bat file using TaskKill.
Here’s details on TaskKill…
You can start and stop services using the net command. Here’s the details…
sc stop PiServiceLauncher
sc start PiServiceLauncher
call it whatever.bat and run it as admin
Note: the PiServiceLauncher doesn’t show up as running at start up on my machine although PiService, pi_server and pi_overlay do and the sc command definitely starts and stops these processes
Note: PiServiceLauncher starts/stops the PiService, pi_server and pi_overlay processes
Edit: PiServiceLauncher is running after a fresh restart as per default, it wasn’t running when I was checking the commands
That’s awesome!
So just using Sc start/stop PiServiceLauncher stops & starts related tasks?
My hmd definitely shut down and initiated overlay again with start, easy to replicate .
Edit: ignore previous statement below -> checked PiServiceLauncher after startup for science and it was running
Dunno if some more magic is required because the launcher service doesn’t show up as running on start up here and therefore the first stop is ignored.
Technically, you should be able to adjust the startup type to “manual” to avoid having the service started at the boot.
I use this:
sc stop PiServiceLauncher & timeout 1 & sc start PiServiceLauncher
- Save as name.cmd
- Create shortcut to cmd
- Right click, advanced, “Run as administrator”
- Pin to start menu
Would be nice if we could capture logs for Pitool devs to fix issues for good, instead of restarting service
I already tried these solutions yesterday, but they’re made to restart the service and tasks.
The best I could do is making 2 different bat files: 1 to start and 1 to stop.
Thanks anyway for the sc stop command, net stop kills only PiServiceLauncher and not the 2 other tasks (I had to taskkill /f each one lol)
What I’d like to do is like the Oculus bat file :
- click to the shortcut to start the service and tasks
- cmd window closes
- use my headset
- click on the same shortcut to stop the service and tasks (and not reload ^^)
- cmd window closes
Here is the oculus bat:
sc config OVRService start= demand
net start “OVRService”
if %errorlevel% == 2 net stop “OVRService”
It works as describe before but when I adapt it for PiServiceLauncher, it reloads it.
@echo off
set ServiceName=PiServiceLauncher
set ProcessName=PiService.exe
tasklist /fi "imagename eq %ProcessName%" | find /v ":" > nul&&(
sc query "%ServiceName%" | find "STATE" | find /v "RUNNING" > nul&&(
sc start %ServiceName%
timeout 10
)
sc stop %ServiceName%
) || (
sc start %ServiceName%
)
It does the toggle state thing but for restart you need to run it twice now.
I am sure @TheIronWolf could write it more nicely.
Note: why so complicated ? I’ve noticed that PiServiceLauncher times out so I’ve added additional taskkills.
Edit: removed taskkill and instead used service start and then stop as a fallback, the service is robust enough not to launch multiple copies of processes
You’re too humble, this is already a very nice batch
The only better way I can think of is self-elevating PowerShell script.
But really we shouldn’t even be doing any of this. Pitool bugs need to be fixed, and sleeping service should cost us nothing.
It’s been awhile. But couldn’t we have it pipe the Terminal output to a text file? I remember foing something like that in DOS.
Piping is still here today - @mojojojo is using it in his script
Is it possible to tag Pitool developers on this forum? I wonder if we could help them diagnose various bugs that we workaround today by service restarts.
Is there diagnostics, logs, (ETW?) we could collect to help you track down tracking issues? I personally hit 2: once in a while HMD does not see base service until restart. Second, sometimes headset looses tracking, happened only once, and seems to be related to fast shaking.
Added pokes to your post.
That’s exactly what I was looking for, thank you
Powershell is the much better scripting language, batch can get ugly very quickly.
I’d add this to the bugs list resolved by service restart:
https://community.openmr.ai/t/vive-controllers-in-wrong-place-help-please/17098
You were already on the right track
No problem, it was easy and fun enough, stackexchange is your friend, only some basic knowledge required.
Agree on powershell - I prefer it to batch, but I do know very hardcore programmers who hate it it has its share of ugliness
A much easier way to fix this is to set the “Startup Type” option of PiServiceLauncher from “Automatic” to “Automatic (Delay)”. My machine requires 2 to 3 minutes delay for the service to actually start, but if I want to jump right into the action, I can just click the “Diagnostic” in PiTool and let it start the service right away.