Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a visual basic program and I 1

Status
Not open for further replies.

shaminda

Programmer
Jun 9, 2000
170
US
I have a visual basic program and I use a batch file to run it. So when I double click the batch file the program runs. Here is the code that is inside the batch file.

md C:\Apps
copy L:\SWAIIApps\SDB\Release\*.* C:\Apps
C:
cd \Apps
start prjAssemblyPU.exe

What this code does is it first creates a folder called ‘Apps’ on the C: drive. Then it copies all the files on a network drive folder to the C:\Apps folder. Then it opens the application prjAssemblyPU.exe.

Does anybody know how to do this in Visual Basic? For example when I click a button on a form it should run the commands
 
if you want to do this in straight VB then you can do something like this:

Public Sub CopyFiles(NetworkPath As String)
Dim arFiles() As String
Dim x As Integer
Dim sFile As String
Dim sFolder As String
ReDim arFiles(0)

MkDir "C:\apps"


If Right(NetworkPath, 1) <> &quot;\&quot; Then NetworkPath = NetworkPath & &quot;\&quot;

sFolder = NetworkPath & &quot;*.*&quot;
sFile = Dir$(sFolder, vbNormal)

Do While sFile <> &quot;&quot;
arFiles(x) = sFile
x = x + 1
ReDim Preserve arFiles(0 To UBound(arFiles) + 1)
sFile = Dir$
Loop


x = 0

Do While x <= UBound(arFiles) - 1
Debug.Print NetworkPath & arFiles(x)
Call FileCopy(NetworkPath & arFiles(x), &quot;C:\Apps\&quot; & arFiles(x))
x = x + 1
Loop


End Sub


 
I found a solution. I ran a shell command in my VB program.

Shell &quot;C:\Apps\BatchFile.bat&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top