Action Stuck in a 'Running' State

(imported topic written by SystemAdmin)

Hello everyone,

So, I’m trying to run some action script in a fixlet along with a VBScript at the end:

appendfile {names of folders whose (creation time of it > (now - 4 * day)) of folder “D:\APPS\BigFix Enterprise\BES Server\BESReportsData\ArchiveData\9”}

delete “D:\APPS\BigFix Enterprise\BES Server\BESReportsData\ArchiveData\9\latestfolder.txt”

move __appendfile “D:\APPS\BigFix Enterprise\BES Server\BESReportsData\ArchiveData\9\latestfolder.txt”

wait cmd.exe /C “cd D: & cd D:\APPS\Bigfix Enterprise\BES Server\BESReportsData\ArchiveData\ & start Unmanaged Assets NO EXCEL VER.vbs”

My problem is that when I run the fixlet, the fourth line of action script stays in a ‘Running’ state much longer than it should…it actually never leaves the ‘Running’ state. I have a feeling that the script is causing the issue however, when I change the last line of action script (the one with the VBScript) I can get the action to a ‘Completed’ state but the VBScript does not seem to execute. To do this I change the action script to:

wait cscript.exe “D:\APPS\Bigfix Enterprise\BES Server\BESReportsData\ArchiveData\Unmanaged Assets NO EXCEL VER.vbs”

The VBScript is shown below:

Dim oFSO, fReport, fReport1, latest, fread, comma, length, midstring, diff

Set oFSO = CreateObject(“Scripting.FileSystemObject”)

set fReport1 = oFSo.OpenTextFile("\server\share\9\latestfolder.txt",1,true)

latest = fReport1.Readline

strPathLoggood = “D:\APPS\BigFix Enterprise\BES Installers\BESClientDeploy\UnmanagedAssetsReportGood.txt”

strPathLogbad = “\server\share\9\UnmanagedAssetsReportBad.txt”

Set fReport = oFSO.CreateTextFile(strPathLogGood, True)

Set fReport1 = oFSO.CreateTextFile(strPathLogBad, True)

set fread = oFSO.OpenTextFile("\server\share\9"& latest &"\archive.csv",1,true)

Dim company, location, genre, hostname, mac, macfilter

latest = fread.Readline

do while fread.atendofstream true

latest = fread.readline

for i = 0 to 3

length = Len(latest)

comma = inStr(latest, “,”)

diff = length - comma

midstring = Mid(latest, comma+1, diff)

latest = midstring

next

company = Mid(latest, 2, 1)

location = Mid(latest, 3, 3)

genre = Mid(latest, 6, 2)

mac = Mid(latest, 8, 6)

macfilter = Mid(latest, 14, 1)

hostname = Mid(latest, 2, 12)

If company = “h” Then

if location = “apg” OR location = “cap” OR location = “fra” OR location = “jun” OR location = “kan” OR location = “pdc” OR location = “pil” OR location = “tom” OR location = “yrk” OR location = “car” OR location = “chi” OR location = “pla” OR location = “ezu” OR location = “emo” OR location = “eba” OR location = “ecr” OR location = “ear” OR location = “eri” OR location = “eox” OR location = “epr” OR location = “eca” OR location = “eru” OR location = “edu” OR location = “aus” OR location = “bra” OR location = “cna” OR location = “ind” OR location = “mia” OR location = “mic” OR location = “mus” OR location = “sin” OR location = “jsh” OR location = “jak” OR location = “jka” then

if genre = “lt” OR genre = “ws” OR genre = “sf” then

if macfilter = “.” then

fReport.write hostname & vbnewline

Else

fReport1.write latest & vbnewline

End If

Else

fReport1.write latest & vbnewline

End If

Else

fReport1.write latest & vbnewline

End If

Else

fReport1.write latest & vbnewline

End If

loop

dim oFile, oFSO1, hostnamelog, PorF, result

Set WshShell = WScript.CreateObject(“WScript.Shell”)

result = WshShell.run(“cmd /C D: & cd D:\APPS\Bigfix Enterprise\BES Installers\BESClientDeploy\ & start BESClientDeploy.exe /useComputerNameList UnmanagedAssetsReportGood.txt /automatic /username username /password password”,true)

set oFSo = CreateObject(“Scripting.FileSystemObject”)

Set oFSO1 = CreateObject(“Scripting.FileSystemObject”)

Set fReport = oFSo1.OpenTextFile("\server\share\9\UnmanagedAssets.txt",8, true)

fReport.WriteLine “Hostname” & vbTab & “Time” & vbTab & “Agent Version” & vbTab & “Pass/Fail”

set oFile = CreateObject(“Scripting.FileSystemObject”)

set fReport1 = oFSo.OpenTextFile(“D:\APPS\BigFix Enterprise\BES Installers\BESClientDeploy\UnmanagedAssetsReportGood.txt”,1,true)

Do while fReport1.AtEndOfStream True

hostnamelog = fReport1.Readline

InstalledVersion = WshShell.RegRead(“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{E387A719-DD69-41CC-A876-A1EEB55E03D9}\DisplayVersion”)

if(InstalledVersion = “” or result 0) then

PorF = “fail”

else

PorF = “pass”

end if

fReport.WriteLine hostname & vbTab & Now() & vbTab & InstalledVersion & vbTab & PorF

Loop

Thanks in advance to everyone who can shed light on the topic.

Cheers,

Ilithis

(imported comment written by Bill.Ehardt)

My guess is the vbscript is erroring out somewhere. When this happens, it would pop up an alert that is waiting for someone to close it. If it isn’t popping up on the console then the error would never close, hence cscript would always be running. To test this out add the following line to the start of the vbscript:

On Error Resume Next

(imported comment written by SystemAdmin)

wmehardt,

Thanks for your input, however when I added that line of code to the start of the VBScript the same thing happens where the action is stuck in a ‘Running’ state and never gets to the ‘Completed’ state.

I can execute the VBScript fine when I double click on it or use run -> cscript.exe “D:\APPS\Bigfix Enterprise\BES Server\BESReportsData\ArchiveData\Unmanaged Assets NO EXCEL VER.vbs”

Ilithis

(imported comment written by mgemma91)

I’d add some logging to the vbscript so that you can see exactly which parts the action is getting to and what parts it never reaches. Also make sure that BigFix can access your server share when it’s running as SYSTEM. Or use RunAsCurrentUser on the script.

(imported comment written by SystemAdmin)

mgemma,

I’m attempting to use RunAsCurrentUser on the script and to execute it this is what I have:

delete __appendfile

appendfile {names of folders whose (creation time of it > (now - 4 * day)) of folder “D:\APPS\BigFix Enterprise\BES Server\BESReportsData\ArchiveData\9”}

delete “D:\APPS\BigFix Enterprise\BES Server\BESReportsData\ArchiveData\9\latestfolder.txt”

move __appendfile “D:\APPS\BigFix Enterprise\BES Server\BESReportsData\ArchiveData\9\latestfolder.txt”

wait RunAsCurrentUser.exe --w cmd.exe /c “D:\APPS\BigFix Enterprise\BES Server\BESReportsData\ArchiveData\Unmanaged Assets NO EXCEL VER.vbs”

However, the line of actionscript with RunAsCurrentUser.exe is failing. Is there something syntactically incorrect with my implementation of RunAsCurrentUser? I tried following the syntax I found on the support page: http://support.bigfix.com/cgi-bin/kbdirect.pl?id=392

Ilithis

(imported comment written by mgemma91)

You need to download RunAsCurrentUser somewhere first. Like:

prefetch RunAsCurrentUser.exe sha1:ee47505ebfb2790b9da8a20ed70e67158e9753d0 size:342528 http://software.bigfix.com/download/bes/util/RunAsCurrentUser-2.0.3.1.exe

wait __Download\RunAsCurrentUser.exe --w cmd.exe /c “D:\APPS\BigFix Enterprise\BES Server\BESReportsData\ArchiveData\Unmanaged Assets NO EXCEL VER.vbs”