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

Build All Visual Studio Solutions In a Given Directory 1

Status
Not open for further replies.

shatterstar6457

Programmer
Aug 6, 2006
4
US
Im getting the following error:

C:\Compile All Visual Studio Solutions.vbs(16, 1) Microsoft VBScript runtime error: Object required: '[string: "F:\Code Samples"]'

where - line 16 is this:

Set objFolderPath = objFolder.Path

-Full Code-

Option Explicit

Dim objFSO, objFile, objFolder, objSubFolder, objShell, objFolderPath,_
colFiles, colFolders, colSubFolders,_
strStartDir, strExtension, strPath,_
intCount

strStartDir = InputBox("Full path of folder to check?")
strExtension = InputBox("Please enter the File Extension To Search For")
intCount = 0

Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strStartDir)
Set colFiles = objFolder.Files
Set objShell = CreateObject("WScript.Shell")
Set objFolderPath = objFolder.Path

For each objFile in colFiles

If lcase(Right(objFile.Name,3)) = strExtension Then
objShell.Run("%COMSPEC% /C devenv /useenv /out C:\MyErrorLog.txt " & objFolderPath & objFile.Name & " /build Debug"),1,TRUE
intCount = intCount + 1
Else
WScript.Echo "I found this file which is " & objFile.Name &_
" but it does not have the Extension " & strExtension
end if
Next

ScanSubFolders(objFolder)
WScript.Echo "DevEnv Found And Attempted To Compile " & intCount & " Files"

Sub ScanSubFolders(objFolder)

Set colFolders = objFolder.SubFolders

For Each objSubFolder In colFolders
Set colFiles = objSubFolder.Files


For Each objFile in colfiles

If lcase(Right(objFile.Name,3)) = strExtension Then
objShell.Run("%COMSPEC% /C devenv /useenv /out C:\MyErrorLog.txt " & objFolderPath & "\" & objFile.Name & " /build Debug"),1,TRUE
intCount = intCount + 1
Else
WScript.Echo "I found this file which is " & objFile.Name &_
" but it does not have the Extension " & strExtension
End If
Next

ScanSubFolders(objSubFolder)
Next

End Sub
 
[1] No set keyword, and it is plain string (obj prefix may mislead yourself eventually.)
>Set objFolderPath = objFolder.Path
[tt]objFolderPath = objFolder.Path[/tt]

[2] It contains no backslash.
> objShell.Run("%COMSPEC% /C devenv /useenv /out C:\MyErrorLog.txt " & objFolderPath & objFile.Name & " /build Debug"),1,TRUE
[tt] objShell.Run("%COMSPEC% /C devenv /useenv /out C:\MyErrorLog.txt " & objFolderPath & [red]"\" &[/red] objFile.Name & " /build Debug"),1,TRUE[/tt]
 
Okay new problem, my folder path has a space in and so does a lot of my deeper, much deeper level folder. How do I pass a variable with double quotation marks without making the variable invalid.
 
[tt] objShell.Run("%COMSPEC% /C devenv /useenv /out C:\MyErrorLog.txt " & [blue]chr(34) &[/blue] objFolderPath & "\" & objFile.Name [blue]& chr(34) [/blue]& " /build Debug"),1,TRUE[/tt]

note: chr(34) is basically just a quote ("); that means you wrap the path with quotes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top