Computer Help and Spyware Removal Computer Help and Spyware Removal Computer Help and Spyware Removal Computer Help Forums Windows Startup Programs Database Spyware and Malware Removal Guides Computer Tutorials Uninstall Database File Database Computer Glossary Computer Resources
 

Welcome Guest ( Log In | Click here to Register a free account now! )



Register a free account to unlock additional features at BleepingComputer.com
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.
Click here to Register a free account now! or read our Welcome Guide to learn how to use this 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
 
Reply to this topicStart new topic
> Batch File, Not as simple as I thought :(
danbrownlow
post Oct 22 2007, 10:33 AM
Post #1


Member
**

Group: Members
Posts: 89
Joined: 5-March 07
From: Brighton, UK
Member No.: 115,537



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:
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
Go to the top of the page
 
+Quote Post
uhaligani
post 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.
Go to the top of the page
 
+Quote Post
danbrownlow
post 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?
Go to the top of the page
 
+Quote Post
usasma
post 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. **
Go to the top of the page
 
+Quote Post
uhaligani
post 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?
Go to the top of the page
 
+Quote Post
frankblourtango
post 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.
Go to the top of the page
 
+Quote Post
danbrownlow
post 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 =]
Go to the top of the page
 
+Quote Post
uhaligani
post 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?
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 3rd December 2008 - 03:48 PM


Advertise   |   About Us   |   Terms of Use   |   Privacy Policy   |   Contact Us   |   Site Map   |   Chat   |   Tutorials   |   Uninstall List
Discussion Forums   |   The Computer Glossary   |   Resources   |   RSS Feeds   |   Startups   |   The File Database   |   Malware Removal Guides

© 2003-2008 All Rights Reserved Bleeping Computer LLC.