Can you read a text file in a JAR file with VBS?

Author Message
cprowse

  • Total Posts : 5
  • Scores: 0
  • Reward points : 0
  • Joined: 12/13/2011
  • Location: London, UK
  • Status: offline
Can you read a text file in a JAR file with VBS? Tuesday, December 13, 2011 9:18 PM (permalink)
0
Hi all - I've used this forum loads, but this is my first post - I can't find the answer anywhere...
 
I'm using an "interesting" enterprise application, and need to check which version of the local client a user is running - unfortunately the only way to do this is to read a file within a jar on the local machine. I've written a script to do this by simply extracting the file I want to a temp folder using "myShell.Run chr(34) & "jar.exe" & chr(34) & " -xf " & chr(34) & "C:\myjar.jar" & chr(34) & " " & "test.txt", 1, True" and checking it, which works fine on my machine...
 
But of course, the client machines don't have java installed. They also don't have any standard unzipping tools available so I can't crack open the JAR. And I'm not allowed to install anything on the machines (we don't manage them, some are desktops, some are laptops).
 
So my question is - can I read a file inside of the JAR using VBScript, without unzipping or extracting the JAR first?
 
Fingers crossed,
-Chris
 
#1
    ebgreen

    • Total Posts : 8219
    • Scores: 98
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: offline
    Re:Can you read a text file in a JAR file with VBS? Wednesday, December 14, 2011 3:10 AM (permalink)
    0
    Why not just copy it from their machine to yours then do what works locally?
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      cprowse

      • Total Posts : 5
      • Scores: 0
      • Reward points : 0
      • Joined: 12/13/2011
      • Location: London, UK
      • Status: offline
      Re:Can you read a text file in a JAR file with VBS? Wednesday, December 14, 2011 3:18 AM (permalink)
      0
      Good point - this worked for some of the earlier items, but the script I'm putting together now needs to run on the client before they log in (essentially checking they have the right version before giving them a login prompt). Therefore the magic has to happen on their machine :(
       
      -Chris
       
      #3
        ebgreen

        • Total Posts : 8219
        • Scores: 98
        • Reward points : 0
        • Joined: 7/12/2005
        • Status: offline
        Re:Can you read a text file in a JAR file with VBS? Wednesday, December 14, 2011 3:43 AM (permalink)
        0
        If they do not have JAVA installed (which begs the question what exactly they are going to do with the JAR), then you are sort of SOL. The JAR file encoding is well known so I suppose that you could write your own code to decode it.
        "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
        Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
        http://www.visualbasicscript.com/m_47117/tm.htm
         
        #4
          cprowse

          • Total Posts : 5
          • Scores: 0
          • Reward points : 0
          • Joined: 12/13/2011
          • Location: London, UK
          • Status: offline
          Re:Can you read a text file in a JAR file with VBS? Wednesday, December 14, 2011 4:02 AM (permalink)
          0
          The client ships with it's own cut down (but extremely customised, non-standard, horrible and weird) JRE that allows the executable JAR to run - but doesn't allow me to do anything useful.
          I thought rolling my own might be the answer, but was hoping I'd missed something obvious.
           
          Thanks for your quick responses,
          -Chris
           
          #5
            ebgreen

            • Total Posts : 8219
            • Scores: 98
            • Reward points : 0
            • Joined: 7/12/2005
            • Status: offline
            Re:Can you read a text file in a JAR file with VBS? Wednesday, December 14, 2011 4:06 AM (permalink)
            0
            Snoop around on google first, but I have never run across VBS for decoding JARs before.
            "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
            Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
            http://www.visualbasicscript.com/m_47117/tm.htm
             
            #6
              TNO

              • Total Posts : 2094
              • Scores: 36
              • Reward points : 0
              • Joined: 12/18/2004
              • Location: Earth
              • Status: offline
              Re:Can you read a text file in a JAR file with VBS? Wednesday, December 14, 2011 5:36 AM (permalink)
              0
              cprowse


              ...

              But of course, the client machines don't have java installed. They also don't have any standard unzipping tools available so I can't crack open the JAR. And I'm not allowed to install anything on the machines (we don't manage them, some are desktops, some are laptops).

              So my question is - can I read a file inside of the JAR using VBScript, without unzipping or extracting the JAR first?


               
              Are these machines older than WinXP? If not, then the native unzip command can be used.
               
              Otherwise, the only solution I can see is to implement a complete VBScript unzipping solution.  I may have something laying around in JScript...
              To iterate is human, to recurse divine. -- L. Peter Deutsch
               
              #7
                ehvbs

                • Total Posts : 3320
                • Scores: 112
                • Reward points : 0
                • Joined: 6/22/2005
                • Location: Germany
                • Status: offline
                Re:Can you read a text file in a JAR file with VBS? Wednesday, December 14, 2011 6:03 AM (permalink)
                0
                Can't you use an indirect indication for the software's version - size, date, or checksum of the .jar?
                 
                #8
                  ebgreen

                  • Total Posts : 8219
                  • Scores: 98
                  • Reward points : 0
                  • Joined: 7/12/2005
                  • Status: offline
                  Re:Can you read a text file in a JAR file with VBS? Wednesday, December 14, 2011 6:05 AM (permalink)
                  0
                  Ooh...if nothing else in the JAR was changing then something like an MD5 would be a great idea Ehvbs.
                  "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
                  Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
                  http://www.visualbasicscript.com/m_47117/tm.htm
                   
                  #9
                    59cobalt

                    • Total Posts : 969
                    • Scores: 91
                    • Reward points : 0
                    • Joined: 7/17/2011
                    • Status: offline
                    Re:Can you read a text file in a JAR file with VBS? Wednesday, December 14, 2011 8:57 AM (permalink)
                    0
                    Something like this won't work?
                    JarFile jarfile = new JarFile("\\PATH\\TO\\foo.jar");
                    System.out.println(jarfile.getManifest().getMainAttributes().getValue("Manifest-Version"));

                     
                    #10
                      cprowse

                      • Total Posts : 5
                      • Scores: 0
                      • Reward points : 0
                      • Joined: 12/13/2011
                      • Location: London, UK
                      • Status: offline
                      Re:Can you read a text file in a JAR file with VBS? Wednesday, December 14, 2011 8:34 PM (permalink)
                      0
                      Thanks all - can't believe I didn't think about the checksum, that will be helpful. Had hoped to do something along the lines of the "get manifest file" in the last post - but not sure how to do it in VBScript?
                       
                      #11
                        59cobalt

                        • Total Posts : 969
                        • Scores: 91
                        • Reward points : 0
                        • Joined: 7/17/2011
                        • Status: offline
                        Re:Can you read a text file in a JAR file with VBS? Sunday, December 18, 2011 5:52 AM (permalink)
                        0
                        You don't do Java in VBScript. Does the GetManifest() call not work from a Java program?
                         
                        #12
                          wenbibi

                          • Total Posts : 11
                          • Scores: 0
                          • Reward points : 0
                          • Joined: 12/18/2011
                          • Status: offline
                          Re:Can you read a text file in a JAR file with VBS? Sunday, December 18, 2011 4:20 PM (permalink)
                          0
                          [deleted]
                          <message edited by TNO on Monday, December 19, 2011 3:29 AM>
                           
                          #13
                            cprowse

                            • Total Posts : 5
                            • Scores: 0
                            • Reward points : 0
                            • Joined: 12/13/2011
                            • Location: London, UK
                            • Status: offline
                            Re:Can you read a text file in a JAR file with VBS? Sunday, December 18, 2011 8:33 PM (permalink)
                            0
                            59cobalt


                            You don't do Java in VBScript. Does the GetManifest() call not work from a Java program?


                             
                            #14

                              Online Bookmarks Sharing: Share/Bookmark

                              Jump to:

                              Current active users

                              There are 0 members and 1 guests.

                              Icon Legend and Permission

                              • New Messages
                              • No New Messages
                              • Hot Topic w/ New Messages
                              • Hot Topic w/o New Messages
                              • Locked w/ New Messages
                              • Locked w/o New Messages
                              • Read Message
                              • Post New Thread
                              • Reply to message
                              • Post New Poll
                              • Submit Vote
                              • Post reward post
                              • Delete my own posts
                              • Delete my own threads
                              • Rate post

                              2000-2012 ASPPlayground.NET Forum Version 3.9