Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Hyperterminal

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,59508
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Hyperterminal
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Hyperterminal - 4/24/2008 11:53:14 PM   
  Dicko1976

 

Posts: 32
Score: 0
Joined: 3/5/2008
Status: offline
Hi

I have been trying to get some simnumber information out of hyperterminal for our laptops that have inbuilt GPRS. I have managed to do it using vbs and sendkeys to mimic what a mouse would do and it works.

I have a couple of things I would like to improve...if possible,

1 - can i run this minimized so that the user cant see what the script is doing in hyperterminal. I have tried minimizing hyperterminal but it needs it showing for the senkkeys ?

2 - is there another way to extract sim details rather than sendkey and hyperterminal ?

Thanks in advance

Martyn
 
 
Post #: 1
 
 RE: Hyperterminal - 4/28/2008 12:06:47 AM   
  ebgreen


Posts: 4595
Score: 29
Joined: 7/12/2005
Status: offline
1) - No
2) - Maybe. There may be some information in WMI.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Dicko1976)
 
 
Post #: 2
 
 RE: Hyperterminal - 4/29/2008 12:54:17 AM   
  Rischip


Posts: 378
Score: 2
Joined: 3/26/2007
Status: offline
Are you using hyperterminal to open a com port to get the simnumber? If so you can do that directly in VBS. Use openfile method and use COM# as the file name.

_____________________________

Rischip
Author of - The Grim Linker

(in reply to Dicko1976)
 
 
Post #: 3
 
 RE: Hyperterminal - 4/29/2008 1:30:13 AM   
  Dicko1976

 

Posts: 32
Score: 0
Joined: 3/5/2008
Status: offline
Hi yes thats what I would like to do. How would that be wrote for Com Port 6
 
The script below is the hyperterminal bit to get the sim number using the command AT^SCID

'#################################
set WshShell = Wscript.CreateObject("Wscript.Shell")
Title1 = "CF18_Sim_Info - Hyperterminal"
'Open Hyperterminal
Sub KeyIt(Keystroke, WinTitle)
WshShell.AppActivate Title1
Wscript.Sleep 500
WshShell.Sendkeys keystroke
End Sub
WshShell.Run"CF18_Sim_Info.ht"
wscript.sleep 500
WshShell.AppActivate Title1
'Minimize Hyperterminal
'WshShell.Sendkeys "(% )N"
Wscript.sleep 500
Call KeyIt ( "%T", Title1)
Wscript.sleep 500
Call KeyIt ( "{DOWN}{DOWN}"+("{Enter}"), Title1)
Wscript.sleep 500
Call KeyIt ( "%B", Title1)
Wscript.sleep 500
Call KeyIt ( "C:\Program Files\Windows NT\SimNumber.txt", Title1)
Wscript.sleep 500
Call KeyIt ( "%S", Title1)
Wscript.sleep 500
Call KeyIt ( "%Y"+("{Enter}"), Title1)
Wscript.sleep 500
Call KeyIt ( "AT{^}SCID"+("{Enter}"), Title1)
Wscript.sleep 500
Call KeyIt ( "%T", Title1)
Wscript.sleep 500
Call KeyIt ( "{DOWN}{DOWN}"+("{Enter}")+("{Enter}"), Title1)
Wscript.sleep 500
Call KeyIt ( "%F", Title1)
Wscript.sleep 500
Call KeyIt ( "x", Title1)
Wscript.sleep 500
Call KeyIt ( "y", Title1)
Wscript.sleep 500

Below is the script the whole script that I put together. Its probably a bit messy as im no expert but I got this script to do exactly what I wanted. A prompt box telling me what the sim number is.
 
