Login | |
|
 |
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
|
|
| |
|
|
|
 |
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
|
|
| |
|
|
|
 |
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
|
|
| |
|
|
|
|
|