<div dir="ltr"><br><div class="gmail_extra">Hi Charles, thank you SO MUCH for your answer! <strong>Today I got the system running OK with PC & UPS shutting down normally!! :</strong></div><div class="gmail_extra"><br><div class="gmail_quote"><span><span lang="EN"><br></span></span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div><div><div style="font:14px/normal Helvetica;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;font-size-adjust:none;font-stretch:normal">One caveat with running "<driver> -k" from a SHUTDOWNCMD is that the existing driver will probably still be running. I don't know how the Windows port of NUT handles exclusive access to USB devices, but it is possible that this is causing the failure.</div></div></div></blockquote><div><br></div><div>Nope. I'm pretty sure the UPS gets the shutdown.stop command the driver sends. I know that because I can successfully send a shutdown.stayoff command via UPSCMD, as you said. That would power off the UPS after the delay time, but it will cancel if I make a force shutdown via "upsmon -c fsd", because UPSMON uses the driver's shutdown process and submits the shutdown.stop after setting the shutdown flag file.</div><div><br></div><div>I erased the shutdown flag file config in the upsmon.config file and since then I can force shutdown UPSMON without it setting the shutdown flag file and thus making the driver shutdown that cancels the UPS timer.</div><div><br></div><div>This is what I mean: </div><div><br></div><div>· Submit "upscmd -u <i>user</i> -p <i>pass</i> HAMUPS shutdown.stayoff" > Wait delay time > UPS shuts down immediately and suddenly powers off PC. (For some reason, shutdown.return doesn't work in my UPS)</div><div>· Submit "upscmd -u <i>user</i> -p <i>pass</i> HAMUPS shutdown.stayoff" > "upsmon -c fsd" with shutdown flag setting on > upsmon creates the flag file, shuts services down and then do the driver shutoff sending the "shutdown.stop" three times > UPS cancels shutdown timer > System shuts down via SHUTDOWNCMD > UPS will stay ON until battery dies</div><div>· Submit "upscmd -u <i>user</i> -p <i>pass</i> HAMUPS shutdown.stayoff"  > "upsmon -c fsd" with shutdown flag file setting OFF > upsmon won't plant the flag file and won't make a driver shutdown, but closes services and runs SHUTDOWNCMD > System shuts down > UPS shuts down after delay time.</div><div><br></div><div>I managed to get the third behavior as follows:</div><div><br></div><div>Having POWERDOWNFLAG setting off (no line written in upsmon.conf), NOTIFYMSG ONBATT "battoff", and NOTIFYFLAG ONBATT SYSLOG+EXEC. NOTIFYCMD and SHUTDOWNCMD point to two separate BAT scripts on my drive. Using upscmd, this is my shutdown design (early shutdown following ONBATT event):</div><div><br></div><div>1- Power goes off. Upsmon does a<em> onbatt notify </em>event calling my 1st bat file, with <em>"battoff"</em> as an argument.</div><div>2- 1st bat file contains a DOS script that compares the received argument to "battoff" string. If it's other than "battoff" it ignores it (to avoid notify events other than ONBATT to trigger the shutdown). If the parameter equals to "battoff" it firsts switches to <em>bin</em> directory and sends the "upscmd -u <i>user</i> -p <i>pass</i> HAMUPS shutdown.stayoff" command starting the UPS's timer. Then it switches to <em>sbin</em> directory and submits "upsmon -c fsd".</div><div>3- Upsmon receives the force-shutdown command. Since POWERDOWNFLAG is not specified, it won't set it or do a driver UPS shutdown that cancels the timer (nevermind because the timer is already going thanks to the<em> shutdown.stayoff </em>command submitted by first bat file). Upsmon closes services, and uses SHUTDOWNCMD that calls my 2nd bat script.</div><div>4- 2nd bat script is a simple one; it calls Windows <em>shutdown </em>command with an specified delay time and an user message.</div><div>5- System shuts down, followed by the UPS after the timer ends.</div><div>6- The entire system and UPS remain off until power goes up again. For some reason my UPS will turn on after power restores, thus acting like it has received the "shutdown.return" instead of the "shutdown.stayoff" command. This is the behavior I was looking for anyway!</div><div><br></div><div>So, it has been an adventure searching a workaround for the driver shutdown failure. I hope I was clear enough and that this will help other people with the same problem. Please correct me if i'm wrong at something, as I don't know very well how NUT behaves on all situations.</div><div><br></div><div>Cheers!</div><div><br></div><div>PS: Only one issue is left: If you use NOTIFYCMD to send messageboxes to the user, it won't work, because Windows services don't have an UI layer and wont be visible. This is also a known issue as I read somewhere else.<br></div></div></div></div>