Welcome Guest ( Log In | Click here to Register a free account now! )
Welcome to Bleeping Computer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.| Important Announcement: We have two terrific contests running on the site that I wanted all our members and guests to know about. The first contest is the HP Magic Giveaway, which is underway as of November 28th. More information can be found at this topic, which will be updated very soon with further information. The second contests, is for the chance to win two Seagate FreeAgent external hard drives. More information about this contest can be found here. These are both amazing contests and I suggest everyone submit an entry for them. - BleepingComputer Management |
![]() ![]() |
Oct 22 2007, 10:33 AM
Post
#1
|
|
|
Member ![]() ![]() Group: Members Posts: 89 Joined: 5-March 07 From: Brighton, UK Member No.: 115,537 |
Well, I thought I'd make a .bat file so that when I click and open it, it would be in the right directory. I went into Notepad and typed: CODE cd c:\Users\<username>\Documents\Java and saved it as a .bat file, however, when I run it, it comes up quickly and then dissapears! I tried adding pause to the end, but that was no help. Can anyone offer any ideas? Thanks :D |
|
|
|
Oct 22 2007, 12:22 PM
Post
#2
|
|
|
Forum Regular ![]() ![]() ![]() Group: Validating Posts: 224 Joined: 18-January 07 Member No.: 106,976 |
You will need to write the path to where the .bat file is situated.
eg The default for the command prompt is c:\users\username. so the easiest thing would be to place the bat file in that folder. |
|
|
|
Oct 22 2007, 12:35 PM
Post
#3
|
|
|
Member ![]() ![]() Group: Members Posts: 89 Joined: 5-March 07 From: Brighton, UK Member No.: 115,537 |
It does exactly the same thing, when I start the bat file, it loads and dissapears. I wanted it to automatically change the directory so I wouldn't need to manually type it in everytime I want to compile or run a java file.
Anyone got any more ideas? |
|
|
|
Oct 22 2007, 06:15 PM
Post
#4
|
|
![]() Still visually handicapped, new avatar :0) ![]() ![]() ![]() ![]() ![]() ![]() Group: Moderator Posts: 14,697 Joined: 2-October 05 From: Southeastern CT, USA Member No.: 35,824 |
Do you run the .bat file in the cmd window? If not, then it'll just terminate when it's done. The /f switch will prevent the command prompt from closing, but I'm not familiar enough with the syntax to figure out how to do it.
-------------------- - John
**If you need a more detailed explanation, please ask for it. I have the Knack. ** |
|
|
|
Oct 23 2007, 04:50 AM
Post
#5
|
|
|
Forum Regular ![]() ![]() ![]() Group: Validating Posts: 224 Joined: 18-January 07 Member No.: 106,976 |
Your syntax is corrct. I've tried every combination and it works for me. I called the bat "try" (but the name is of no significance!) I saved it to my user, which in my case is "Administrator" (I run as the "power" administrator, without a user). For the exercise I created the Folder "java". Every time it changed to that directory.
Have you tried right clicking the Command prompt and running as the Administrator, thats all I can think of? |
|
|
|
Oct 23 2007, 10:33 AM
Post
#6
|
|
![]() Member ![]() ![]() Group: Members Posts: 63 Joined: 26-September 07 From: philly Member No.: 159,308 |
Does it give you any error if you open a dos prompt and then run it? See if it completes without any errors and returns to the prompt. I test my batches by doing that and watching them complete. Just my two cents.
|
|
|
|
Oct 23 2007, 11:24 AM
Post
#7
|
|
|
Member ![]() ![]() Group: Members Posts: 89 Joined: 5-March 07 From: Brighton, UK Member No.: 115,537 |
Yea' it runs fine when I open it via CMD by typing 'java.bat', I kind of was wondering how I could get it to run by just clicking the link file in Explorer, as I am quite lazy. Thanks for the help anyway, it works fine in CMD so thank you =]
|
|
|
|
Oct 24 2007, 12:42 AM
Post
#8
|
|
|
Forum Regular ![]() ![]() ![]() Group: Validating Posts: 224 Joined: 18-January 07 Member No.: 106,976 |
I think I misunderstood your intention. I thought you were concerned with the command prompt. If you want to open Windows explorer to your Java folder, then you should open another instance of explorer on your desktop or shortcut menu. right click and in the properties , after C:\Windows\explorer.exe make a space and then C:\Users\<username>\Documents\Java. Is that what you are looking for?
|
|
|
|
![]() ![]() |
| Lo-Fi Version | Time is now: 3rd December 2008 - 03:48 PM |