• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 13040
  • Last Modified:

Shell Command in vb.net



I had a program which will convert the content of text file into a desired format and inorder to run this pro we need to pass in input filename paramter and keyword /p and will generate a txt in the working ditector. I have excecuted the below syntax in command prompt and the conversion works fine.

CD C:\Program Files

CD My Converter

C:\ProgramFiles\MyConverter>Converter /p c:\test2.txt

Conversion sucessful

VB.net code


        Dim stemp As String
        stemp = "cmd /c c:\Program Files\MyConverter\Converter.exe /p " + "c:\test2.txt "
        Shell(stemp)
 
But .net code does nt work..What seems to be the problem lately. Experts, pls advice.
       
0
niger007
Asked:
niger007
  • 2
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
Hi niger007,

it might be the space in the path.

try this:
stemp = "cmd /c " + chr(34) + "c:\Program Files\MyConverter\Converter.exe" + chr(34) + " /p " + "c:\test2.txt "


Cheers!
0
 
Éric MoreauSenior .Net ConsultantCommented:
niger007,

You might also want to check the Process.Start method that is more .Net-ish!
0
 
niger007Author Commented:
David Bro,

Awesome.... it is working now..

Niger.
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.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now