Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scripting the changing of the time on a cs1000

Status
Not open for further replies.

Adman11

Technical User
Apr 25, 2015
4
CA
Good Morning All,

I have created a vbs script that updates the time on our cs1000. This script works fine when I am logged on and executes it manually, but because of the "sendkeys and " AppActivate" commands I don't believe it can run as a scheduled task. I am required to use ssh here. I see on this forum that people have used the aspect scripting languange to change the dates on the pbx, but this is not a freeware language. Would appreciate if someone can confirm that this type of vbs script can not be scheduled? Also would appreciate some guidance on an alternative approach. Thanks

Here's my Vbs script.

Option Explicit

On Error Resume Next

Dim Wshshell

Dim d,m,y,h,n,s,dateformat

d = DatePart("d",now)

m = DatePart("m",now)

y = DatePart("yyyy",now)

h = DatePart("h",now)

n = DatePart("n",now)

s = DatePart("s",now)

Dim PUTTYPROFILE

PUTTYPROFILE = "Chanpbx"

dateformat = d & " "& m & " " & y & " " & h & " " & n & " " & s

set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run "c:\putty.exe -load " & chr(34) & "Chanpbx" & chr(34)

WScript.Sleep 2000

WshShell.AppActivate "HOSTNAME - PuTTY"

WshShell.SendKeys "username{ENTER}"

WScript.Sleep 2000

WshShell.SendKeys "password{ENTER}"

WScript.Sleep 3000

WshShell.SendKeys "cslogin{ENTER}"

WScript.Sleep 2000

WshShell.SendKeys "{ENTER}"

WshShell.SendKeys "logi{ENTER}"

WScript.Sleep 2000

WshShell.SendKeys "username{ENTER}"
WScript.Sleep 2000
WshShell.SendKeys "password"
WshShell.SendKeys "{ENTER}"

WScript.Sleep 3000

WshShell.SendKeys "ld 2"
WshShell.SendKeys "{ENTER}"

WScript.Sleep 3000

WshShell.SendKeys "ttad"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 2000

WshShell.SendKeys "stad " & dateformat
WshShell.SendKeys "{ENTER}"
WScript.Sleep 2000

WshShell.SendKeys "****{ENTER}"
WScript.Sleep 2000

WshShell.SendKeys "logo{ENTER}"
WScript.Sleep 2000

WshShell.AppActivate "HOSTNAME - PuTTY"

WshShell.SendKeys "%{F4}"

WshShell.SendKeys "{ENTER}"

WScript.Quit

 
There is a limitation to using the sendkeys while logged off or locked. I have been successful using PLink.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top