Solved

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

Posted on 2009-05-20
3
546 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now