Solved

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

Posted on 2009-05-20
3
552 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
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

803 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