Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, 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.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Batch File


  • Please log in to reply
7 replies to this topic

#1 Guest_danbrownlow_*

Guest_danbrownlow_*

  • Guests
  • OFFLINE
  •  

Posted 22 October 2007 - 10:33 AM

Hello all, I have a little problem. I use java and javac alot and everytime I open "cmd" I have to cd to the right directory! Which can be a pain.

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

BC AdBot (Login to Remove)

 


m

#2 Guest_uhaligani_*

Guest_uhaligani_*

  • Guests
  • OFFLINE
  •  

Posted 22 October 2007 - 12:22 PM

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.

#3 Guest_danbrownlow_*

Guest_danbrownlow_*

  • Guests
  • OFFLINE
  •  

Posted 22 October 2007 - 12:35 PM

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?

#4 usasma

usasma

    Still visually handicapped (avatar is memory developed by my Dad


  • BSOD Kernel Dump Expert
  • 25,073 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Southeastern CT, USA

Posted 22 October 2007 - 06:15 PM

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.
My browser caused a flood of traffic, sio my IP address was banned. Hope to fix it soon. Will get back to posting as soon as Im able.

- John  (my website: http://www.carrona.org/ )**If you need a more detailed explanation, please ask for it. I have the Knack. **  If I haven't replied in 48 hours, please send me a message. My eye problems have recently increased and I'm having difficult reading posts. (23 Nov 2017)FYI - I am completely blind in the right eye and ~30% blind in the left eye.<p>If the eye problems get worse suddenly, I may not be able to respond.If that's the case and help is needed, please PM a staff member for assistance.

#5 Guest_uhaligani_*

Guest_uhaligani_*

  • Guests
  • OFFLINE
  •  

Posted 23 October 2007 - 04:50 AM

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?

#6 frankblourtango

frankblourtango

  • Members
  • 63 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:philly

Posted 23 October 2007 - 10:33 AM

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.

#7 Guest_danbrownlow_*

Guest_danbrownlow_*

  • Guests
  • OFFLINE
  •  

Posted 23 October 2007 - 11:24 AM

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 =]

#8 Guest_uhaligani_*

Guest_uhaligani_*

  • Guests
  • OFFLINE
  •  

Posted 24 October 2007 - 12:42 AM

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?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users