Solved

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

Posted on 2007-11-15
9
847 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Cannot get VBScript to run as schedules task 10 47
Check version 13 75
I want to make a copying program for vbs 1 46
VBScript Issues 8 34
Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

803 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