Solved

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

Posted on 2007-11-15
9
838 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 …
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now