Batch File String Functions?

Posted on 2005-04-18
Medium Priority
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
  • 2
LVL 18

Accepted Solution

Crash2100 earned 0 total points
ID: 13811791
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

ID: 13812030
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

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We have adopted the strategy to use Computers in Student Labs as the bulletin boards. The same target can be achieved by using a Login Notice feature in Group policy but it’s not as attractive as graphical wallpapers with message which grabs the att…
Step by step guide to Clean and Sort your windows registry! Introduction: Always remember: A Clean registry = Better performance = Save your invaluable time In this article we're going to clear our registry manually! Yes, manually! The e…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

840 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