Difficulty using "Shell"

  • Thread starter Thread starter Amjad
  • Start date Start date
A

Amjad

I'm trying to create a folder, append text file to
another, and delete files using the "Shell" command. But
I always get the error "File Not Found".

How do I use DOS commands from Visual Basic?

My code is something like:

Dim folderPath as String
folderPath = "C:\MyFolder"
Shell ("md " & folderPath)
 
Amjad said:
I'm trying to create a folder, append text file to
another, and delete files using the "Shell" command. But
I always get the error "File Not Found".

How do I use DOS commands from Visual Basic?

My code is something like:

Dim folderPath as String
folderPath = "C:\MyFolder"
Shell ("md " & folderPath)

md is a resident command of command.com or cmd.exe. You must call

shell "cmd.exe /c md test"

(untested)

Instead of "cmd.exe" use environ("comspec")

Apart from this: Why do you want to use DOS commands?
 
Hi Lou,

It must have been discouraging to have been 'ignored'. :-(

But it's very unlikely that your question would have been left unanswered
This only occurs when the topic is well outside the area of any of the many
people who answer questions here. As I can't see your question in my
newsreader (and I update frequently throughout the day), I suspect that it may
have failed to reach the server.

Regards,
Fergus
 
* "Armin Zingler said:
md is a resident command of command.com or cmd.exe. You must call

shell "cmd.exe /c md test"

(untested)

Instead of "cmd.exe" use environ("comspec")

Apart from this: Why do you want to use DOS commands?

DOS commands or "command shell" commands...

;-)
 
*Amjad* tippselte am *21.10.2003 15:50* MESZ:
I'm trying to create a folder, append text file to
another, and delete files using the "Shell" command. But
I always get the error "File Not Found".

How do I use DOS commands from Visual Basic?

VB.NET, you meant, right?

However, I think the easiest method is to write all commands to a
temporary batch file and then call the batch file. This has also the
advantage that you can check out easily the contents of the batch file
and see what the operating system does.

Best regards,

Michael
 
* Michael Kremser said:
VB.NET, you meant, right?

However, I think the easiest method is to write all commands to a
temporary batch file and then call the batch file. This has also the
advantage that you can check out easily the contents of the batch file
and see what the operating system does.

Mhm... I prefer redirecting the command shell and execute the commands
against it directly.

;-)
 
Back
Top