dim filesys
Set filesys = createobject("scripting.FileSystemObject")
if filesys.fileexists("C:\Program Files\Windows NT\SimNumber.txt") Then
filesys.deletefile "C:\Program Files\Windows NT\SimNumber.txt"
Else
end if
'#################################
set WshShell = Wscript.CreateObject("Wscript.Shell")
Title1 = "CF18_Sim_Info - Hyperterminal"
'Open Hyperterminal
Sub KeyIt(Keystroke, WinTitle)
WshShell.AppActivate Title1
Wscript.Sleep 500
WshShell.Sendkeys keystroke
End Sub
WshShell.Run"CF18_Sim_Info.ht"
wscript.sleep 500
WshShell.AppActivate Title1
'Minimize Hyperterminal
'WshShell.Sendkeys "(% )N"
Wscript.sleep 500
Call KeyIt ( "%T", Title1)
Wscript.sleep 500
Call KeyIt ( "{DOWN}{DOWN}"+("{Enter}"), Title1)
Wscript.sleep 500
Call KeyIt ( "%B", Title1)
Wscript.sleep 500
Call KeyIt ( "C:\Program Files\Windows NT\SimNumber.txt", Title1)
Wscript.sleep 500
Call KeyIt ( "%S", Title1)
Wscript.sleep 500
Call KeyIt ( "%Y"+("{Enter}"), Title1)
Wscript.sleep 500
Call KeyIt ( "AT{^}SCID"+("{Enter}"), Title1)
Wscript.sleep 500
Call KeyIt ( "%T", Title1)
Wscript.sleep 500
Call KeyIt ( "{DOWN}{DOWN}"+("{Enter}")+("{Enter}"), Title1)
Wscript.sleep 500
Call KeyIt ( "%F", Title1)
Wscript.sleep 500
Call KeyIt ( "x", Title1)
Wscript.sleep 500
Call KeyIt ( "y", Title1)
Wscript.sleep 500
'Delete 1st line within SimNumber.txt
strInputFile = "SimNumber.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForReading = 1
Set objInputFile = objFSO.OpenTextFile(strInputFile, intForReading, False)
If Not objInputFile.AtEndOfStream Then
     objInputFile.SkipLine
Else
     MsgBox "Already at the end of the file."
     WScript.Quit
End If
strContents = ""
While Not objInputFile.AtEndOfStream
     If strContents = "" Then
           strContents = objInputFile.ReadLine
     Else
           strContents = strContents & VbCrLf & objInputFile.ReadLine
     End If
Wend
objInputFile.Close
Set objInputFile = Nothing
Set objOutputFile = objFSO.CreateTextFile(strInputFile, True)
objOutputFile.Write strContents
objOutputFile.Close
Set objOutputFile = Nothing
Set objFSO = Nothing
'Delete last 2 lines within SimNumber.txt
Const ForReading = 1
Const ForWriting = 2
Set objFSo = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("SimNumber.txt", ForReading)
strContents = objFile.ReadAll
objFile.Close
arrLines = Split(strContents, vbCrLf)
Set objFile = objFSO.OpenTextFile("SimNumber.txt", ForWriting)
For i = 0 to UBound(arrLines) - 2
   objFile.WriteLine arrLines(i)
Next
objFile.Close
'Removes the ^SCID : from the SimNumber.txt
'Const ForReading = 1
'Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("SimNumber.txt", ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "^SCID: ", "")
Set objFile = objFSO.OpenTextFile("SimNumber.txt", ForWriting)
objFile.WriteLine strNewText
objFile.Close
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("SimNumber.txt",1)
strComputer = objTextFile.Readline
Wscript.Echo "Sim Number Is : " & strComputer

(in reply to Rischip)
 
 
Post #: 4
 
 RE: Hyperterminal - 4/29/2008 1:46:19 AM   
  Rischip


Posts: 378
Score: 2
Joined: 3/26/2007
Status: offline
Well it would start out like this


      

_____________________________

Rischip
Author of - The Grim Linker

(in reply to Dicko1976)
 
 
Post #: 5
 
 RE: Hyperterminal - 4/29/2008 2:06:55 AM   
  Dicko1976

 

Posts: 32
Score: 0
Joined: 3/5/2008
Status: offline
Thanks for the quick response but it doesnt work.

It took a while to start but then I get Error Permission Denied on Line 13 Char 3 which is the line below

Set objSimCard = objFS.OpenTextFile("COM6", ForReading, True)

Any ideas

All I put for the line below was the hyperterminal code for the simnumber AT^SCID within the quotes

Result = objSimCard.Write("The text you need to write to get the info from the sim card")


Thanks again

Martyn

(in reply to Rischip)
 
 
Post #: 6
 
 RE: Hyperterminal - 4/29/2008 4:29:41 AM   
  Rischip


Posts: 378
Score: 2
Joined: 3/26/2007
Status: offline
Maybe the port was already open? Check other processes.

If I do this
Set objSimCard = objFS.OpenTextFile("COM6", ForWriting, True)
Set objSimCard = objFS.OpenTextFile("COM6", ForWriting, True) ' <-This is line 14

Then I get
comtest.vbs(14, 3) Microsoft VBScript runtime error: Permission denied

_____________________________

Rischip
Author of - The Grim Linker

(in reply to Dicko1976)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Hyperterminal Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts