/build/static/layout/Breadcrumb_cap_w.png

Need a VB Script

I would usually create something like this in Powershell, but the majority of the machines this will be ran on will be XP. I'm not too familiar with VB scripting since for whatever reason I skipped over it, and went straight to Powershell.

I need something that will look at a log file in a specific path. Is there a way to look in both paths in one script?

Win 7 - %PROGRAMDATA%\Sophos\AutoUpdate\Logs\alc.log

Win XP- %PROGRAMFILES%\Sophos\AuotUpdate\Logs\alc.log

I would usually run a ShellCommandTextReturn custom inventory in Kace, but this is a pretty lengthy log file. I'm looking for a particular string "Download of Sophos AutoUpdate Failed from Server http://<servername>/CIDs/<old_path>/SAVSCFXP/". This should get if any of my machines are pointing to the wrong update path. 

I then need to take that entry if it exists, and export to a txt file so that I can have Kace inventory it. I can then add it to my report.

 

***EDIT***

I've got this so far. I would like one script to run on both XP and Win 7. I'm running this using "cscript script.vbs  //NoLogo > c:\temp.txt". This gives me an output as text file.  

Const ForReading = 1 

 

strFileName = "C:\ProgramData\Sophos\AutoUpdate\Logs\alc.log"

strFailed = "Download of Sophos AutoUpdate Failed from Server"

strSucceeded = "SophosAutoUpdate"

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile(strFileName, ForReading) 

strText = objFile.ReadAll 

objFile.Close

 IF InStr(strText, strFailed) Then

WScript.Echo "Download of Sophos AutoUpdate failed from server http://<servername>/CIDs/S009/SAVSCFXP/"

ELSEIF InStr(strText, strSucceeded) Then

WScript.Echo "Update Successful"

End IF

 

0 Comments   [ + ] Show comments

Answers (1)

Answer Summary:
Posted by: jverbosk 11 years ago
Red Belt
0

If your Win7 is x64, you could use a bitness test (or, if not, at least take this idea and run with it).

John

_____________________________________

vbscript version:

_____________________________________

'find OS bitness and run MI check-in from appropriate folder

Dim WshShell,runStr,strProgramFiles
set WshShell = WScript.CreateObject("WScript.Shell")

OsType = wshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
If OsType = "x86" then
runStr = Chr(34) & "C:\Program Files\Dell\KACE\runkbot.exe" & Chr(34) & " 6 0"
WshShell.run runStr

elseif OsType = "AMD64" then
runStr = Chr(34) & "C:\Program Files (x86)\Dell\KACE\runkbot.exe" & Chr(34) & " 6 0"
WshShell.run runStr
end if

_____________________________________

_____________________________________

batch file version:

_____________________________________

if /i %processor_architecture%==AMD64 GOTO x64
if /i %processor_architecture%==x86 GOTO x86

:x64
:: MI check-in (64-bit)
"C:\Program Files (x86)\Dell\KACE\runkbot.exe" -s 4 0
GOTO END

:x86
:: MI check-in (32-bit)
"C:\Program Files\Dell\KACE\runkbot.exe" -s 4 0

:END


Comments:
  • I did do something similar. I uploaded two separate scripts as dependencies and checked OS in a batch file. Then called the correct script. It works. Just looking for something a little cleaner. - dugullett 11 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