Results 1 to 3 of 3

Thread: Exit VB-Scritp after Time X

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2012
    Posts
    1

    Exit VB-Scritp after Time X

    Hi,

    I'm using a very simple script to change the computername in Win7.
    But if the User didn't enter the new Computername, the scipt never stops.
    How can I exit the script after a specific time?? eg. 10 Minutes.
    Thanks for your help.


    Option Explicit

    Set ws = WScript.CreateObject("WScript.Shell")
    Dim ws, t, p2, p3, p4, p5, n, g, j, h, f, k, cn, cg, cj
    Dim itemtype

    p2 = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ComputerName\"
    p3 = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters\"
    p4 = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\"
    p5 = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\"

    j = ws.RegRead(p2 & "ComputerName")
    h = ws.RegRead(p3 & "NV Hostname")
    f = ws.RegRead(p4 & "ComputerName")
    k = ws.RegRead(p5 & "NV Hostname")

    t = "Change Utility"

    cj = InputBox("Type new Computer name and click OK.", t, j)

    If cj <> "" Then
    ws.RegWrite p2 & "ComputerName", cj
    ws.RegWrite p3 & "NV Hostname", cj
    ws.RegWrite p4 & "ComputerName", cj
    ws.RegWrite p5 & "NV Hostname", cj
    End If

  2. #2
    Addicted Member
    Join Date
    Jul 2009
    Posts
    208

    Re: Exit VBScript after Time X

    Try putting:
    Code:
    WScript.Timeout = 60*10
    in the script
    Last edited by His Nibbs; Nov 27th, 2012 at 07:44 PM. Reason: A better solution.

  3. #3
    New Member
    Join Date
    Nov 2012
    Posts
    4

    Re: Exit VB-Scritp after Time X

    Yes, Code: WScript.Timeout = 60*10 may work.

Posting Permissions

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



Click Here to Expand Forum to Full Width