Hi,
I have the following script that I want to execute as a GPO on users machines however one test machine brings the following error;
Line43
Char2
Error: Invalid procedure call or argument
Code: 800A0005
Here is the script, no idea why its doing it. The test machine is an exact replica of my other successful test machines.
col1=Array("ProductName","YES")
col2=Array("ProductVendor","YES")
col3=Array("ProductVersion","YES")
col4=Array("InstallDate","YES")
col5=Array("ComputerName", "YES")
col6=Array("UserName", "YES")
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
Set WshNetwork = CreateObject("WScript.Network")
strComputer = WshNetwork.ComputerName
strUserName = wshShell.ExpandEnvironmentStrings( "%USERNAME%" )
Set fileObj = CreateObject("Scripting.FileSystemObject")
If fileObj.FileExists("\\fa-dc01\Installers\Test\" & strComputer & " - " & strUserName & ".csv") Then
WScript.Quit
Else
Set csvFile = fileObj.CreateTextFile("\\fa-dc01\Installers\Test\" & strComputer & " - " & strUserName & ".csv")
End If
Set WMIObject = GetObject("winmgmts:\\.\root\cimv2")
Set resultSet = WMIObject.ExecQuery ("SELECT * FROM Win32_Product")
'Msgbox "The export will now begin, it may take a few seconds!",vbokonly,"Message"
if(col1(1)="YES") then header=header & col1(0) & "," end if
if(col2(1)="YES") then header=header & col2(0) & "," end if
if(col3(1)="YES") then header=header & col3(0) & "," end if
if(col4(1)="YES") then header=header & col4(0) & "," end if
if(col5(1)="YES") then header=header & col5(0) & "," end if
if(col6(1)="YES") then header=header & col6(0) & "," end if
csvFile.WriteLine mid(header,1,len(header)-1)
For Each app in resultSet
if(col1(1)="YES") then rowData=rowData & """" & app.Name & """" & "," end if
if(col2(1)="YES") then rowData=rowData & """" & app.Vendor & """" & "," end if
if(col3(1)="YES") then rowData=rowData & """" & app.Version & """" & "," end if
if(col4(1)="YES") then rowData=rowData & """" & app.InstallDate & """" & "," end if
if(col5(1)="YES") then rowData=rowData & """" & strComputer & """" & "," end if
if(col6(1)="YES") then rowData=rowData & """" & strUserName & """" & "," end if
csvFile.WriteLine mid(rowData,1,len(rowData)-1)
rowData=""
Next
'Msgbox "Data exported successfully, see generated .csv file",vbokonly,"Done"
csvFile.Close
Thanks
I have the following script that I want to execute as a GPO on users machines however one test machine brings the following error;
Line43
Char2
Error: Invalid procedure call or argument
Code: 800A0005
Here is the script, no idea why its doing it. The test machine is an exact replica of my other successful test machines.
col1=Array("ProductName","YES")
col2=Array("ProductVendor","YES")
col3=Array("ProductVersion","YES")
col4=Array("InstallDate","YES")
col5=Array("ComputerName", "YES")
col6=Array("UserName", "YES")
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
Set WshNetwork = CreateObject("WScript.Network")
strComputer = WshNetwork.ComputerName
strUserName = wshShell.ExpandEnvironmentStrings( "%USERNAME%" )
Set fileObj = CreateObject("Scripting.FileSystemObject")
If fileObj.FileExists("\\fa-dc01\Installers\Test\" & strComputer & " - " & strUserName & ".csv") Then
WScript.Quit
Else
Set csvFile = fileObj.CreateTextFile("\\fa-dc01\Installers\Test\" & strComputer & " - " & strUserName & ".csv")
End If
Set WMIObject = GetObject("winmgmts:\\.\root\cimv2")
Set resultSet = WMIObject.ExecQuery ("SELECT * FROM Win32_Product")
'Msgbox "The export will now begin, it may take a few seconds!",vbokonly,"Message"
if(col1(1)="YES") then header=header & col1(0) & "," end if
if(col2(1)="YES") then header=header & col2(0) & "," end if
if(col3(1)="YES") then header=header & col3(0) & "," end if
if(col4(1)="YES") then header=header & col4(0) & "," end if
if(col5(1)="YES") then header=header & col5(0) & "," end if
if(col6(1)="YES") then header=header & col6(0) & "," end if
csvFile.WriteLine mid(header,1,len(header)-1)
For Each app in resultSet
if(col1(1)="YES") then rowData=rowData & """" & app.Name & """" & "," end if
if(col2(1)="YES") then rowData=rowData & """" & app.Vendor & """" & "," end if
if(col3(1)="YES") then rowData=rowData & """" & app.Version & """" & "," end if
if(col4(1)="YES") then rowData=rowData & """" & app.InstallDate & """" & "," end if
if(col5(1)="YES") then rowData=rowData & """" & strComputer & """" & "," end if
if(col6(1)="YES") then rowData=rowData & """" & strUserName & """" & "," end if
csvFile.WriteLine mid(rowData,1,len(rowData)-1)
rowData=""
Next
'Msgbox "Data exported successfully, see generated .csv file",vbokonly,"Done"
csvFile.Close
Thanks