Solved

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

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

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…
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…
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…

691 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