Incorporating cmd .exe file to run with parameters and text output

Hi! This project is not for any academic course (I might have questions once school starts back up, however)

I will start off by saying I do not claim to be the best searcher on the net--but I've put a fair amount of effort into searching--and haven't found anything that talks about QUITE what I need to do.

Also, I attempted to ask this question on another forum, but the admin has some issue and banned me for no reason (I promise--they did not give a coherent reason for the ban. I contacted their admin, no response. I am considering taking legal action against their forum because I feel it discriminates against users with Asperger's Syndrome, like myself.) For your reference, I asked the question on the ozgrid.com forums. I read and adhered to all their forum rules to the best of my ability. For the record, I would advise anyone from ever posting on their forums.

I also asked my question on the winamp forums, where I am a long-time member, but the question remains unanswered. For your convenience: The winamp thread is accessible at http://forums.winamp...threadid=295284

I am working on a project to create a spreadsheet that archives a list of all files on CD-R's along with user-input categories (like who the disc is by. Microsoft, for example)

I was going to use good old command prompt dir > text, but then I found a better solution--an exe file that exports all the files properties nicely to csv text file. It also includes MD5 checking--nice for checking for duplicate files across the discs.

The last time I did anything with VB was over 13 years ago in middle school, so I'm a little rusty. I've done searching on the net over the past week to help refresh my memory. I saw the sticky thread to the Ebook, but the link was broken. If anyone has that reference, I would REALLY appreciate it.

I have already figured out how to write the code to take the output of the CSV .txt file into the excel spreadsheet & do what it needs to do. I will post the code below:

I am designing this in the VBA macro tool thing by Microsoft. I do not have visual studio on this computer--just what comes with MS Office. You will see some of my comments in the code--they aren't directed to anyone on the forum; more to myself than anything else.

I want driveletter & discnumber to be input by user--ideally have the VB code substitute these into the syntax I listed above.

I had looked at using the Shell command. I saw a similar thread regarding using shell to call out an external .exe, but the person seems to be running into the same issue as me---being unable to get text output properly.

I also thought about using VBA to 1.) get the user input, 2.) WRITE a .bat file to call out the .exe file with the proper syntax BASED on the input, 3.) run that .bat file.

I also tried a suggestion I read about...putting the arguments in quotes. It didn't like this one bit.

Please note: At this stage, I'm just trying to get the text exporting process to work. I currently have no idea how to do the custom syntax; so I'm trying to get the simple version to work before trying the complicated one using the inputs)

------------------------------------------------------------
A link to a helpful page, thread, or guide would be great.

Suggestions would be preferred, but I am willing to try to figure it out if I have a resource available to do so.

Any idea what I'm doing wrong? Also, I still would like to accomplish what I asked previously. I apologize if the bump is rude; I am not sure what is considered a normal wait time before bumping on this forum.

Re: Incorporating cmd .exe file to run with parameters and text output

Posted 05 August 2008 - 08:53 AM

Update:

I have managed to solve the isssue of calling out the external command prompt .exe file. I decided to use VBA to write a .bat file that would call out the filelist.exe file.

Right now I'm just working out bugs & trying to figure out ways to perform checks for user error

Please see commented aspects of text for issues in question. Some of my comments are more to me than anything else

Still unresolved is the error in the code to find if Disc ___ has already been entered; and if so, prompt user whether to continue or break.

I'm also working on figuring out code to check if the file about to be written by the filelist.exe already exists. This shouldn't be too much of a problem for me.

I'm also thinking about having a final prompt before the code actually performs the operation of importing the text from the CSV .txt file . The prompt would be something like:
"You have entered Disc ___, By: _______. Is this correct?"
I'm thinking about using vbYesNo.
If answered no, then it will break. If yes, it will continue.

Re: Incorporating cmd .exe file to run with parameters and text output

This code is giving me fits. I had the certain parts working fine this morning; but as I tried to make it more able to detect whether the input DiscNumber was an integer & giving a smarter output error message, I lost the functionality of the previous code!

It's driving me nuts, and I can't seem to figure out how to get it to go back to how it was!

This morning: I was able to have it successfully check to see if the disc__.txt already exists, and if so,l to have it warn you that the file exists & ask if you want to enter another number or cancel. It also worked to check to see if Disc [discnumber] appeared in the spreadsheet and do the same thing--successfully

I had originally run into trouble with it giving an error if the user hit cancel, which I was able to get around with On Error GoTo (spot right before end). I wanted to avoid such a blanket situation (every error goes makes it stop)---so I was going to use the integer check, etc.

I also had successfully implemented the message box right before the code takes the text output from filelist.exe & works it into the spreadsheet.

Re: Incorporating cmd .exe file to run with parameters and text output

Posted 06 August 2008 - 01:07 PM

gabehabe, on 6 Aug, 2008 - 12:32 PM, said:

Please don't create a new thread to bump an old one.

Threads merged.

I'm sorry =(

Anybody have any clues at all? I think I realize that I need to start out the Case thing with the Cancel case, then use Case Else to handle the part if the user clicks OK.

Working on the code now. Please bear in mind I'm a borderline n00b at VB...I supposedly took a course in middle school that was supposed to teach me VB, but the class was more or less a disaster b/c of a lot of issues. We ended up spending more time waiting for the teacher to come around to look at code than actually learning. Plus that was over 10 years ago that I took that class. I just started working on this project around a week & a half ago, so I'm learning VB as I go =/

If my questions are dumb, I apologize---I sometimes get stumped over minor details although I think I'm at least moderately intelligent

Re: Incorporating cmd .exe file to run with parameters and text output

Posted 12 August 2008 - 02:28 PM

*bump*

Still running into Runtime Errors the 2nd time through:

My error handling handles the user cancelling the first inputbox correctly---the first time.
After clicking cancel the first time, it takes them to the prompt asking them if they really want to cancel or if they want to start over. If they click start over, & then click cancel AGAIN, my error handling gives the runtime error that my error handling code got around the first time.

Everything else in my code is decently solid.

Any idea what's causing my runtime error the 2nd time through & how to fix it?

Re: Incorporating cmd .exe file to run with parameters and text output

Posted 05 November 2008 - 11:41 AM

Hi, I am a basic novice however I also have this problem. I have found a part way through this problem and I think I understand why it is happening. I hope this helps but please understand my knowledge is limited.
First the batch file is still busy when the log file is trying to be written. If you tested the program with a differnt batch commmand say example ipconfig, you might well find it works. This is because the ip config runs quicker and the logfile makes for ok and displays.
I placed a timer delay of 1 second between my batch being executed and the file contents being displayed. You may need longer, 1 second is ok for ipconfig.
I first tried this with the Sleep command tied in to a module but this made the program very buggy, so instead I added a timer.

This info is probably enought to get you out of trouble, however i am still stuck because my timer is in a loop, if I stop the loop I cannot change the timer from 1. I being either i hour or minute or second, as when i do this it does not display the text as required.
No doubt I will get round this, but the main thing I wanted to let you know was the delay between the dos program starting and printing does work. It is just amatter of making the delay long enough to wait untill the dos program has finished tasking.
I can pass some of code to you if required, but its likely to appear a bit of long way round job, due to my inexperience.
Kind regards and good luck.