I am using a shell command to communicate with a device under test and would like to open this shell once, change directory to a specific one and then send different text strings to it at various times during my test program. The code below works perfectly fine but opens and closed the shell each time it is used. I think it woud be quicker if I could reuse it until done and then exit out of it.
Here are 2 examples of a couple different strings I would like to pass into the cmdShell function at various times. I would like to send the first string, perform some measurements and then repeat with the 2nd string.
i.e. shellStr1 = ("cd \.. & cd c:\ezspi & testdm900 --widn 0x1020 --widv 0x1") then once the shell is open and the directory has been set send shellStr = ("testdm900 --widn 0x1020 --widv 0x5")
Is this possible using WShell Script or do I need another method?
Public Sub cmdShell(shellStr As String)
Dim Test As Double
Dim response As VbMsgBoxResult
Dim cmdObject As Object
Dim ReferenceTime As Double, ElapsedTime As Double
Set objShell = CreateObject("WScript.Shell")
Test = Shell("cmd /c " & shellStr, vbHide)
' Test = Shell("cmd /k " & shellStrvbNormalFocus)
End Sub
Here are 2 examples of a couple different strings I would like to pass into the cmdShell function at various times. I would like to send the first string, perform some measurements and then repeat with the 2nd string.
i.e. shellStr1 = ("cd \.. & cd c:\ezspi & testdm900 --widn 0x1020 --widv 0x1") then once the shell is open and the directory has been set send shellStr = ("testdm900 --widn 0x1020 --widv 0x5")
Is this possible using WShell Script or do I need another method?
Public Sub cmdShell(shellStr As String)
Dim Test As Double
Dim response As VbMsgBoxResult
Dim cmdObject As Object
Dim ReferenceTime As Double, ElapsedTime As Double
Set objShell = CreateObject("WScript.Shell")
Test = Shell("cmd /c " & shellStr, vbHide)
' Test = Shell("cmd /k " & shellStrvbNormalFocus)
End Sub