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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading software from a network drive

Status
Not open for further replies.

TD007

MIS
Jul 9, 2008
4
0
0
US
I have a script that is working fine but I would like to clean it up. The script loads software from a software share but the applications are not all located in one folder so my question is this:

Is there a way to script the network mapping once and then navigate throughout the mapped drive for the folders that contain the executables. Right now it cannot ever find the folders I try to direct it to unless I map directly to the directory.

Currently it maps to the folder, runs the executable and then disconnects and just repeats the mappings to different areas for the different software that needs to load.
 
do you mean search a directory for a program?

Code:
set objFSO = CreateObject("Scripting.FileSystemObject")
set objShell = CreateObject("WScript.Shell")

function searchDir(strDir, strQuery, boolFirst)
	set objFolder = objFSO.GetFolder(strDir)
	for each objSubFolder in objFolder.SubFolders
		strResults = strResults & searchDir(objSubFolder.Path, strQuery, boolFirst)
	next
	
	for each objFile in objFolder.Files
		if (inStr(objFile.Name, strQuery)) then 
			if (boolFirst) then 
				searchDir = objFile.Path
                exit function
            end if
            strResults = strResults & objFile.Path & vbNewLine
        end if
	next
	searchDir = strResults
end function

objNetwork.MapNetworkDrive "x:", "\\server\share"
strPath = searchDir("x:\", "my_program.exe", true)

objShell.Run strPath

or something

-Geates
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top