• 0

[VB.NET] Remote Shell Command Help (please!)


Question

Hello All, just found out about Neowin, looks fantastic!

I have what I think is a very simple question in VB.NET, I'm just starting out with the language.

To run a standard application, I typically run:

Shell(mxcl -d)

within a button to launch the program in question. I'd like however to be able to run this command to a comptuer on my lan (remote computer). I've tried PsExec with no luck. I've tried something along the lines of:

Shell(psexec \\computerName -u "my name" -p Password "mxcl -d")

Not sure if I'm using PsExec correctly, but that's besides the point. I don't need to use PsExec at all, just want my remote computers to launch these programs!

Thanks for reading, any help would be greatly appreciated!

hahaha: "Resident One Post Wonder"... i'm new!

4 answers to this question

Recommended Posts

  • 0
  cicero38 said:
Hello All, just found out about Neowin, looks fantastic!

I have what I think is a very simple question in VB.NET, I'm just starting out with the language.

To run a standard application, I typically run:

Shell(mxcl -d)

within a button to launch the program in question. I'd like however to be able to run this command to a comptuer on my lan (remote computer). I've tried PsExec with no luck. I've tried something along the lines of:

Shell(psexec \\computerName -u "my name" -p Password "mxcl -d")

Not sure if I'm using PsExec correctly, but that's besides the point. I don't need to use PsExec at all, just want my remote computers to launch these programs!

Thanks for reading, any help would be greatly appreciated!

hahaha: "Resident One Post Wonder"... i'm new!

Welcome!

For me, the shell command never seems to pass arguments correctly.

You can try using the System.Diagnostics.Process class to start a new process and pass arguments to it.

You use the Process.StartInfo.FileName attribute to launch your application.

Use the Process.StartInfo.Arguments attribute to list the program arguments.

Process.Start() starts the application.

To point you in the right direction, it would look something like this:

Imports System.Diagnostics 'At the top of your code

Dim p As New Process()

p.StartInfo.FileName = "psexec"
p.StartInfo.Arguments =  "\\computerName -u "my name" -p Password "mxcl -d"
p.Start()

For more information, see the MSDN documentation.

  • 0

Thanks xcguy87 and Rudy.

Going to try making a new Process, sounds very straightforward, thanks for the tip! Will post my results even if it works.

But what does it mean, when one says "you need to start escaping stuff"? Sorry, still learning the programming lingo.

  • 0
  cicero38 said:
Thanks xcguy87 and Rudy.

Going to try making a new Process, sounds very straightforward, thanks for the tip! Will post my results even if it works.

But what does it mean, when one says "you need to start escaping stuff"? Sorry, still learning the programming lingo.

He's referring to the fact that I didn't use escape characters when showing you the code examples...

It should have been:

Dim p As New Process()

p.StartInfo.FileName = "psexec"
p.StartInfo.Arguments =  "\\computerName -u ""my name"" -p Password ""mxcl"" -d"
p.Start()

(notice the double quotation marks?)

The VB.NET compiler associates a quotation mark with the end of a string. Double quotation marks indicate to insert a quotation mark character, instead of indicating the end of the string. The example I gave early would produce compiler errors.

Sorry about that, I usually develop in c# and couldn't remember visual basic's escape character's off hand.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.