-
Nov 27th, 2012, 10:46 AM
#1
Thread Starter
New Member
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
-
Nov 27th, 2012, 07:35 PM
#2
Addicted Member
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.
-
Nov 28th, 2012, 05:10 AM
#3
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|