7 Replies - 3682 Views - Last Post: 09 August 2012 - 12:08 AM Rate Topic: -----

#1 geoleob  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 06-August 12

I am new to VB. How do I execute a DOS command (i.e Copyfile) from VB?

Posted 06 August 2012 - 10:05 AM

I have rtried the 'Shell' command and that does not work. Can not find any help in 'Books Online'.
Is This A Good Question/Topic? 0
  • +

Replies To: I am new to VB. How do I execute a DOS command (i.e Copyfile) from VB?

#2 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: I am new to VB. How do I execute a DOS command (i.e Copyfile) from VB?

Posted 06 August 2012 - 02:33 PM

Well, CopyFile isn't a DOS command. Maybe that's the real reason Shell doesn't work? Try using Copy or Xcopy instead. Feel free to post your code so we can have a better idea of where you're going wrong.
Was This Post Helpful? 0
  • +
  • -

#3 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 876
  • View blog
  • Posts: 2,312
  • Joined: 28-March 11

Re: I am new to VB. How do I execute a DOS command (i.e Copyfile) from VB?

Posted 06 August 2012 - 02:45 PM

Can I ask why do you want to use command line stuff? Doesn't VB have its own file functions? If you are not happy with them, you could always use the File Functions from the Windows API, which are as powerful as you need them to be.

DOS is dead, let it rest in piece!
Was This Post Helpful? 0
  • +
  • -

#4 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: I am new to VB. How do I execute a DOS command (i.e Copyfile) from VB?

Posted 07 August 2012 - 12:33 PM

DOS is alive and well so long as I am. How the hell else would I execute a batch file? :P

This post has been edited by BobRodes: 07 August 2012 - 12:34 PM

Was This Post Helpful? 0
  • +
  • -

#5 geoleob  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 06-August 12

Re: I am new to VB. How do I execute a DOS command (i.e Copyfile) from VB?

Posted 07 August 2012 - 04:02 PM

View PostGunnerInc, on 06 August 2012 - 02:45 PM, said:

Can I ask why do you want to use command line stuff? Doesn't VB have its own file functions? If you are not happy with them, you could always use the File Functions from the Windows API, which are as powerful as you need them to be.

DOS is dead, let it rest in piece!


as being new to VB, I am unaware how touse thw windows API. Any help would be most appreciated!!

I want to use a command button to copy a file to an external drive. as I am new to VB, I do not know how to use the Windows API. Any help will be appreciated.
Was This Post Helpful? 0
  • +
  • -

#6 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,797
  • Joined: 26-March 09

Re: I am new to VB. How do I execute a DOS command (i.e Copyfile) from VB?

Posted 07 August 2012 - 11:41 PM

Rather than using API's, have a look at the FileSystemObject, which will give you all you need to copy files.

You will need to add a reference to Microsoft Scripting Runtime.

Take a look at this link for further information.
Was This Post Helpful? 1
  • +
  • -

#7 geoleob  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 06-August 12

Re: I am new to VB. How do I execute a DOS command (i.e Copyfile) from VB?

Posted 08 August 2012 - 07:25 PM

View Postmaj3091, on 07 August 2012 - 11:41 PM, said:

Rather than using API's, have a look at the FileSystemObject, which will give you all you need to copy files.

You will need to add a reference to Microsoft Scripting Runtime.

Take a look at this link for further information.


Thaks a bunch, worked the first time!! i will be comming back for more info as I am just a beginner in VB (spent 20 years doing RPG on AS/400)
Was This Post Helpful? 0
  • +
  • -

#8 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,797
  • Joined: 26-March 09

Re: I am new to VB. How do I execute a DOS command (i.e Copyfile) from VB?

Posted 09 August 2012 - 12:08 AM

No problem, glad to have helped.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1