Shell command

Posted on 2007-03-21
Last Modified: 2010-04-30
Hi: Can any one please tell me how to i use the shell command to copy file from one location to another. I try to copy from vpath2 into strdestination and it create a file but its blank

ShellExecute 0, vbNullString, Chr(34) & vPath & vFile & Chr(34), vbNullString, vbNullString, vbMaximizedFocus

Option Explicit
Public Declare Function ShellExecute Lib "shell32.dll" _
   Alias "ShellExecuteA" (ByVal HWnd As Long, ByVal lpOperation As String, _
   ByVal lpFile As String, ByVal lpParameters As String, _
   ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Question by:mustish1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18763942
why do you not use the FileCopy command?

anyhow, what is the value of vPath and vFile? maybe you do not call the ShellExecute properly?

Author Comment

ID: 18764023

vpath-->C:\Documents and Settings\khamu443\My Documents\temp20070321-100914.xls


Author Comment

ID: 18764025
OOPS I am sorry
vpath-->C:\Documents and Settings\khamu443\My Documents\temp20070321-100914.txt
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

LVL 20

Expert Comment

ID: 18764055
If this is the case here is your statement
ShellExecute 0, vbNullString,  "C:\Documents and Settings\khamu443\My Documents\temp20070321-100914.txtC:\REMITandNSF\New_Import_PCDI03_032107.txt" ,vbNullString, vbNullString, vbMaximizedFocus

You arent trying to execute anything and
Chr(34) & vPath & vFile & Chr(34), is all togeather

LVL 20

Expert Comment

ID: 18764064
as angel stated why not just use VB's native FileCopy


Author Comment

ID: 18764106
ok thanks. But if you please tell me how to i copy from vpath into vfile thru shellexecute command

Author Comment

ID: 18764132
I try to use the variable names but it gives syntax error.
ShellExecute 0, vbNullString, vpath2 strDestination, vbNullString, vbNullString, vbMaximizedFocus
LVL 143

Accepted Solution

Guy Hengel [angelIII / a3] earned 500 total points
ID: 18764155
>ok thanks. But if you please tell me how to i copy from vpath into vfile thru shellexecute command
please try this:
ShellExecute 0, vbNullString, "cmd /c copy """ & vPath & """ """& vFile & """ ", vbNullString, vbNullString, vbMaximizedFocus

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

623 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