?
Solved

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

Posted on 2009-05-20
3
Medium Priority
?
569 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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

770 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