Author Topic: anyway to: autopush shutdown  (Read 2746 times)

portems

  • Guest
anyway to: autopush shutdown
« on: June 06, 2008, 10:03:10 pm »
does anyone know if you can autopush shutdown when app starts

I want to be able to turn my machine on, it auto run Altbinz.
grabs NZB's from external drive
auto schedule so it downloads them at the right times
Then once finished shutdown (this is the bit I can't do)

All this without the need of a monitor or keyboard.

Offline Hecks

  • Contributor
  • ***
  • Posts: 2011
  • naughty cop
Re: anyway to: autopush shutdown
« Reply #1 on: June 06, 2008, 10:36:19 pm »
By 'turn machine on' do you mean boot or resume from standby/hibernate?  If the latter, you can just keep Alt.Binz running with your options toggled.

Otherwise, you need to invest a bit of time in writing a batch script to monitor the altbinz_status.xml file.  Here's a snippet of old one that should give you an idea of what's possible (I do it all with PowerShell now ;)):

Code: [Select]
@echo off

rem SNIPPED

:connect_altbinz
find "<connect>true</connect>" "C:\Program files\Altbinz\altbinz_status.xml" >nul
if %ERRORLEVEL%==0 goto scan_RSS
Echo %DATE% %TIME:~0,-3% Connecting Altbinz ................
c:\replace.vbs "C:\Program files\Altbinz\altbinz_status.xml" "<connect>false</connect>" "<connect>true</connect>"

:scan_RSS
echo %DATE% %TIME:~0,-3% Scanning RSS feed .................
set counter=1

:scan_RSS_loop
if %counter%==10 goto disconnect_altbinz
find "<ETA>Unknown</ETA>" "C:\Program files\Altbinz\altbinz_status.xml" >nul
if %ERRORLEVEL%==1 goto check_download_status
set /a counter=%counter% + 1
call c:\wait.bat 60
goto scan_RSS_loop

:check_download_status
Echo %DATE% %TIME:~0,-3% Checking AB download status .......

:check_loop
FOR /f "EOL=- TOKENS=3 DELIMS=<>" %%S IN ('find "<CurrentSpeed>" "C:\Program files\Altbinz\altbinz_status.xml"') DO (echo %date% %TIME:~0,-3% Current Speed: %%S)
find "<ETA>Unknown</ETA>" "C:\Program files\Altbinz\altbinz_status.xml" >nul
if %ERRORLEVEL%==0 goto disconnect_altbinz
call c:\wait.bat 60
goto check_loop

:disconnect_altbinz
Echo %DATE% %TIME:~0,-3% Disconnecting Altbinz .............
c:\replace.vbs "C:\Program files\Altbinz\altbinz_status.xml" "<connect>true</connect>" "<connect>false</connect>"

:hibernate
Echo %DATE% %TIME:~0,-3% Hibernating .......................
%SYSTEMROOT%\System32\rundll32.exe powrprof.dll,SetSuspendState 1,1,0


And in replace.vbs:

Code: [Select]
Const ForReading = 1
Const ForWriting = 2

strFileName = Wscript.Arguments(0)
strOldText = Wscript.Arguments(1)
strNewText = Wscript.Arguments(2)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFileName, ForReading)

strText = objFile.ReadAll
objFile.Close

intLength = Len(strText)
strEnd = Right(strText, 2)
If strEnd = vbCrLf Then
    strText = Left(strText, intLength - 2)
End If

strNewText = Replace(strText, strOldText, strNewText)

Set objFile = objFSO.OpenTextFile(strFileName, ForWriting)
objFile.WriteLine strNewText
objFile.Close

And in wait.bat:

Code: [Select]
@echo off
@ping 127.0.0.1 -n 2 -w 1000 > nul
@ping 127.0.0.1 -n %1% -w 1000> nul

LOL, all that reminds me why I moved over to PowerShell. Maybe an Autopush Shutdown option would be easier :P


portems

  • Guest
Re: anyway to: autopush shutdown
« Reply #2 on: June 06, 2008, 11:37:11 pm »
Many thanks for the help

Alas, I wish to do all this from a powerup.
Not saying I understand anything you wrote but I will have a go.

And your right, an Autopush would be a lot easier!!!