How to detect windows startup and appdata folder from java?

To read the startup and appdata path I execute the following registry command and capture the foldername from the output:
reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Startup
The path contains the windows users name which may contain international character. The inputstream used to capture the path uses the
default encoding of the platform but it seems to get it wrong - international characters looks wrong and any subsequent use of the path
throws FileNotFoundException.
What is the right way to detect theese folders or is there a fix to my current folder detection shown below?
     private static final String RESULT_TOKEN_REGSZ = "REG_SZ";
          String value = null;
          Process process = Runtime.getRuntime().exec(windowsCommand);
          BufferedReader in = new BufferedReader(new InputStreamReader(process
                    .getInputStream()));
          String line = null;
          StringBuilder sb = new StringBuilder(250);
          while ((line = in.readLine()) != null) {
               sb.append(line);
          String capture = sb.toString();
          int pos = capture.indexOf(RESULT_TOKEN_REGSZ);
          if (pos != -1) {
               value = capture.substring(pos + RESULT_TOKEN_REGSZ.length()).trim();
          }

To answer my original post.
I found what I believe is a robust (although somewhat complex if you havent touched C code i more than 10 years like me) method to read the windows registry keys.
I call the following native windows unicode functions using the JNA api:
advapi32.RegOpenKeyExW
advapi32.RegQueryValueExW
Notice the W at the end - those functions encode character strings using wide character encoding UTF-16LE (Little Endian). Now nothing is "lost in translation"...
Wont post the kode here since it spans multiple srcfiles and is rather involved - but there are many good samples on the JNA site.

Similar Messages

  • How to change admin account and use folder from old account?

    Hi, I created a new admin account, and now I need to get all folders like Music, Documents, Video etc from old admin account. So, if I loged in as a new admin I see all folders with red sign in the coner and don't have permistion to see them or move. What are my options?
    I do have Time Machine backup from old admin account, but it also doesn't let me open folders from the new admin.

    Go back to the old account. Select one of the folders you moved to the Public folder and open the Info window. Click the lock icon and authenticate. Change the access permission for Everyone to Read. From the action menu (gear icon), select Apply to enclosed items. Repeat for each folder. Switch to the new account and try the copy again.

  • How to get the draft and sent folder in java mail

    i found the File Not Found error while accessing the draft,sent folder to fecth from the mail sever using IMAP. i m using the code like tis
    draft=store.getFolder("draft");
    sent=store.getFolder("sent");
    And i want to know whether the draft,sent,trash folder is default like inbox or not

    There are probably no folders with those names on your IMAP server.
    Unlike INBOX, there are no standard names for "draft" or "sent" folders,
    so you need to know exactly what name is used by the other email
    clients you're using.

  • How to detect window close event and do some task before exiting

    Hi 
    Anyone knows how to detect window close event and do some task before exiting ?
    Sridhar
    Solved!
    Go to Solution.
    Attachments:
    window close event.JPG ‏34 KB

    Yes .You can discard the panel close event by passing "TRUE" boolean value to the "discard ?" terminal which is lied in the right side of that panel close(filter) event.& It will work in executables.  See attached picture.
    Attachments:
    Panel Close.JPG ‏12 KB

  • How to hide windows heading and border on WEB?

    How to hide windows heading and border on WEB? forms 6i.
    null

    Abdetu wrote:
    Thanks JeanYves
    i found that parameter but didn't know what to set to it i even has no forms in my pc thanks again
    Regards,
    Abdetu...Hi Abdetu,
    There is 3 parameters in the <DevSuiteHome>\forms\server.formsweb.cfg having the same behavior.
    Logo
    Background
    SplashScreen
    By default (if you don't have specified them in you [section] they values are inherited from the [default] section) the values are
    Logo=
    Background=
    SplashScreen=
    This means you will have the oracle logo, the Forms Services background image in your applet and the oracle splash screen at startup.
    *To have nothing shown then just put the value no in front of these 3 parameters*
    Logo=no
    Background=no
    SplashScreen=noYou can also customize that with you own gif files.
    For this you have to put your images in a icons.jar file
    place it in your <DevSuiteHome>\forms\java where frmall.jar and others are located.
    then in your formsweb.cfg :
    Archive=frmall.jar, icons.jar
    ImageBase=CodeBase
    Logo=yourlogo.gif
    Background=yourbackground.gif
    SplashScreen=yourbeautifullsplachscreen.gifAnd at least if you have a small gif in your icons.jar for the window you can also defining the Icon Filename property in Forms builder. This wile replace the default forms runtime icon.
    Hope this helps
    JeanYves

  • How can i delete photos in a folder from my Iphone 4s.  when it was synced, the photos went to two folders and not to the camera roll

    How can I delter photos in a folder from my Iphone 4s?  When I synced the new phone from the Itunes, the photos went to two folders and not the camera roll. 

    thanks, should I delete all the phones on Itunes and re sync the old phone, then resync the new phone to get the pictures?  Will they go to camera roll instead of a folder?

  • How to lock a drive and/or folder if there is no lock icon in the get info field?, how to lock a drive and/or folder if there is no lock icon in the get info field?

    how to lock a drive and/or folder if there is no lock icon in the get info field?, how to lock a drive and/or folder if there is no lock icon in the get info field?

    You can create an encrypted disk image.
    http://www.macworld.com/article/1154559/password_protect_folders.html

  • How do I uninstall window 7 and Parallels 8  from my MBP?

    I fairly new to the Apple Mac and somewhat hesitance on what install and uninstall (moving to the trash).  On to the question How do I uninstall both window 7 and parallels 8 from my MBP?  I'm using OS X ML 10.8.2  The reason is I throught I had to use a window based only program for some personal work that I do, but I didn't have to after all.  The biggest reason is to free up disk space, I don't like program I don't use wasting space. 

    Let me get this clear - you're running Windows 7 under Parallels 8 and want to uninstall both?
    Pretty simple - http://kb.parallels.com/en/114624. And http://kb.parallels.com/en/5029.
    Good luck,
    Clinton

  • How do I remove an empty gmail folder from my iPad2?

    How do I remove an empty gmail folder from my iPad2?

    I Think that you had a corrupt email or an email with a really large attachment in that folder and it is now causing the mail app to crash. When the app closes and goes back to the home screen, that is an app crashing. I would try to delete this folder on the server. Log into your Gmail in a web browser and try to delete it there. If you delete it there, that will delete it on the iPad.

  • How do I delete photos and photo albums from my iPhone? The instructions given do not work. No "delete" symbol appears next to the album name, and no trash can icon appears below most of the pictures the computer just put on my new iPhone 4.

    How do I delete photos and photo albums from my iPhone 4? The instructions given do not work. No "delete" symbol appears next to the album name when I press "Edit," and no trash can icon for me to click appears below most of the individual photos in the albums the computer just loaded on my new iPhone 4. When I synced the new phone the computer added these photo albums without permission from me. They are now taking up about 3 GB of memory on my phone. I would like very much to get rid of these photos from the phone. How do I do this?

    To delete photos from your device
    In iTunes, select the device icon in the Devices list on the left. Click the Photos tab in the resulting window.
    Choose "Sync photos from."
    On a Mac, choose iPhoto or Aperture from the pop-up menu.
    On a Windows PC, choose Photoshop Album or Photoshop Elements from the pop-up menu.
    Choose "Selected albums" and deselect the albums or collections you want to delete.
    Click Apply.

  • How do i delete a contacts sub folder from my iphone?

    How do i delete a contacts sub folder from my iPhone?

    Hi, sure.
    Under "contacts" "Groups" I have the "All Contacts" option at the top, underneath that i have 3 empty subfolders that have come in from my PC Outlook program. I've deleted these from Outlook, shut Outlook down, shut iTunes down, re started both programs and re synced my iPhone4 and iPhone5. They are still on the iPhone 4, just given to my wife, but have disappeared from my iPhone 5!

  • How do I export wmv and avi files from media encoder on a mac in CC2014

    How do I export wmv and avi files from media encoder on a mac in CC2014?

    John T Smith wrote:
    As far as I know, you don't... those are Windows formats that are not available on a Mac
    Nonsense.
    Apple Compressor has been doing wmf exports for a decade. I have the Quicktime export components from Telestream and they appear as presets in Compressor. They should be available in Media Encoder or they should be importable. Adove apparently refuses to see them. Still trying to figure that out.

  • How can I compare a (partial) export folder from iPhoto to an event in iPhoto to find images not exported?

    How can I compare a (partial) export folder from iPhoto to an event in iPhoto to find images not exported?  Or better yet, how can I export selected events to a new iPhoto library or an existing iPhoto library with events, titles and keywords intact?

    Ask here:
    https://discussions.apple.com/community/ilife/iphoto

  • How to save my emails and adressbook files from an old ibook?

    How to save my emails and adressbook files from an old ibook (bought around 2002) ?
    The screen from the old ibook doesn´t work anymore (logicboard problem I guess).
    I saved everything else with starting it in target modus. That worked fine.
    I want to delete the files after that as well, because I wanna give away the old ibook and don´t want anyone to read my emails!
    Little helpers I have:
    A running MacBook
    External Screen (and cables to connect)
    Fire Wire Cable

    Don't know how helpful this will be but I often copy mail from one computer to another, I drag the mail from the mail window to the other computers drop box, then from the other computer double click it and mail asks me what I want to do with it, of course without a screen you'd need to use back to my mac.
    If you don't have back to my mac running, you could set up a second user account on the newer mac, import everything via target mode as suggested by c above, and then drag the mail to the first user account drop box.

  • HT204053 how do i move page and numbers documents from one icloud login to another?

    how do i move page and numbers documents from one icloud login to another?
    I had to change my email address whcih meant new apple login.
    I have a number of docs in iwork/pages and iwork/numbers.  How do I transfer them to my new login?

    There's a couple of ways but my tip backing up your documents in the cloud is as good as any.

Maybe you are looking for