Help with copying files into the the Start Menu

I am trying to copy my application which tracks system usage, such as reboots, temps, etc, I want it when it first runs, to copy it self into the the programs folder and the start up folder. However I get the error ""FileCopy: destination file is unwriteable: ""......Anyone have an idea why I get this error? Is there away around it? Thanks for any and all help
*Copying on a Mac works fine
*I am currently Testing it on a copy of Windows Xp
*I havenot Tested Vista or 7 Yet.
Hers the class which I call to copy my program
class FileCopy {
     String OS="";
     String username;
     String dir;
     String name="Test.jar";
     String MAC="Mac OS X";
     String WinXp="Windows XP";
     String WinVista="Windows Vista";
     String Win7="Windows 7";
     JFrame errorWin;
     FileCopy(){
          System.out.println("Enter Copy");
          OS= ManagementFactory.getOperatingSystemMXBean().getName();
          username = System.getProperty("user.name"); 
          if(MAC.compareTo(OS)==0){
               copyMac();
          else if(WinXp.compareTo(OS)==0){
               copyWinXp();
          else if(WinVista.compareTo(OS)==0){
               copyWinVista();
          else if(Win7.compareTo(OS)==0){
               copyWin7();
          else
               return;
     private void copyMac(){          
          System.out.println("Enter Mac Copy");
          System.out.println("OS:"+OS);
          String s="/Applications/Solitaire.Jar";
          try {
               copy(name, s);
          } catch (IOException e) {
               System.out.println("Failed at Mac Copy new");
               errorWin=new JFrame("Error: Failed at Mac Copy new ");
               e.printStackTrace();
          } //Moves Jar File to Application Folder
     private void copyWin7(){
          String dir1="C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\SolitaireWin7.Jar";
          String dir2="C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\SolitaireWin7.Jar";
          try {
               copy(name, dir1);
          } catch (IOException e) {
               System.out.println("Failed at Win7 Copy 1");
               errorWin=new JFrame("Failed at Win7 Copy 1");
               e.printStackTrace();
          } //Moves Jar File to Application Folder
          try {
               copy(name, dir2);
          } catch (IOException e) {
               System.out.println("Failed at Win7 Copy 2");
               errorWin=new JFrame("Failed at Win7 Copy 2");
               e.printStackTrace();
          } //Moves Jar File to Application Folder     
     private void copyWinVista(){
          String dir1="C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\SolitaireVista.Jar";
          String dir2="C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\SolitaireVista.Jar";
          try {
               copy(name, dir1);
          } catch (IOException e) {
               errorWin=new JFrame("Failed at Winista Copy 1");
               System.out.println("Failed at WinVista Copy 1");
               e.printStackTrace();
          } //Moves Jar File to Application Folder
          try {
               copy(name, dir2);
          } catch (IOException e) {
               errorWin=new JFrame("Failed at WinVista Copy 2");
               System.out.println("Failed at WinVista Copy 2");
               e.printStackTrace();
          } //Moves Jar File to Application Folder     
     private void copyWinXp(){
          String dir1="C:\\Documents and Settings\\"+username+"\\Start Menu\\Programs\\Solitaire.Jar";
          String dir2="C:\\Documents and Settings\\"+username+"\\Start Menu\\Programs\\Startup\\Solitaire.Jar";
          try {
               copy(name, dir1);
          } catch (IOException e) {
               errorWin=new JFrame("Failed at WinXp Copy 1");
               errorWin.setVisible(true);
               errorWin.repaint();
               System.out.println("Failed at WinXP Copy 1");
               e.printStackTrace();
          } //Moves Jar File to Application Folder
          try {
               copy(name, dir2);
          } catch (IOException e) {
               errorWin=new JFrame("Failed at WinXp Copy 2");
               errorWin.setVisible(true);
               errorWin.repaint();
               System.out.println("Failed at WinXP Copy 2");
               e.printStackTrace();
          } //Moves Jar File to Application Folder     
     public void copy(String fromFileName, String toFileName) throws IOException {
       File fromFile = new File(fromFileName);
       File toFile = new File(toFileName);
       if (!fromFile.exists()){
            errorWin=new JFrame("FileCopy: " + "no such source file: "  + fromFileName);
               errorWin.setVisible(true);
               errorWin.repaint();
         throw new IOException("FileCopy: " + "no such source file: "  + fromFileName);
       if (!fromFile.isFile()){
            errorWin=new JFrame("FileCopy: " + "can't copy directory: "
                       + fromFileName);
               errorWin.setVisible(true);
               errorWin.repaint();
         throw new IOException("FileCopy: " + "can't copy directory: "
             + fromFileName);
       if (!fromFile.canRead()){
            errorWin=new JFrame("FileCopy: " + "source file is unreadable: "
                       + fromFileName);
               errorWin.setVisible(true);
               errorWin.repaint();
         throw new IOException("FileCopy: " + "source file is unreadable: "
             + fromFileName);
       if (toFile.isDirectory())
         toFile = new File(toFile, fromFile.getName());
       if (toFile.exists()) {
         if (!toFile.canWrite()){
              errorWin=new JFrame("FileCopy: destination file is unwriteable: " + toFileName);
               errorWin.setVisible(true);
               errorWin.repaint();
           throw new IOException("FileCopy: destination file is unwriteable: " + toFileName);
         System.out.print("Overwrite existing file " + toFile.getName()
             + "? (Y/N): ");
         System.out.flush();
         BufferedReader in = new BufferedReader(new InputStreamReader(
             System.in));
         String response = in.readLine();
         if (!response.equals("Y") && !response.equals("y")){
              errorWin=new JFrame("FileCopy: existing file was not overwritten.");
               errorWin.setVisible(true);
               errorWin.repaint();
              throw new IOException("FileCopy: existing file was not overwritten.");
       } else {
         String parent = toFile.getParent();
         if (parent == null)
           parent = System.getProperty("user.dir");
         File dir = new File(parent);
         if (!dir.exists()){
              errorWin=new JFrame("FileCopy: destination directory doesn't exist: " + parent);
               errorWin.setVisible(true);
               errorWin.repaint();
           throw new IOException("FileCopy: destination directory doesn't exist: " + parent);
         if (dir.isFile()){
              errorWin=new JFrame("FileCopy: destination is not a directory: " + parent);
               errorWin.setVisible(true);
               errorWin.repaint();
           throw new IOException("FileCopy: destination is not a directory: " + parent);
         if (!dir.canWrite()){
              errorWin=new JFrame("FileCopy: destination directory is unwriteable: " + parent);
               errorWin.setVisible(true);
               errorWin.repaint();
           throw new IOException("FileCopy: destination directory is unwriteable: " + parent);
       FileInputStream from = null;
       FileOutputStream to = null;
       try {
         from = new FileInputStream(fromFile);
         to = new FileOutputStream(toFile);
         byte[] buffer = new byte[4096];
         int bytesRead;
         while ((bytesRead = from.read(buffer)) != -1)
           to.write(buffer, 0, bytesRead); // write
       } finally {
         if (from != null)
           try {
             from.close();
           } catch (IOException e) {
         if (to != null)
           try {
             to.close();
           } catch (IOException e) {
}

That's clearly a security restriction then. You need to assign the JVM's user account enough rights to do so, or to configure any firewall/virusscanner which has possibly blocked it.
Apart from this, are you aware of the fact that the OS root disk is not per se labeled "C:", that the location of documents is not per se "Documents and Settings", that there exist System#getenv() and System#getProperty() methods to find default system and environment variables and that there is the java.util.prefs API to access the registry? Your application is likely not going to run on any environment.

Similar Messages

  • Help with importing files into elements catalog?

    I recently downloaded HD home video's to my computer and when I open Pre elements 9.0 it gives me the message saying new files have been downloaded since last launch of elements organizer. Elements will now import these files into a catalog. it starts and listed the mov file but is stuck and will not respond.
    Any idea's?

    jsguild
    What is the format of these HD home video's that you are trying to import into Elements Organizer 9?
    Try importing one of them into a Premiere Elements 9.0/9.0.1 new project and determining if a copy of the video gets automatically placed in Elements Organizer 9.
    More later.
    ATR

  • I need help with copying files in java?

    hi, i use the following code sample to copy a directory structure and its files.
    It copy's the directory-structure, but all the files in it have 0kb as size. except one file.
    Here's the code:
    public static void copyDir(String source, String target)
    String [] listing = new String [0];
    FileReader in = null;
    FileWriter out = null;
    String sourcePath = source;
    String targetPath = target;
    // Maakt directory onder target directory
    File f = new File(targetPath);
    f.mkdir();
    // Maakt filelist van bestanden in source-directory
    f = new File(sourcePath);
    listing = f.list();
    for(int i = 0; i < listing.length; i++)
    f = new File(sourcePath + listing);
    if(f.isDirectory())
    copyDir(source + listing[i] + File.separatorChar,
    target + listing[i] + File.separatorChar);
    else
    try
    in = new FileReader(sourcePath + listing[i]);
    out = new FileWriter(targetPath + listing[i]);
    int t;
    while (-1 != (t = in.read()))
    out.write(t);
    try { Thread.sleep(200); } catch (InterruptedException e) { }
    System.out.println("Copied: " + sourcePath + listing[i]);
    catch (Exception e)
    System.out.println(e);

    Here is a quick copy program that works. You'll need to deal with the exception instead of just throwing it though.
    import java.io.*;
    public class Copy
      private static void copy(String source, String target) throws IOException
        // Create directory
        File file=new File(target);
        file.mkdirs();
        // Get contents
        file=new File(source);
        File[] files=file.listFiles();
        // Copy files
        int length;
        byte[] buffer=new byte[1024];
        for(int i=0; i<files.length; i++)
          String destination=target+File.separator+files[ i ].getName();
          if(files[ i ].isDirectory())
            copy(files[ i ].getPath(), destination);
          else
            FileInputStream in=new FileInputStream(files[ i ]);
            FileOutputStream out=new FileOutputStream(destination);
            while((length=in.read(buffer))!=-1)
              out.write(buffer, 0, length);
            in.close();
            out.close();
      public static void main(String[] args) throws IOException
        copy(args[0], args[1]);
    }[\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Help with importing files into Lightroom 3.2

    Nothing has changed on my Mac for a year, except installing Lightroom 3 two months ago. I have had no issues importing till yesterday. Imported 300 .CR2 files, installed another card into my card reader and it will not import the files from the same camera, same shoot, done same day.
    I have tried to copy the files over to my hard drive and import from there. Failed again.
    I can open the files in Camera RAW and convert them to PSD files on a different drive and they still will not import from there.
    Any suggestions out there/
    I am begging to hate LR3 more and more and more every day.

    Copy the files from your card reader or camera to your Mac then import the files into Lr. You can configure Lr to import where to a new location or leave them were they are.

  • Help With Transferring Files into iTunes Music Folder

    Last year, my computer crashed and I had no backup. I used a program called Sharepod to import all my music from my iPod onto my new computer. Now, all that tranferred music resides in C:\Program Files\Sharepod.
    The songs play just fine out of iTunes, but because I'm a little OCD I'd really like them to be in the iTunes Music folder where they belong. But I've found that when I drag the songs from the Sharepod folder to the iTunes Music folder, I then have to help iTunes "locate" each song one by one. It's very tedious.
    Is there a better way to do this?
    Many thanks!
    Message was edited by: kidsmoke

    Yes. Once songs are in your iTunes library, do not move or rename them in Windows. If you want to get them all in one place, use the iTunes Consolidate command.

  • Need help with java File IO ( Removing the first line from a file )

    Hi guys ,
    I am currently doing a project in which I need to extract out the values from the second line of a file to the end. The question is how do I ignore the first line ??
    I thought of two possible answers myself. One is to use randomaccessfile to read and rewrite. But the file may be HUGE so storing the whole file in memory is not a very good idea.
    Second is to jump to second line before doing while ((str = in.readLine()) != EOL) ... or just delete the first line from the file. Can anyone suggest a better solution or show me some sample codes ? Thanks.
    regards
    billyam

    Just skip the first line (bufferedReader.readLine()), add a comment, and then handle the rest of your file

  • Need help with moving files into Itunes and syncing

    Please help.
    I have an external hard drive with my music on it.  I created a new playlist in Itunes and did a drag and drop from my external hard drive into my newly created playlist. 
    Now that I go back and play the items I brought over, I get an error that says "original files not found" and it won't play and therefore does not seem to be syncing to the Ipod to be able to play.
    Can you please give me guidance as to what I can do without recreating all the work I had already done?
    Thanks,
    Michelle

    Is the external drive connected?
    Has the drive letter possibly changed due to being disconnected and reconnected?

  • Need help with copying files onto external drive

    I need help! Trying to copy downloaded movie files from Vuze (which have downloaded successfully) and copy onto external hard drive to view them but it wont let me copy over to the external device. Any ideas how to fix this please???

    Can you explain the steps you used, and the error message (or symptom), that says the copy did not work? 

  • HT1449 Help! This all runs quite smoothly until i get to 'consolidate library'. Then, tracks start copying, then stop followed by a pop up saying 'Copying files failed. The disc could not be read from or written to.'  Any suggestions? Thank you!

    Help! This all runs quite smoothly until I get to 'consolidate library'. Then, tracks start copying, then stop followed by a pop up saying 'Copying files failed. The disc could not be read from or written to.'  Any suggestions? Thank you!

    I had similar problems, it was a nightmare and on a 3 month ipod too!. I use a Powerbook G4 at home and a G5 at work - both were returning the same problems. so I sent it off to apple, they quickly sent it back saying there was nothing wrong with and it didn't need to be repaired. I tried it again and the same problems occurred "disc cannot be written to or read from." I could copy 20 songs onto it at the very most. A couple of guys at my work suggested updating it on a PC, then adding tunes via my mac as normal - guess what!? it works a treat!?. How ridiculous is that!? an Apple product works best on a PC. these generations of ipods are obviously designed to work best on Intel based Macs. What is wrong Apple? are you abandoning the G-generation!? still, atleast my ipod works for now - it will prove a problem when I have to update the iPod's software since I don't own a PC or an intel-based Mac.

  • HT1751 Consolidating ITunes Library Failed - message received: "Copying files failed. The file name was invalid or too long" . Please help - how to i fix this issue?

    I consulted your website for details on how to back up my ITunes Library on my PC-found the article very helpful-I reached step 7 - clicked ok and the following message came up: "Copying files failed. The file name was invalid or too long."  Please can you help and advise what I should do or how to fix this issue.   My pc operating system is Windows 7 Home Basic

    You can select a group of tracks and consolidate from the right-click context menu. You coud try consolidating in batches, say all songs by artists beginning with A, then B, etc, then the other media types, until you can isolate a problem track and then try moving that by hand and fixing the broken link.
    I also have two scripts that could help you, Unconsolidated and ConsolidateByMoving. The first can make a playlist of all unconsolidated tracks, the second can consolidate a selection of tracks by moving them instead of copying.
    tt2

  • When trying to 'Consolidate Files' via iTunes I get the message "Copying files failed. The name was invalid or too long."

    I am trying to copy my entire iTunes library and everything in it from my PC Desktop to my PC Laptop using the "External Drive" method as shown on the Apple website. On Part 1 (5) I am told to consolidate files. When attempting to do this I get the message "Copying files failed. The file name was invalid or too long."
    How do I resolve this?

    I have just been having this problem and it has been driving me mad.   The error message doesn't tell you which file is causing the problem so you can't fix it and it leaves your libray in a state of limbo with some files copied into the new location and some in the old location.  After many hours I found a surprisingly quick and simple solution.
    1) in iTune create a smart play list that includes everything that was added before tomorrows date.  This will include everything.
    2) Right click this playlist and export it as a text file to produce a tab delimited file.
    3) Import this into a spread sheet, or just view it in a text editor with line wrap turned off.  What you are interested in is the last column (or end of the line in a text editor).  This gives you the path of the file associated with each entry in the library. 
    The path of the files that have already been copied successfully will start with the new location for your media files you specified.  Scroll thru the rows until you get a blank path.  If you start getting paths starting with the old Media file location then you went to far and start scrolling back.
    The row with the blank path was the file that failed.  Move back to the start of the row to find out more about it.  In my case it was a podcast with a very long name. I just deleted that podcast from iTunes.
    4) Restart the consolidation by choosing File, Library as you did before and the process starts again where it left off.
    5) If it fails again on another file just repeat the process

  • Consolidate Problem. Copying files failed. The File name was invalid.

    Hi to everyone,
    My system is 10.5.8, iTunes 9.2.1 (4)
    I tried to consolidate my iTunes library to an external HD. After about 100GB of copied music, I got the message : Copying files failed. The File name was invalid.
    Now everytime I try again to consolidate, I get immediately this message. I am looking everywhere for a solution, and I only find the same problem for Windows iTunes users.
    Actually I found very useful this thread:
    http://discussions.apple.com/thread.jspa?threadID=1708372,
    which talks about with which order iTunes consolidates the media, so by digging a little in the folders to find which track has the problem and make the fix. It says that consolidate start copy the files by the date added order. So I can go in my new iTunes media folder and find the latest added track, then go back in iTunes, sort by date added the songs and locate the next song, to make the fix. However in my case, all previous and next songs (by date added), have been copied in the new locations.
    I am stuck. I have a remaining 300GB of music to consolidate and dont know how to proceed.
    Any help would be much appreciated..

    Finaly, I managed to solve it by myself...,
    following the help I found from the post of the thread I mentioned on my question...
    What was the problem that made things more difficult in my case, is that a big amount of songs have been added at the same time, with just a few seconds time distance. So it was tougher to locate what was the last imported song, and where iTunes consolidation had stopped. Actually I had groups of about 100 songs with the same timestamp of date added and the consolidation was following the rule of the "date added" but not exactly with the order the songs was showing in the iTuned library. So I started checking all the songs very close to the last added in the media folder one by one with the "show in finder" command, and then I managed to found what was the one with the problem.
    Regarding the problematic file, that was a midi file that had been imported in my iTunes.
    I hope this will help anyone else that might have the same problem as me in the future.

  • Need some help with downloading PDF's from the net.

    need some help with downloading PDF's from the net.  Each time I try to click on a link from a website, if it takes me to a new screen to view a pdf, it just comes up as a blank black screen?  any suggestions?

    Back up all data.
    Triple-click the line of text below to select it, the copy the selected text to the Clipboard (command-C):
    /Library/Internet Plug-ins
    In the Finder, select
    Go ▹ Go to Folder
    from the menu bar, or press the key combination shift-command-G. Paste into the text box that opens (command-V), then press return.
    From the folder that opens, remove any items that have the letters “PDF” in the name. You may be prompted for your login password. Then quit and relaunch Safari, and test.
    The "Silverlight" web plugin distributed by Microsoft can also interfere with PDF display in Safari, so you may need to remove it as well, if it's present.
    If you still have the issue, repeat with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari again.

  • Permission Error when copy files into cmsdk using NFS with non admin user

    Hi All,
    We are using CMSDK with NFS protocol and we have created different users with ACL to control different access for users.
    When we copy files into cmsdk folders using one of the admin user this works fine, even a multiple copy works fine. But when we use any non admin user , some time copy commands works but some time it throw a permission deny error. and this is happening very intermittently.
    when we use ftp protocol and ftp file it's all works fine for the both admin & non admin user. Is there any limitation in using CMSDK NFS protocol
    Did any one encouter any similar issue. Any pointers would be of great help.
    Thanks in advance
    Regards,
    Navin

    Hi All,
    We are using CMSDK with NFS protocol and we have created different users with ACL to control different access for users.
    When we copy files into cmsdk folders using one of the admin user this works fine, even a multiple copy works fine. But when we use any non admin user , some time copy commands works but some time it throw a permission deny error. and this is happening very intermittently.
    when we use ftp protocol and ftp file it's all works fine for the both admin & non admin user. Is there any limitation in using CMSDK NFS protocol
    Did any one encouter any similar issue. Any pointers would be of great help.
    Thanks in advance
    Regards,
    Navin

  • ITunes v10.6.1.7 "Copying files failed. The File name was invalid or too long."

    I'm trying to organize my music files using iTunes 10.6.1.7 and I keep getting the error message "Copying files failed. The File name was invalid or too long."
    I've got music folders by artist in both the iTunes Music folder and the iTunes Media/Music folder. When I add certain files by drag/drop they sometimes get lost and I don't want that to happen anymore. I used to just consolidate my music files using the File/Library/Organize Library option and that worked, however now when I do that, I get the error message.
    I'm a novice and the only online stuff I see is both confusing and refers to earlier versions of iTunes.
    My concern is that I have heard that people lose entire libraries of their music when they trry to fix things like this and I don't want that. If this is of any importance, I have several files called iTunes library and temp library. I have no idea what that all means but I'm scared to death of it.
    Also, I can't get to the "re-organize library" link at all. It won't let me.
    One thing that be of some interest is that when I pull up the properties of the music and media/music files they are marked "read only" I'm also afraid to touch that!
    Please help and please know that I am a dummy. Be kind and be clear. Step by step would be great, with images even better. Thanks.

    Perhaps nobody knows the answer? We're fellow users here answering questions in our free time when we think we've something useful to contribute.
    You can choose to *Consolidate selected tracks* with a right-click menu. Perhaps if you can identify a specific track that won't consolidate and examine the full path to the file & the path that iTunes would create when it consolidates the problem might become apparent. For example iTunes may not be able to move files if the source or destination path length exceeds 255 characters.
    tt2

Maybe you are looking for

  • Heirarchical Trees

    Developer 6.0.5.0.2 Forms Windows NT4 Service Pack4 ORACLE 8.0.5 on sun solaris server I am attempting to build a tree via a record group. The property sheet for the tree asks for a record group. What structure does the record group (or query that cr

  • HT5554 I am getting searching for sim card even though sim card is inside

    I am getting message searching for network even though sim card is inside

  • Support for more than one hierarchy

    Is it possible to include more than one hierarchy in a Crystal Report? I have tried and am getting some unexpected results. I have two groups, each with it's own hierarchy. When I run the report, the top level hierarchy is returning "extra" summary n

  • Oracle Incentives, Different plans applicable for the same invoice

    Dear Oracle incentive exports, I need to know how we can apply 2 plans for the same invoice? Suppose we have ONE plan that says 2% from $0-$750,000 and 4% from $750,000 to $1,000,000. If the sales is $800.000 the 2% will be applied for the 1st 750.00

  • Is usage of Proxy nodes expensive ?

    Hi, I would like to know how expensive is the usage of proxy node from performance point of view. Thanks Girish