- 1 year ago
Using Only FileSystemObject in a VBScript, How Can I Determine the Operating System's Processor Architecture?
In VBScript, you can use the FileSystemObject
to access system information indirectly. However, determining the operating system's processor architecture is not a task that can be achieved solely with the FileSystemObject
. You'll need to combine it with other methods or objects to obtain the required information.
One approach is to use the WScript.Shell
object along with the FileSystemObject
to execute a command and capture its output. Here's an example script that determines the processor architecture using this combination:
vbscriptSet objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Execute the systeminfo command and capture the output
Set objCmd = objShell.Exec("systeminfo")
strOutput = objCmd.StdOut.ReadAll
' Search for the processor architecture in the output
If InStr(strOutput, "Processor(s):") > 0 Then
arrLines = Split(strOutput, vbNewLine)
For Each strLine In arrLines
If InStr(strLine, "Processor(s):") > 0 Then
' Extract the processor architecture from the line
arrWords = Split(strLine, " ")
strArchitecture = arrWords(UBound(arrWords))
Exit For
End If
Next
' Display the processor architecture
If Len(strArchitecture) > 0 Then
WScript.Echo "Processor Architecture: " & strArchitecture
Else
WScript.Echo "Processor Architecture not found."
End If
Else
WScript.Echo "Unable to retrieve system information."
End If
Set objCmd = Nothing
Set objFSO = Nothing
Set objShell = Nothing
This script uses the systeminfo
command-line tool to retrieve detailed system information. It then searches for the line containing the processor information and extracts the processor architecture from it.
Please note that this method relies on executing external commands, so it may not work in all environments or configurations. Additionally, it's worth considering that VBScript is an outdated scripting language, and it's recommended to use more modern alternatives like PowerShell for system-related tasks.