Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Part 2 - A few questions for the VBScript Gurus

Status
Not open for further replies.

Ludacris

Technical User
Jun 19, 2004
9
US
Hello all,

I have been mostly successful in setting up my script which basically shows the system hardware specs and installs several software packages in a specific order. However, I have run into a few problems that I can't seem to overcome and I was hoping you guys could assist me.

1. How do you set a temporary path in vbscript? In DOS, all I had to do was type:

set path="C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\j2sdk1.4.2_04\bin"

2. How do you tell vbscript bring up the command prompt and have it change directories to a specific folder so that I can execute a dos based program from that folder?

3. Is there a way to tell vbscript to scan a particular drive for a executable and launch it once it has found it? Right now, I am using an input box for the user to specify a path where all the files are stored so that they can be launched. It works fine, but I just wanted to see if there was an easier way to do this without the user typing in a path.

4. I can get the vbcancel button to wscript.quit in this segment of my code:

Sub Intro
user1 = InputBox ("Enter the path where all the files for the **** installation are stored?", "**** Installer v5.0b Build 1550")
set fso = CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(user1) Then
WScript.Echo "path is valid, preparing to launch script."
Else WScript.Echo "Please input a valid path."
Call Intro
End If
Call Java
End Sub


I removed the wscript.quit reference from the code all together because I kept getting a type mismatch error. Can you guys give me some pointers to get that working. It is driving me nuts. I am using Option Explicit and declaring all my variables at the beginning of my code.

I appreciate your assistance and any help would be greatly appreciated! Thanks in advance!
 
1)
Set S = WScript.CreateObject("WScript.Shell")
Set E = S.Environment("SYSTEM")
E("PATH") = E("PATH") & ";D:\TEMP"
2)
Set S = WScript.CreateObject("WScript.Shell")
S.CurrentDirectory = "D:\Temp"
3) Take a look at the FileSystemObject
You may do a keyword search in this forum for fso recursive
4)
user1 = InputBox("Enter the path where all the files for the **** installation are stored?", "**** Installer v5.0b Build 1550", "\Path\to\DefaultDir")
If user1 = "" Then WScript.Quit 1 ' Cancel button clicked


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV! You are outstanding! I'll give this a shot and see how it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top