Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Run .bat commands from shell

Posted on 2003-10-31
6
Medium Priority
?
2,194 Views
Last Modified: 2008-02-01
I have created a button (plinkButton) in a form.
I am using the shell command to call a batch file called plink.bat
Here is the command I am currently using:

 Shell("C:\Program Files\plink.bat", vbNormalFocus)

The batch file consisits of the following commands:

@cls
@echo off
echo Connecting...
@"C:\plink\plink.exe" userid@192.168.1.100

I would like to illiminate the .bat file all together and be able to run the above in my project without calling out to an external batch file.
How do I do that?
0
Comment
Question by:greetrufus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9661940
Private Sub Command1_Click()
Shell Environ("Comspec") & " /c C:\plink\plink.exe userid@192.168.1.100", vbHide
End Sub
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9661942
You could also try shell without calling the command interpretor:

Private Sub Command1_Click()
Shell "C:\plink\plink.exe userid@192.168.1.100", vbHide
End Sub
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 2000 total points
ID: 9661948
You could also try changing to the Directory before shelling.This example also uses vbNormalFocus in case you don't want to Hide the process as in the above examples.

Private Sub Command1_Click()
ChDrive "C:\"
ChDir "C:\plink"
Shell "plink.exe userid@192.168.1.100", vbNormalFocus
End Sub
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:greetrufus
ID: 9661956
Sorry, I should have included that fact that I will be adding switches in the batch.
Here is a better example of the batch file I am calling (note, I am using VS 7.0 if that matters):

@cls
@echo off
echo Connecting...
@"C:\plink\plink.exe" -v -C -P 26 -L 5900:192.168.1.101 userid@192.168.1.100
0
 

Author Comment

by:greetrufus
ID: 9661968
Never mind.  Your solution worked perfectly.
Thank you very much!!
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9661972
This should work:

Private Sub Command1_Click()
Shell Environ("Comspec") & " /c C:\plink\plink.exe -v -C -P 26 -L 5900:192.168.1.101 userid@192.168.1.100", vbNormalFocus
End Sub
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question