Solved

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

Posted on 2007-11-15
9
826 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

21 Experts available now in Live!

Get 1:1 Help Now