|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How can I execute a simple command?I have the following routine that I thought was streight forward (I should
know better) Private Sub DOS_Command() Dim lRetVal As Long lRetVal = Shell("erase ""Z:\IDW2\XML Report Files\*.txt""") End Sub When the shell line gets executed, I get a diagnostic "Verify that the file exists in the specified location". The files are there. If I go to a command line and execute the same command. it performs fine. Any ideas or better ways to accomplish the same thing? I believe the Shell function is looking for the "erase" file/program and
since it can't find it, it's throwing an error. I don't know what your specific requirements are, but there are different ways to achieve what you are trying to do. Show quoteHide quote > I have the following routine that I thought was streight forward (I > should know better) > > Private Sub DOS_Command() > > Dim lRetVal As Long > > lRetVal = Shell("erase ""Z:\IDW2\XML Report Files\*.txt""") > > End Sub > > When the shell line gets executed, I get a diagnostic "Verify that the > file exists in the specified location". The files are there. If I go > to a command line and execute the same command. it performs fine. Any > ideas or better ways to accomplish the same thing? > > Private Sub DOS_Command() Erase is an internal OS command, and the way you do this via Shell is to run > Dim lRetVal As Long > lRetVal = Shell("erase ""Z:\IDW2\XML Report Files\*.txt""") > End Sub > > When the shell line gets executed, I get a diagnostic "Verify that the file > exists in the specified location". The files are there. If I go to a > command line and execute the same command. it performs fine. Any ideas or > better ways to accomplish the same thing? cmd.exe with appropriate arguments. In other words, Shell runs an exe file, and there is no erase.exe file to run, and that is the diagnostic's complaint. An easier way might be vb's Kill, eg Kill("Z:\IDW2\XML Report Files\*.txt") If memory serves, Kill takes wild cards. Thank you, thank you. KILL did it just fine.
Show quoteHide quote "AMercer" <AMer***@discussions.microsoft.com> wrote in message news:B6F399D9-500E-4DF1-B60C-C4B5CF2C8FF6@microsoft.com... >> Private Sub DOS_Command() >> Dim lRetVal As Long >> lRetVal = Shell("erase ""Z:\IDW2\XML Report Files\*.txt""") >> End Sub >> >> When the shell line gets executed, I get a diagnostic "Verify that the >> file >> exists in the specified location". The files are there. If I go to a >> command line and execute the same command. it performs fine. Any ideas >> or >> better ways to accomplish the same thing? > > Erase is an internal OS command, and the way you do this via Shell is to > run > cmd.exe with appropriate arguments. In other words, Shell runs an exe > file, > and there is no erase.exe file to run, and that is the diagnostic's > complaint. > > An easier way might be vb's Kill, eg > Kill("Z:\IDW2\XML Report Files\*.txt") > If memory serves, Kill takes wild cards. > Jeffrey Grantz wrote:
Show quoteHide quote > Thank you, thank you. KILL did it just fine. And then there's always the "proper" .NET way, File.Delete.> > "AMercer" <AMer***@discussions.microsoft.com> wrote in message > news:B6F399D9-500E-4DF1-B60C-C4B5CF2C8FF6@microsoft.com... > >> Private Sub DOS_Command() > >> Dim lRetVal As Long > >> lRetVal = Shell("erase ""Z:\IDW2\XML Report Files\*.txt""") > >> End Sub > >> > >> When the shell line gets executed, I get a diagnostic "Verify that the > >> file > >> exists in the specified location". The files are there. If I go to a > >> command line and execute the same command. it performs fine. Any ideas > >> or > >> better ways to accomplish the same thing? > > > > Erase is an internal OS command, and the way you do this via Shell is to > > run > > cmd.exe with appropriate arguments. In other words, Shell runs an exe > > file, > > and there is no erase.exe file to run, and that is the diagnostic's > > complaint. > > > > An easier way might be vb's Kill, eg > > Kill("Z:\IDW2\XML Report Files\*.txt") > > If memory serves, Kill takes wild cards. > > Jeffrey Grantz wrote:
Show quoteHide quote > I have the following routine that I thought was streight forward (I should Being a DOS command, it should probably be run as: cmd /k erase .......> know better) > > > > Private Sub DOS_Command() > > Dim lRetVal As Long > > lRetVal = Shell("erase ""Z:\IDW2\XML Report Files\*.txt""") > > End Sub > > When the shell line gets executed, I get a diagnostic "Verify that the file > exists in the specified location". The files are there. If I go to a > command line and execute the same command. it performs fine. Any ideas or > better ways to accomplish the same thing? B.
Async socket connection ends up in Unable to read data from....
Search for files in folders? Date/Time Pickers/VB2005 Print out contents of a hashtable app.config not copied to bin directory Opening a space delimited textfile in Excel using VB.net entlib UpdateDataSet how to update the database? how to receive data from .NET socket into VB6 winsock ? embedded text file Download tif from the web via a stream with progress indication |
|||||||||||||||||||||||