• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unable to mount in windows 7 through Java

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am using windows 7. If I run following command from command prompt

It mounts the network drive /d/jaibhim on my z: drive.

I want to achieve same result through Java. So I wrote following piece of code-


I get following error from the error stream- "'C:\Windows\System32\mount.exe' is not recognized as an internal or external command,"

Could you please guide me, where I am going wrong?


Thanks,
jaibhim
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure it's mount and not mountvol
 
jaibhim max
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Maneesh,

its mount not mountvol.

mount.exe is present under C:\Windows\system32


Thanks,
jaibhim
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My installation of Windows 7 does not recognize mount. It does recognize mountvol, though. I'd tend to believe Maneesh is right and your system is somewhat crooked; you should start using mountvol perhaps.

The error message you're getting might mean that the cmd.exe executed from Java does not have necessary permissions to run C:\Windows\System32\mount.exe (assuming it does exist at that location, as you report). Aren't you running the console as an Administrator when you're trying that from command line?
 
jaibhim max
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I got the solution from my friend...It should look like as -



 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That looks odd. Yes, the entire mount command should be one argument - it's one of two arguments (the other /C) to cmd.exe. It's the first /C and the other cmd.exe I find odd. I think the following should be enough:
 
Martin Vashko
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think there is any problem with parceling the arguments one way or the other. At the end the arguments in the array get concatenated together with space as a separator under Windows (or so I believe - Windows does not have that sophisticated shell interface as Unix).

However, the need to use sysnative looks highly suspicious. This is a way for a 32bit application to access 64bit version of the system32 directory, which is otherwise unavailable due to redirection. It also means that there is only 64bit version of mount.exe on the system, otherwise this would not be needed and the 32bit application would call mount.exe from 32bit version of system32 directory. This need not be a problem, if the application is to never be run on another system, but if the plans are to use it on other computers, it can run into a new problems of its own. Also, I believe that if run using 64bit JRE, it would fail, as sysnative is not recognized by 64bit apps (see this).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic