Results 1 to 19 of 19
  1. #1
    space889 is offline Member
    Join Date
    Jul 2010
    Posts
    4
    Rep Power
    0

    Default How to test if server is running Windows 7?

    Hi, we have application that tests if a server is Windows 7. We currently do it by seeing if the following directory exists or not using the command below:
    File f = new File(String.format("\\\\%s\\C$\\windows\\system32\ \tasks", hostName));

    However, whenever this line runs, we get an exception saying the file can't be found. The file however can be accessed through Windows Explorer using command \\hostName\C$\windows\system32\tasks\

    We all have local admin rights on the Windows 7 server machine as well.

    So I'm wondering if there is a way to fix this issue or is there a better way to see if the server is running Windows 7 or not?

    thanks!

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default

    Have you looked at System Properties: os.name

  3. #3
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    Norm is right.

    You can simply watch your system with System.properties method

    I recommend reading this Listing All System Properties | Example Depot
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,679
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Webuser View Post
    Norm is right.
    No he's not; the OP wants to check a directory/file on another host by supplying an UNC name to the File class (which should work). My first action would be to print out and check the resulting UNC name.

    kind regards,

    Jos

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default

    What's a UNC name?

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,679
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Norm View Post
    What's a UNC name?
    It's an acronym for 'Universal Naming Convention', a Microsoft invention, also used by Samba; it uses a host name, a partition name and a file path separated by several backslashes here and there ;-) Google knows the details.

    kind regards,

    Jos

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default

    Thanks.
    My google came up with lots of University of North Carolina stuff.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default

    Also I didn't know that you could access a server using the File class.
    What kind of server is that?

  9. #9
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,679
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Norm View Post
    Also I didn't know that you could access a server using the File class.
    What kind of server is that?
    The server and the client have to run MS Windows (or have a Samba enabled filing system) and the particular 'partition' has to be shareable. UNC names can address the file(s) on the server through ordinary filing system calls then.

    kind regards,

    Jos

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default

    So the connection is via some MS software. Is there any need for there to be a server on any of the PCs?
    Last edited by Norm; 07-18-2010 at 10:21 PM.

  11. #11
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,679
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Norm View Post
    So the connection is via some MS software. Is there any need for there to be a server on any of the PCs?
    Nope, not for UNC name resolution; shares are a MS thing that broadcast hosts all over the network, each machine is periodically yelling. Every other machine can use the shared partitions from that other host. The OP wants to (ab)use that feature to check whether or not a particular server runs on an MS Windows (7) machine.

    kind regards,

    Jos

  12. #12
    space889 is offline Member
    Join Date
    Jul 2010
    Posts
    4
    Rep Power
    0

    Default

    Hi, thanks for the reply.

    JosAh you are right, we are trying to abuse this particular feature to find out if the server is Windows 7 or not.

    The complete URN string is \\v-server-01\C$\windows\system32\tasks\

    I think it's becaues of the C$ that MS Windows don't like. We can access it via Windows Explorer but not from Java File object. Might be some MS Windows security related?

    As for testing os.name, how would I do that for a remote server?

    thanks.

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default

    What type of server is it? What protocols does it support that you could use to ask it questions?

  14. #14
    space889 is offline Member
    Join Date
    Jul 2010
    Posts
    4
    Rep Power
    0

    Default

    It's a Windows 7 server machine. I'm not sure what kind of protocol you are referring to?

  15. #15
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default

    How do you use a server if there is no protocol for communicating with it?
    Sample protocols: HTTP, FTP, SMTP

    Can this server live outside of a MS environment?

    How does java programming come into use here?

  16. #16
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,679
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by space889 View Post
    The complete URN string is \\v-server-01\C$\windows\system32\tasks\

    I think it's becaues of the C$ that MS Windows don't like. We can access it via Windows Explorer but not from Java File object. Might be some MS Windows security related?
    Got it: remove that $ sign, i.e. make that file name "\\\\v-server-01\\C\\windows\\system32\\tasks"

    Stupid UNC names ...

    kind regards,

    Jos

  17. #17
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,120
    Rep Power
    20

    Default

    Quote Originally Posted by JosAH View Post
    Stupid UNC names ...
    Am I the only one to have read that in a Homer Simpson voice?
    :)

  18. #18
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,679
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Tolls View Post
    Am I the only one to have read that in a Homer Simpson voice?
    :)
    Nope, I was first ;-)

    kind regards,

    Jos

  19. #19
    space889 is offline Member
    Join Date
    Jul 2010
    Posts
    4
    Rep Power
    0

    Default

    Hi, thanks for the replies.

    I found the problem yesterday which is that I need to give myself full access rights to the folder in question. I was told by network that we (the programmers) have full admin rights on the server but apparently we don't and that's what is causing the Java program to fail. Once I gave myself full control to the folder, the File object can access the directory properly using the \\server\C$\... notation. The Java exception path not found was throwing me off a bit as well.

    thanks for all the replies and help.

Similar Threads

  1. running java under Windows 7
    By newbie123 in forum New To Java
    Replies: 3
    Last Post: 05-29-2010, 09:36 PM
  2. Errors running app in linux but not in Windows
    By JohnST in forum New To Java
    Replies: 3
    Last Post: 03-12-2010, 02:58 AM
  3. how to keep server running
    By Harris68 in forum Networking
    Replies: 4
    Last Post: 12-22-2009, 11:11 AM
  4. [SOLVED] TCP chat test availability server
    By Koren3 in forum New To Java
    Replies: 16
    Last Post: 05-02-2009, 01:55 PM
  5. Replies: 0
    Last Post: 09-18-2008, 06:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •