Results 1 to 31 of 31

Thread: (VB6 & DOS) I have a batch file but I would rather have the VB interface.

  1. #1

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057

    (VB6 & DOS) I have a batch file but I would rather have the VB interface.

    I'm not to sure how this batch file works (basicly it is contacting another co's server and transfering files) but I believe it is through java. I control it via the command window. Will it be hard or even possible to convert to vb?
    Code:
    echo off
    rem set JDK_BIN=D:\jdk\bin\
    SET CLASSPATH=D:\blahxf\java;D:\Blahxf\lib\email.jar;D:\Blahxf\lib\jnet.jar;D:\Blahxf\lib\foo.jar
    SET CLASSPATH=%CLASSPATH%;D:\Blahxf\lib\jsse.jar;D:\Blahxf\lib\jcert.jar
    JAVA -Xms8M com.Blah.interfaces.pms1way.BlahClient  -S Y
    Thanks
    Michael
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  2. #2
    Hyperactive Member Blinky Bill's Avatar
    Join Date
    Mar 2002
    Location
    Happily munching on the greenery in your garden
    Posts
    349
    Do you want to convert the batch file or the java code it executes?
    We don't know what's wrong. . . So the best bet might be to remove something surgically.

  3. #3

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    Just the batch... the batch and the java are from a different company and they may change something one day and assume I am just switching out the files.
    I would even be happy with opening the batch file in a 'window' on a form kind of like a WebBrowser element.
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  4. #4
    Hyperactive Member Blinky Bill's Avatar
    Join Date
    Mar 2002
    Location
    Happily munching on the greenery in your garden
    Posts
    349
    If you just want to run the batch file you could use the Shell command on it. Or use ShellExecute if you want it to finish before you continue your program.
    We don't know what's wrong. . . So the best bet might be to remove something surgically.

  5. #5

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    What this program is, is basicly a holder for an asp page that it refreshes every 30 seconds and hopefully will run or hold the batch file (that executes every 60 seconds on its own) so I guess the "Shell" method is what I am looking for... could you elaborate a bit on that or point me in the right direction?
    thx
    ms
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  6. #6
    Hyperactive Member Blinky Bill's Avatar
    Join Date
    Mar 2002
    Location
    Happily munching on the greenery in your garden
    Posts
    349
    Usage is really simple
    VB Code:
    1. Shell(MyApp.bat, vbNormal)

    It takes the two arguments, the app to run, this can be a bat file with command line arguments if you wish, and the second argument is how to run it, Hidden, Normal, Maximised, etc.

    If you want more information check out the microsoft website.
    We don't know what's wrong. . . So the best bet might be to remove something surgically.

  7. #7

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    k that wasnt really what I wanted. You know how the webBrowser element lets you open IE on (in) a form can I run the batch file like that?
    Michael
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  8. #8
    Hyperactive Member Blinky Bill's Avatar
    Join Date
    Mar 2002
    Location
    Happily munching on the greenery in your garden
    Posts
    349
    I don't know of any control you can use to use a batch file like a webpage. The only thing i can suggest is looking into setting the size and position of the command window using API's.
    We don't know what's wrong. . . So the best bet might be to remove something surgically.

  9. #9

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    I think what I'm trying to say is that I don;t want a seperate command window.
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  10. #10
    Addicted Member PhilRob56's Avatar
    Join Date
    Oct 2002
    Location
    New York
    Posts
    249
    Recently I came across a nice VB Class module that executes a DOS command and captures the output to any control (textbox / label) that you like. The good thing about it is that it uses the API to execute the DOS command and therefore you don't get the DOS window - the whole process is invisible.

    I use it to read the EXIF data from digital camera files, because the program I have to extract the data is a command line program only.

    If you want it let me know and I will post it for you.
    Some days you're the dog,
    and some days you're the hydrant.


    VB6 Enterprise

  11. #11

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    Originally posted by PhilRob56
    Recently I came across a nice VB Class module that executes a DOS command and captures the output to any control (textbox / label) that you like. The good thing about it is that it uses the API to execute the DOS command and therefore you don't get the DOS window - the whole process is invisible.

    I use it to read the EXIF data from digital camera files, because the program I have to extract the data is a command line program only.

    If you want it let me know and I will post it for you.
    that sounds like what I am looking for... I was just explaining it poorly when I used the webbrowser as an example I should have though about the text box.

    post please

    thanks
    michael
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  12. #12
    Addicted Member PhilRob56's Avatar
    Join Date
    Oct 2002
    Location
    New York
    Posts
    249
    Ok. I just had a quick look on the web and cannot find it , so I'll have to post it from home in about 4 hours time.
    Some days you're the dog,
    and some days you're the hydrant.


    VB6 Enterprise

  13. #13

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    no hurry I have about 5 projects running at the same time so I have plenty to work on in the meantime.
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  14. #14

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    hmmm... you deleted your post chicocouk
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  15. #15
    Addicted Member PhilRob56's Avatar
    Join Date
    Oct 2002
    Location
    New York
    Posts
    249

    Here 'Tis!

    Here it is!
    The code originally came from Planet Source Code, so I take no credit at all. I will say that it works, and does a good job.



    Attached Files Attached Files
    Some days you're the dog,
    and some days you're the hydrant.


    VB6 Enterprise

  16. #16
    Addicted Member chicocouk's Avatar
    Join Date
    Sep 2001
    Posts
    207
    msimmons, yeah I did, sorry

    After re-reading the code i was posting, it was to run .exe files and pipe the output to a vb textbox or label or whatever. It works with things like ipconfig.exe or ping.exe etc, but i don't think it works with batch files, so i didn't want to confuse the issue

    (and i'd have got away with it if it hadn't been for you pesky kids )
    MCSE, Mcp+I, Unicenter Engineer

  17. #17

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057

    Re: Here 'Tis!

    Originally posted by PhilRob56
    Here it is!
    The code originally came from Planet Source Code, so I take no credit at all. I will say that it works, and does a good job.
    Awesome, thanks for finding that. Quick question though (I really only need to turn my batch file on and off so am going to get rid of the command line and replace w/on off buttons. When it is in the command window I hit ctrl+c to turn it on and off (or just call it to turn on). how would I do via this program?

    Originally posted by chicocouk
    msimmons, yeah I did, sorry

    After re-reading the code i was posting, it was to run .exe files and pipe the output to a vb textbox or label or whatever. It works with things like ipconfig.exe or ping.exe etc, but i don't think it works with batch files, so i didn't want to confuse the issue

    (and i'd have got away with it if it hadn't been for you pesky kids )
    No problem... I guess i got to it before you deleted it (and the code didn;t seem to work for me) when I cam back to reply/ask it was gone
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  18. #18
    Addicted Member PhilRob56's Avatar
    Join Date
    Oct 2002
    Location
    New York
    Posts
    249
    Since this module simply creates a process, I guess all you need to do is to exeute the batch file. Windows knows to execute a .BAT file natively.
    Some days you're the dog,
    and some days you're the hydrant.


    VB6 Enterprise

  19. #19

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    yeah but if I need to kill it I normaly hit ctrl+c then I can just ctrl+c to restart it... I guess I can just send the VB app a different command to clear the batch file out then reload it when ready.
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  20. #20

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    I made all the adjustments I needed to (decided to forgo the ctrl+c part. we can just kill the app when needed). It runs fine on my NT4.0 machine but the final destination is my Win2K server. When i click the exe to start it nothing happens. (it gets added to the task manger but the form never loads.) Is there some adjustment that needs to be made between the two OS's?
    thanks
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  21. #21

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    never mind. I think it has to be in the root of c:
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  22. #22

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057

    small problem...

    the batch file is in a directory on d: and has to be there (I may be able to fix it if I have to but wont be fun ) and I believe the exe has to be in the root of c:. easy right just do this:
    d:
    cd theDirectory
    theBatch.bat

    but the d: (and anything but "help" or the batch name) gives the error:
    File or command not found.
    any ideas?
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  23. #23
    Addicted Member PhilRob56's Avatar
    Join Date
    Oct 2002
    Location
    New York
    Posts
    249
    Sorry, I mised your last question.
    I am using it to execute a DOS Executable with Command Line options.
    When I first tested it the executable was in my Path variable (tested on Win2K), so it was not a problem. On my XP machine at home, after installing it into my project, I decided not to rely on the executable being in the path and specified the full path to the exectable.
    So....to cut a long story short....I wrapped the command string in quotes..

    String = """" & whatever & """"

    Should help (I hope).
    Some days you're the dog,
    and some days you're the hydrant.


    VB6 Enterprise

  24. #24

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    I tried (to first switch to the d: directory):
    VB Code:
    1. objDOS.CommandLine = "d:"
    2.     objDOS.ExecuteCommand
    and
    VB Code:
    1. temp = "d:"
    2.     objDOS.CommandLine = """" & temp & """" 'txtCommand.Text
    3.     objDOS.ExecuteCommand
    both gave that same error
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  25. #25

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057

    odd...

    k, I can go to the batch file directly like so:
    Code:
    d:\theDirectory\Thebatch.bat
    and it will run but it has its own error cos it cannot find the files it needs (I may have to just edit it but won't be fun)
    OR
    I wote a batch file containg this:
    Code:
    d:
    cd theDirectory
    theBatch.bat
    now if I run that batch file from the command window it works perfectly but in the program I have the problem where the exe will show up in the task manager but not really run.



    thanks for all the help
    michael
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  26. #26
    Addicted Member PhilRob56's Avatar
    Join Date
    Oct 2002
    Location
    New York
    Posts
    249

    Thinking........



    I just looked at the batch file again...would it be possible to execute each line individually rather than as a batch?
    Would that work?

    Some days you're the dog,
    and some days you're the hydrant.


    VB6 Enterprise

  27. #27

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    I tried that just now and got the same (command not found) error on each of these lines:
    Code:
    rem set JDK_BIN=D:\jdk\bin\
    SET CLASSPATH=D:\blahxf\java;D:\Blahxf\lib\email.jar;D:\Blahxf\lib\jnet.jar;D:\Blahxf\lib\foo.jar
    SET CLASSPATH=%CLASSPATH%;D:\Blahxf\lib\jsse.jar;D:\Blahxf\lib\jcert.jar
    but on this line
    Code:
    JAVA -Xms8M com.Blah.interfaces.pms1way.BlahClient  -S Y
    i get the same error that i get when i run the batch directly from the exe with the full path:
    java.lang.NoClassDefFoundError: com/synxis/interfaces/pms1way/SrmsPms1WayClient
    Exception in thread "main"
    and i am assuming this is caused by somthing in the company's code that wrote the batch file and it cannot find the files it needs cos it is running in c:
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  28. #28
    Addicted Member PhilRob56's Avatar
    Join Date
    Oct 2002
    Location
    New York
    Posts
    249
    I am starting think that there is some environment issue with Java that needs the Command Window open....



    I don't know what else to offer at this point....sorry.
    Some days you're the dog,
    and some days you're the hydrant.


    VB6 Enterprise

  29. #29

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    I just ran the batch with the full path again and this is the error I get:
    C:\>echo off
    SrmsPms1WayClient initialized at Tue Nov 05 14:47:34 CST 2002
    SrmsPMSSettings.properties not found! Using default values.
    java.lang.NumberFormatException: null
    at java.lang.Integer.parseInt(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at com.bLaH.interfaces.pms1way.SrmsPMSSettings.getServerPort(SrmsPMSSettings.java:163)
    at com.bLaH.interfaces.pms1way.SrmsPMSSettings.setupUrl(SrmsPMSSettings.java:387)
    at com.bLaH.interfaces.pms1way.SrmsPMSSettings.<init>(SrmsPMSSettings.java:87)
    at com.bLaH.interfaces.pms1way.SrmsPms1WayClient.main(SrmsPms1WayClient.java:89)
    Exception in thread "main"
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  30. #30

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    Originally posted by PhilRob56
    I don't know what else to offer at this point....sorry.
    No problem. Thanks for all the help so far
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  31. #31

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057

    *bump*

    Anyone (other than PhilRob56 ) have any ideas?
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width