Colocar Resposta 
 
Avaliação do Tópico:
  • 1 votos - 5 Média
  • 1
  • 2
  • 3
  • 4
  • 5
.VBS
07-05-2012, 16:02
Mensagem: #1
.VBS
Olá pessoal estou com uma duvida neste codigo que ainda nao consegui perceber qual é, encontrei-o na net e sei que tenho de por o caminho para onde vai o ficheiro txt, mas isto esta me a dar um erro na linha 12 e ainda nao consegui perceber onde está o erro. Segue aqui o codigo:


Set objNetWork = CreateObject("Wscript.Network")
strUserName = objNetwork.UserNamestrPcName = objNetwork.ComputerName
strNameFile = strUserName&" - "&strPcName
strPath = "C:\"
strPathFile = strPath & strNameFile &".txt"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(strPathFile) Then
WScript.Quit
End If
Set objFile = fso.OpenTextFile(strPathFile,2,True)
Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")
objFile.WriteLine("----- Arquivo Criado em "& Date &" às "& Time &" -----")objFile.WriteBlankLines(2)
strSO = "Win32_OperatingSystem"strProcessor = "Win32_Processor"strMemory = "Win32_PhysicalMemory"strDisk = "Win32_DiskDrive"strPrint = "Win32_Printer"
Set objWMI = GetObject("winmgmts:")
' SISTEMA
objFile.WriteLine("SISTEMA:")objFile.WriteBlankLines(1)
Set colWMI = objWMI.InstancesOF(strSO)
For Each strWMI In colWMI
objFile.WriteLine(strWMI.Caption) dtmConvertedDate.Value = strWMI.InstallDate strData = dtmConvertedDate.GetVarDate objFile.WriteLine("Data de instalação: "& strData) objFile.WriteLine("Service Pack: "& strWMI.ServicePackMajorVersion) NextobjFile.WriteBlankLines(1)
' PROCESSADOR
objFile.WriteLine("PROCESSADOR:")objFile.WriteBlankLines(1)
Set colWMI = objWMI.InstancesOF(strProcessor)
For Each strWMI In colWMI
objFile.WriteLine(strWMI.Name &" "& strWMI.MaxClockSpeed &"Mhz") NextobjFile.WriteBlankLines(1)
' MEMÓRIA
objFile.WriteLine("MEMÓRIA:")objFile.WriteBlankLines(1)
Set colWMI = objWMI.InstancesOF(strMemory)
For Each strWMI In colWMI
objFile.WriteLine(strWMI.Capacity/1024/1024 &"MB") NextobjFile.WriteBlankLines(1)
' DISCO
objFile.WriteLine("DISCO:")objFile.WriteBlankLines(1)
Set colWMI = objWMI.InstancesOF(strDisk)
For Each strWMI In colWMI
objFile.WriteLine("Tamanho Total: "& Round(strWMI.Size/1024/1024/1024) &"GB") Next
objFile.WriteBlankLines(1)' IMPRESSORASobjFile.WriteLine("IMPRESSORAS:")objFile.WriteBlankLines(1)
Set colWMI = objWMI.InstancesOF(strPrint)
For Each strWMI In colWMI
objFile.WriteLine(strWMI.DeviceId) Next
objFile.WriteBlankLines(1)
' PROGRAMAS
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINEstrComputer = "."strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"strEntry1a = "DisplayName"strEntry1b = "QuietDisplayName"strEntry2 = "InstallDate"strEntry3 = "VersionMajor"strEntry4 = "VersionMinor"strEntry5 = "EstimatedSize"
Set objReg = GetObject("winmgmts://" & strComputer & _ "/root/default:StdRegProv")objReg.EnumKey HKLM, strKey, arrSubkeys
objFile.WriteLine("Programas Instalados:")objFile.WriteBlankLines(1)
For Each strSubkey In arrSubkeys intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, strEntry1a, strValue1) If intRet1 <> 0 Then objReg.GetStringValue HKLM, strKey & strSubkey, strEntry1b, strValue1 End If If strValue1 <> "" Then objFile.WriteLine("Nome: " & strValue1) End If objReg.GetStringValue HKLM, strKey & strSubkey, strEntry2, strValue2 If strValue2 <> "" Then objFile.WriteLine("Data de Instalação: " & strValue2) End If objReg.GetDWORDValue HKLM, strKey & strSubkey, strEntry3, intValue3 objReg.GetDWORDValue HKLM, strKey & strSubkey, strEntry4, intValue4 If intValue3 <> "" Then objFile.WriteLine("Versão: " & intValue3 & "." & intValue4) End If objReg.GetDWORDValue HKLM, strKey & strSubkey, strEntry5, intValue5 If intValue5 <> "" Then objFile.WriteLine("Tamanho Estimado: " & Round(intValue5/1024, 3) & " MB") End If
objFile.WriteBlankLines(1)
Next


pessoal se alguem quiser de me uma ajudinha, precisava disto para ontem. XD
Procurar todas as mensagens deste utilizador
Citar esta mensagem numa resposta
Colocar Resposta 


Mensagem neste Tópico
.VBS - pmesteves - 07-05-2012 16:02
RE: .VBS - karkov - 07-05-2012, 16:52
RE: .VBS - pmesteves - 07-05-2012, 17:39
RE: .VBS - karkov - 07-05-2012, 22:03

Saltar Fórum:


Utilizadores a ver este tópico: 1 Visitante(s)