Results 1 to 14 of 14

Thread: Automation Help

  1. #1
    Triple Platinum Member
    Join Date
    Aug 2004
    Posts
    805

    Automation Help

    I want to do the following everyday:
    1. Establish a dial-up connection at 2am.
    2. Start a P2P program at 2am.
    3. Close the P2P program 8am.
    4. Terminate the dial-up connection at 8am.
    Is there a way to do this using Window's Task Scheduler? Alternatively, is there a freeware application that'll let me do this easily? I've found Advanced Task Scheduler but it's not free.

    Any help is appreciated. Thanks

  2. #2
    Platinum+ Member
    Join Date
    Nov 2004
    Location
    India
    Posts
    629
    The Windows Task Scheduler can do this.

    It can start, stop and restart the program at specified time (intervals).

    http://img429.imageshack.us/img429/5968/untitledjo6.jpg

    It gave me a permissions error, but I think it will work for you.

  3. #3
    Triple Platinum Member
    Join Date
    Aug 2004
    Posts
    805
    I don't think it schedules dial-up connections.

  4. #4
    Junior Member
    Join Date
    Feb 2005
    Location
    Greenock, Scotland
    Posts
    38
    Set The Windows Task Scheduler to start up Internet Explorer , then set IE to always dial a connection. Then set up another task to run 5 min later starting the P2P software

  5. #5
    Security Intelligence TZ Veteran cash_site's Avatar
    Join Date
    Jul 2002
    Location
    Software Paradise
    Posts
    3,385
    Yep rmm59 has a great idea! Another way is to use window cmd (or scripts) and use the commandline functions to dialup, start P2P etc... then just schedule that filename.cmd file to run at 2am with TaskScheduler

    --- 0wN3D by 3gG ---

  6. #6
    Triple Platinum Member
    Join Date
    Aug 2004
    Posts
    805
    Genius!

  7. #7
    Precision Processor Super Moderator egghead's Avatar
    Join Date
    May 2002
    Location
    In Your Monitor
    Posts
    3,212
    Quote Originally Posted by rohitk89 View Post
    Genius!

    nod

    :thumbs up:
    ------------------------------------------------------------



  8. #8
    Junior Member Rangerdawg75's Avatar
    Join Date
    Jul 2006
    Location
    SouthEast
    Posts
    6

    Very ingenious!

    I bet the guys, if they read the thread here, at SoutSoftware; they coded Advanced Task Scheduler, would pay you two guys RMM59 and Tarun not to post your advice help...ha ha ha...that might cut into their profits then again they might offer you a job because it is a very ingenious answer to a question. I know, as a programmer, I tend to make things more complicated that they need to bes sometimes and come up with something like SouthSoft's answer like ATS, when there is a much simpler and BETTER way to do it.

    I am new to the techzone's community here but since my registraton the other day I have spent hours and hours here already because of the people in the community and the insight/knowledge of those people!..Thanks guys/gals for this great forum...
    God Bless,

    Ranger!
    "Sua Sponte, Rangers Lead the Way!"

  9. #9
    Senior Member blackhat's Avatar
    Join Date
    Oct 2005
    Posts
    202
    I have to agree! These guys Rock! If I get the time and the money at the same time to do some of the things I have in mind, I'll be trying to pick some of these brains! DRB

    "Will Golf for Food"

  10. #10
    Old and Cranky Super Moderator rik's Avatar
    Join Date
    Aug 2003
    Location
    Watching Your every move...
    Posts
    4,303
    Glad you like it here and Welcome to Techzonez.

    Hooah!

  11. #11
    Bronze Member
    Join Date
    Dec 2005
    Posts
    175
    Or use Rasdial

    1. Try to establish connection using RasDial
    2 a. if connection successful - write an event log record and start p2p program
    2 b. if connection failed - write an event log record and redial.

    Code:
    ConnectionName = "XYZ"
    strUserName = "username"
    strPassword = "pass"
    nRedial = 10
    progEXEpath = "path of p2p.exe"
    
    sDialUpCmd = "Rasdial " & ConnectionName & " " & chr(34) & strUserName & chr(34)  & " " & chr(34) & strPassword & chr(34) 
    
    Set objShell = Wscript.CreateObject("Wscript.Shell")
    
    Do 
    sResult = CMDResults(sDialUpCmd)
    If InStr(1, sResult, error, vbTextCompare) = 0 Then
       objShell.LogEvent 0, sResult  
       StartPrgm progEXEpath 
       WScript.Quit
    Else
        'Wscript.Echo i
        objShell.LogEvent 0, sResult 
        i = i + 1
    End If
    Wscript.Sleep 5000
    Loop Until i = nRedial
    
    Function CMDResults(cmdline)
      Set oExCmd = objShell.Exec(cmdline)
      Set oExCmdStdOut = oExCmd.StdOut
      Do: WScript.Sleep 10
        Do Until oExCmdStdOut.AtEndOfStream
          CmdResults = CmdResults & oExCmdStdOut.ReadAll
        Loop
      Loop Until oExCmd.Status <> 0 and oExCmdStdOut.AtEndOfStream
    End Function
    
    Sub StartPrgm(strPath)
    Const NORMAL_WINDOW = 5
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    
    Set objStartup = objWMIService.Get("Win32_ProcessStartup")
    Set objConfig = objStartup.SpawnInstance_
    objConfig.ShowWindow = NORMAL_WINDOW
    Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
    errReturn = objProcess.Create _
    (strPath, null, objConfig, intProcessID)
    End Sub
    Copy the code (add connection name (ConnectionName), username (strUserName), password (strPassword), no. of redials (nRedial) and p2p program path (progEXEPath) to notepad save it as dial.vbs file. Double-click dial.vbs to run it.

    http://windowsxp.mvps.org/rasdial.htm

    =======

    Terminate your dial-up connection

    http://windowsxp.mvps.org/closeras.htm

    Or use this script
    Code:
    ConnectionName = "XYZ"
    
    sDialUpCmd = "Rasdial " & ConnectionName & " /DISCONNECT"
    
    Set objShell = Wscript.CreateObject("Wscript.Shell")
    
    sResult = CMDResults(sDialUpCmd)
      objShell.LogEvent 0, sResult  
    
    Function CMDResults(cmdline)
      Set oExCmd = objShell.Exec(cmdline)
      Set oExCmdStdOut = oExCmd.StdOut
      Do: WScript.Sleep 10
        Do Until oExCmdStdOut.AtEndOfStream
          CmdResults = CmdResults & oExCmdStdOut.ReadAll
        Loop
      Loop Until oExCmd.Status <> 0 and oExCmdStdOut.AtEndOfStream
    End Function
    Copy the code (add connection name(ConnectionName)) to notepad and save it as terminate.vbs. Double click terminate.vbs to run it.

    =======

    To shutdown computer automatically

    (a) if connection failed:

    add
    Code:
    WScript.Sleep 5000
    objShell.Run “Shutdown –s –t 60"
    after Loop Until i = nRedial (1st script)

    (b) after terminating connection : add the above code after objShell.LogEvent 0, sResult (2nd Script)

    Or download shutdown.exe and add
    Code:
    WScript.Sleep 5000
    objShell.Run “path of shutdown.exe –u"
    Last edited by Kane; July 23rd, 2006 at 23:05 PM.

  12. #12
    Security Intelligence TZ Veteran cash_site's Avatar
    Join Date
    Jul 2002
    Location
    Software Paradise
    Posts
    3,385
    great scripts Kane, dont forget to clear the objects (nothing)

    --- 0wN3D by 3gG ---

  13. #13
    Senior Member beelzebub's Avatar
    Join Date
    Aug 2004
    Location
    California
    Posts
    223
    man i need to start getting back into programming

  14. #14
    Triple Platinum Member
    Join Date
    Aug 2004
    Posts
    805
    Quote Originally Posted by beelzebub View Post
    man i need to start getting back into programming
    I should start too

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •