Batch File String Functions?

Posted on 2005-04-18
Last Modified: 2008-01-09
Is there any way I can get the containing folder and the filename (without the extension) using a batch file?

I'm trying to write a batch file to open Java programs I'm writing.  I'm using NetBeans to write the programs, but from what I can tell, there's no way to open a class file and have it automatically execute in NetBeans.  So I'm trying to write a batch file or something that I will associate with class files.

I need the batch file to do something like this:
    Say the file I opened is "E:\Programming Files\Java\SwingCalc\SwingCalc.class"
    It will do this...
        CD "E:\Programming Files\Java\SwingCalc\"
        java SwingCalc

If this can't be done with a batch file, is there any way I could do this using a VB script or something else that's built into windows?
Question by:Crash2100
    LVL 18

    Accepted Solution

    Never mind, I found these two articles and figured out how to do this:

    Using Java Classes in Windows Batch Files

    Directory removal Batch File

    And here's the batch file I ended up using:

    @echo off
    cd %~p1
    java %~n1
    LVL 15

    Expert Comment

    Crash2100, you should close this question and get a refund for your points.  Take a look at the below to see how to do this:
    LVL 18

    Author Comment

    I already posted a question in CS for them to close it.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    There are 2 things you must have in order to connect to the internet behind a router, The "Gateway IP" of the router, which is usually something like, I've seen routers with default values of:,,, …
    Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now