[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB.NET Call executable with parameters in VB Script

Posted on 2007-07-20
3
Medium Priority
?
1,377 Views
Last Modified: 2008-01-09
I have the following code, plink is is an executable. I am running this code from the same directory as the executable. When I am testing the code it does not seem to be working. Any ideas why this might be, all of the variables are being assigned correctly. If I type the command directly into a command prompt it works. Any ideas why this isnt working, also is there a way to get the output that the executable is sending out and print it wo screen?


Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec("cmd /c plink '" & LoadBalancer & "' -l '" & Username & "' -pw '" & Password & "' bigpipe node '" & RebootComputer & "' down")
0
Comment
Question by:Benjamin297
  • 2
3 Comments
 
LVL 31

Expert Comment

by:merowinger
ID: 19530129
execute the script that u only see the command in a msgbox!
Then u can verify that's all right!

msgbox "cmd /c plink '" & LoadBalancer & "' -l '" & Username & "' -pw '" & Password & "' bigpipe node '" & RebootComputer & "' down")
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 19530515
Hi, you can try replacing your single quotes in the command with the double-quote character, which you "double-up" in VBScript to represent one literal quote inside a string.
For example:
strString = "test string here"
outputs: test string here
strString = "test ""string"" here"
output: test "string" here

So, you can try:
objShell.Exec("cmd /c plink """ & LoadBalancer & """ -l """ & Username & """ -pw """ & Password & """ bigpipe node """ & RebootComputer & """ down")

And also, instead of MsgBox, I tend to use an InputBox so you can just copy and paste the exact text into a command line:
strCommand = "cmd /c plink """ & LoadBalancer & """ -l """ & Username & """ -pw """ & Password & """ bigpipe node """ & RebootComputer & """ down"
strCommand = InputBox("Prompt", "Title", strCommand)
Set objExec = objShell.Exec(strCommand)

Regards,

Rob.
0
 
LVL 31

Expert Comment

by:merowinger
ID: 19530591
or try the vbscript function: Chr(34)  
this makes " too

Try also:
objShell.Run not Exec
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

830 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