Hi,
I am new to VB and have run into an error message and I am not sure what the problem is ... I am trying to use VB to open up an SSH tunnel ...
the error message is : "Expected Line number, label statement or end of statement
Here is the code ... any help would be appreciated .. cheers, Natasha
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ()
ByVal hwnd As Long, _
ByVal lpszOp As String, _
ByVal lpszFile As String, _
ByVal lpszParams As String, _
ByVal lpszdir As String, _
ByVal FsShowCmd As Long)
As Long
Private Sub Form_Load()
ShellExecute Me.hWnd, "Open", "C:/plink.exe", "-ssh"
-l tunnel -pw Cyber4me -L -batch 192.168.10.25", "c:\",
0
MsgBox "Tunnel Open!"
End Sub
12 3939
Try this: - Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
-
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
-
-
-
-
-
Private Sub Form_Load()
-
ShellExecute Me.hwnd, "Open", "C:/plink.exe", "-ssh -l tunnel -pw Cyber4me -L -batch 192.168.10.25", "c:\", 0
-
MsgBox "Tunnel Open!"
-
-
End Sub
Good Luck.
Hi Thanks for the response .. I can get the code to compile now without any errors. When I run the script, I see the "tunnel open" message box ... I click okay and then see a blank forms page ?? IS there something that I am missing, as to why the tunnel would not be opening ?
I replaced the plink.exe with putty.exe just to see if putty would lanuch and it does ... so I am not sure why plink would not be opening the tunnel ... thanks again ..
Natasha
Try this: - Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
-
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
-
-
-
-
-
Private Sub Form_Load()
-
ShellExecute Me.hwnd, "Open", "C:/plink.exe", "-ssh -l tunnel -pw Cyber4me -L -batch 192.168.10.25", "c:\", 0
-
MsgBox "Tunnel Open!"
-
-
End Sub
Good Luck.
Unfortunately I don't know those EXEs you have to try execute the same statement with all parameters from DOS prompt and see if any errors will show up.
Sorry, not sure how to help you here..... :)
Don't you think you should change a backslash here?
From C:/plink.exe
to C:\plink.exe
Hi ... I already changed the backslash ... I alredy went into DOS and ran the plink command .. this is just a command line version of putty .... it works from DOS ..
I think the error is something I am not doing in VB. I just started using VB, so that is probably the issue .. I simply went into VB and started writing the code ..
When I run the script I am just getting a blank form1 page ... Is there something that I need to create to get my output to show-up in VB ? thanks for your advise ... cheers,
N
Don't you think you should change a backslash here?
From C:/plink.exe
to C:\plink.exe
In this line: - ShellExecute Me.hwnd, "Open", "C:\plink.exe", "-ssh -l tunnel -pw Cyber4me -L -batch 192.168.10.25", "c:\", 0
change 0 to 1 - ShellExecute Me.hwnd, "Open", "C:\plink.exe", "-ssh -l tunnel -pw Cyber4me -L -batch 192.168.10.25", "c:\", 1
Try to execute this way.
It worked ... thanks so much ....
Natasha
In this line: - ShellExecute Me.hwnd, "Open", "C:\plink.exe", "-ssh -l tunnel -pw Cyber4me -L -batch 192.168.10.25", "c:\", 0
change 0 to 1 - ShellExecute Me.hwnd, "Open", "C:\plink.exe", "-ssh -l tunnel -pw Cyber4me -L -batch 192.168.10.25", "c:\", 1
Try to execute this way.
I think it worked before too. You just didn't see it.
Now by changing parameter 0 to 1 you were able to see that it does work.
0 - makes application run on a background.
I am glad it is working now.
Good Luck.
Irina.
Hi Irina,
Thanks again for your help yesteray. I am now trying to include the option to close the SSH tunnel. I can get the following code to compile with no errors, but I get no output .... Could you have a look at this to see if I am missing something .. maybe an API declaration or something ... Yesterday I was at least getting the "open tunnel" box to display before I made the changes you suggested ... but now ... I can complile the code and then nothing ...
thanks,
Natasha - Option Explicit
-
-
Dim si As SHELLEXECUTEINFO
-
-
Private Declare Function ShellExecuteEx Lib "shell32.dll" Alias "ShellExecuteExA" _
-
(si As SHELLEXECUTEINFO) As Long
-
-
-
Private Declare Function TerminateProcess Lib "kernel32" (ByVal _
-
hProcess As Long, ByVal uExitCode As Long) As Long
-
-
-
Private Type SHELLEXECUTEINFO
-
cbSize As Long
-
fMask As Long
-
hwnd As Long
-
lpVerb As String
-
lpFile As String
-
lpParameters As String
-
lpDirectory As String
-
nShow As Long
-
hInstApp As Long
-
lpIDList As Long
-
lpClass As String
-
hkeyClass As Long
-
dwHotKey As Long
-
hIcon As Long
-
hProcess As Long
-
End Type
-
-
-
-
-
-
Private Sub cmdClose_Click()
-
Dim exitCode As Long
-
If TerminateProcess(si.hProcess, exitCode) <> 0 Then
-
CloseHandle (si.hProcess)
-
MsgBox "Tunnel Closed!"
-
End If
-
End Sub
-
-
Private Sub cmdOpen_Click()
-
si.cbSize = Len(si)
-
si.fMask = SEE_MASK_NOCLOSEPROCESS
-
si.hwnd = frmMain.hwnd
-
si.lpVerb = "open"
-
si.lpFile = "c:\plink.exe"
-
si.lpParameters = "-ssh -l tunnel -pw Cyber4me 192.168.10.25", "c:\", 1
-
si.lpDirectory = "c:\"
-
si.nShow = SW_HIDE
-
-
-
-
If ShellExecuteEx(si) Then
-
MsgBox "Tunnel Open!"
-
Else
-
MsgBox "Opening Failed!"
-
End If
-
End Sub
Look at this line:
si.lpParameters = "-ssh -l tunnel -pw Cyber4me 192.168.10.25", "c:\", 1 , 1 - is not a part of parameters passed to exe.
It is the last parameter in ShellExecute Function which is nShowCmd = 1 the same as SW_SHOWNORMAL
See
http://msdn2.microsoft.com/en-us/library/ms647732.aspx
Good Luck.
si.lpParameters = "-ssh -l tunnel -pw Cyber4me 192.168.10.25", "c:\", 1
That raises an interesting question. What do you get when you assign two or three values like this, separated by commas, to a string? I would have expected a compile error.
I'll have to try it sometime.
That raises an interesting question. What do you get when you assign two or three values like this, separated by commas, to a string? I would have expected a compile error.
I'll have to try it sometime.
I have to stop putting my 5 cents everywhere...
It gets people confused... :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ange T |
last post by:
Hi there,
I'm having pain with the VB behind an Access form. The form is used to
create reports in Excel based on the details entered in the form. This
has always worked without error on my...
|
by: Steve |
last post by:
I have several pairs of synchronized subforms in an application. I have a Delete
button for each pair that uses the following code or similar to delete a record
in the second subform:
...
|
by: Carlos Kim via DotNetMonster.com |
last post by:
Compiler Error Message: CS1026: ) expected
Source Error:
Line 12: <body MS_POSITIONING="GridLayout">
Line 13: <form id="Form1" method="post" runat="server">
Line 14:...
|
by: Tony Tone |
last post by:
I am having trouble resolving this issue:
Server Error in '/test' Application.
--------------------------------------------------------------------------------
Compilation Error
Description:...
|
by: pericpero |
last post by:
Hi
There seem to be a number of posts already with this error message but none of them have helped me ...
I am trying to execute some dynamic SQL from an ASP form to update or delete from a...
|
by: Buddy Home |
last post by:
Hello,
I'm trying to upload a file programatically and occasionally I get the
following error message.
Unable to write data to the transport connection: An established connection
was aborted...
|
by: David Mathog |
last post by:
Do any of you happen to have links to compendiums (or heaven forbid, an
actual manual) which maps compiler warnings and errors to examples of
actual code problems? In this case I'm specifically...
|
by: kya2 |
last post by:
I am not able to create following store procedure.
CREATE PROCEDURE DBSAMBA.InsertDeleteBatch(OUT norows INT )
RESULT SETS 1
LANGUAGE SQL
BEGIN part1
DECLARE TOTAL_LEFT INT DEFAULT 0;
...
|
by: vijayrvs |
last post by:
SearchCrawler.java
The program search crawler used to search the files from the website.
From the following program i got 7 compiler error. can any body clarify it and provide me solution.
...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |