Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2007-11-15
9
Medium Priority
?
879 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 1500 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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

971 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