Solved

how do you use cmd in vb6 to excute cmd command like delete *.txt

Posted on 2009-05-20
3
555 Views
Last Modified: 2012-05-07
how do you use cmd in vb6 to excute cmd command like C:\tmp_email\messages>delete *.mai in other Language they use run or spawn

Description

Runs the specified application program.

Syntax

Run ( string {, windowstate } )

Argument      Description
string      A string whose value is the file name of the program you want to execute. Optionally, string can contain one or more parameters for the program.
windowstate (optional)      A value of the WindowState enumerated datatype indicating the state in which you want to run the program:·      Maximized! - Maximized; enlarge the program window to its maximum size when it starts·      Minimized! - Minimized; shrink the program window to an icon when it starts·      Normal! - (Default) Run the program window in its normal size

Description

in C or C++ they use

_spawnl, _wspawnl
Create and execute a new process.

int _spawnl( int mode, const char *cmdname, const char *arg0, const char *arg1, ... const char *argn, NULL );

int _wspawnl( int mode, const wchar_t *cmdname, const wchar_t *arg0, const wchar_t *arg1, ... const wchar_t *argn, NULL );

Routine Required Header Compatibility
_spawnl <process.h> Win 95, Win NT
_wspawnl <stdio.h> or <wchar.h> Win NT

what do they use for vb6
0
Comment
Question by:1030071002
[X]
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
3 Comments
 
LVL 15

Expert Comment

by:ChloesDad
ID: 24435579
VB6 uses a shell command

Shell(command,{ window_style})

where command is a string containing the text that you would type at the command prompt

so your example would be

shell("delete C:\tmp_email\messages\*.mai")
0
 

Expert Comment

by:MartanElite
ID: 24437027
Try this
Dim FilePath As String = "c:\*.txt"

Dim sr As StreamReader = File.Delete (FilePath)

rtfBox.Text = sr.ReadToEnd
0
 
LVL 6

Accepted Solution

by:
nirojexpert earned 500 total points
ID: 24438191
you can make dos run any dos command by  passing the command after /c  and then shell it as chloes said
see the exmaple below.

cmdstr="cmd /c del c:\temp_email\message\*.mai"
shell cmdstr

Open in new window

0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

730 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