Sometimes I run into strange (to me) problems and sometimes I can resolve them.
But this one seems to be beyond my 72 year old brain. Can anyone tell me what I am not doing correctly?
I want to run an external program VNC from within a PureBasic program. I have some examples working but when I use a string variable for the program path it no longer seems to work. I have a file list of computers with their IP addresses and the first line of the file is a path to VNCviewer.exe. If I read the first line of the file and get the VNC path into a variable and confirm it is correct, the test program does not seem to launch VNC and attempt to connect to the test IP address. When I put the actual path in the command line as shown in my examples it works fine. Why can I not use variables read from a file?
For something so trivial I have spent hours trying different things to make it work with no success. I appreciate any help on this one.
Thank you
Stephen
I am going to post some examples of my dilemma. lines commented out allowed me run the tests. I just comment/uncomment where needed.
Code: Select all
;=== This Works to launch VNC and pass on the IP address to connect to ===
IPaddr$ = "192.168.23.15" ;any address will do
VNC$ = "C:\Program Files (x86)\RealVNC\VNCviewer.exe"
RunProgram(VNC$, IPaddr$, "")
End
;=== This does not work === WHY ?
; vnc-list.txt first line contains: C:\Program Files (x86)\RealVNC\VNCviewer.exe
;IPaddr$ = "192.168.23.15" ;any address will do
;ReadFile(0, "vnc-list.txt")
;VNC$ = ReadString(0) ;gets the correct vnc path to VNC$
;CloseFile(0)
;RunProgram(VNC$, IPaddr$, "") ;does not appear to work ???
;End
;=== And This works ===
;IPaddr$ = "192.160.23.15"
;ShellExecute_(0, "open", "C:\Program Files (x86)\RealVNC\VNCviewer.exe", IPaddr$, "", #SW_NORMAL)
;=== And this works ===
;IPaddr$ = "192.160.23.15"
;VNC$ = "C:\Program Files (x86)\RealVNC\VNCviewer.exe"
;ShellExecute_(0, "open", VNC$, IPaddr$, "", #SW_NORMAL)
;=== This does not work === WHY ?
; vnc-list.txt first line contains: C:\Program Files (x86)\RealVNC\VNCviewer.exe
IPaddr$ = "192.168.23.15" ;any address will do
ReadFile(0, "vnc-list.txt")
VNC$ = ReadString(0) ;gets the correct vnc path to VNC$
CloseFile(0)
ShellExecute_(0, "open", VNC$, IPaddr$, "", #SW_NORMAL)
End