Solved

how do you write a vbscript to check if i files exists?

Posted on 2007-11-15
9
868 Views
Last Modified: 2008-02-01
i need to install ms java machine to 31 cleints. Some of the cleints have the software installed. So i need to write a vb script that checks if C:\WINDOWS\System32\jview.exe exists.
If it does not then install if quietly from
P:\LANGUAGES\Microsoft JVM Build 3805.

Can you also point me to any site that teach vbscript writing (need to be very basic due to lack of knowledge)

thanks as always

0
Comment
Question by:exdos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 6

Expert Comment

by:MELeBlanc
ID: 20288713
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(Filename and path) Then
End If


-M
0
 

Author Comment

by:exdos
ID: 20288736
just trying that now!
0
 
LVL 6

Expert Comment

by:MELeBlanc
ID: 20288737
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 65

Expert Comment

by:RobSampson
ID: 20292046
If you don't already know how to install the Java VM silently, this may help, although I haven't tried it:
Installing or Updating the Microsoft Java Virtual Machine
http://corob.net/msjava/

Regards,

Rob.
0
 

Author Comment

by:exdos
ID: 20320096
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(C:\WINDOWS\System32\jview) Then
End If

can you let me know where i need to put the path and switches in the above syntax

path is P:\apps\java.exe /q
thanks
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 20322783
Hi, if you want to install the software if that file does not exist, then use this (by the way I've assumed that jview is an EXE file, so if that's not correct, just change it):

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
If objFSO.FileExists("C:\WINDOWS\System32\jview.exe") = False Then
   objShell.Run "cmd /c p:\apps\java.exe /q", 1, True
End If

And you can change the , 1, True part to , 0, True to hide the command prompt.

Regards,

Rob.
0
 

Author Comment

by:exdos
ID: 20327083
i have tried this
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
If objFSO.FileExists("C:\WINDOWS\System32\jview.exe") = False Then
   objShell.Run "cmd /c p:\apps\java.exe /q", 1, True
End If


the dos screen appears but i get the message
"p:\apps is not a reconginsed as an internal or external command, opearble program or batch file."
I know how to set the path in batch files

set local
path=

but not in vb scripts, any ideas

thanks


0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 20330859
Hi, is P Drive already mapped?  If not, try something like this:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
If objFSO.DriveExists("P:") = False Then objNetwork.MapNetworkDrive "P:", "\\server\pshare"
If objFSO.FileExists("C:\WINDOWS\System32\jview.exe") = False Then
   objShell.Run "cmd /c p:\apps\java.exe /q", 1, True
End If


Other than that, I'm surprised it says "P:\Apps is not recognised..." as that means the command it is trying to execute stops at P:\Apps and does not try to run the Java.exe....

Does that command work alone from the command line?

If you are still stuck after today, please post a new question so someone else can help you, as I will be unavailable for a few weeks.

Regards,

Rob.
0
 

Author Comment

by:exdos
ID: 20372596
sorry for the delay, as the other support staf are off i have been unable to test this, once i do i will replay back
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question