Running vbs script works locally from command prompt but not from fixlet

The fixlet script runs with no failure but there is no output to the file. always 0kb

**I can run the vbs script locally on machine and it works fine using the following command. The script captures all installed patches. **

running the script from the command line

//set the variable 
Cscript //nologo //h:cscript //s

run installpatch localhost >output.txt

Below is the fixlet. I can run the vbs script below from command line and it works. However i cannot get the output to the file to read. I have tried but run commands below. the vbs script gets created and the output file is created but empty. What am I doing wrong.

// ADD CODE HERE TO CREATE "PATHNAME".
if {not exists folder "C:\BigFixScripts"}
wait cmd.exe /c "md C:\BigFixScripts"
endif

// create installpatch.vbs
createfile until __the_end

strPatches=500
'strPatches=InputBox(vbCRLF & vbCRLF & "Last How Many Patches?")
strComputer=wscript.arguments(0)

Set objSession = CreateObject("Microsoft.Update.Session", strComputer)
Set objSearcher = objSession.CreateUpdateSearcher

Set colHistory = objSearcher.QueryHistory(0, strPatches)

For Each objEntry in colHistory
	strList = strList & strComputer & vbTAB & objEntry.Title & vbTAB & objEntry.Date & vbCRLF
Next
I am running a vbs script which works fine on the endpoint using command line.This text will be hidden

wscript.echo strList
 __the_end 

delete "C:\BigFixScripts\installpatch.csv"
delete {parameter "scriptPath"}\installpatch.vbs

move __createfile {parameter "scriptPath"}\installpatch.vbs

//waithidden cmd.exe /C cscript //B {parameter "scriptPath"}\installpatch.vbs localhost >> C:\BigFixScripts\installpatch.csv

waithidden cmd.exe /Cscript //nologo //h:cscript //s {parameter "scriptPath"}\installpatch.vbs {computer name} > C:\BigFixScripts\installpatch.csv

By default BigFix runs in 32-bit mode, which means it will launch the 32-bit version of cscript.exe (at \windows\syswow64\cscript.exe ). You can override this behavior and force native mode by using the action uses wow64 redirection false directive in your actionscript, anywhere before the waithidden. ex.

action uses wow64 redirection false

waithidden cmd.exe /C cscript //nologo //h:cscript //s {parameter "scriptPath"}\installpatch.vbs {computer name} > C:\BigFixScripts\installpatch.csv

Check whether that works better for you.

You also had a type-O on your command, if this is a copy/paste:

The “/Cscript” should be “/C cscript”

Thanks for all your information Jason. That solved the problem. thanks for all your help

1 Like

Instead of doing all of that, you can use the folder create command which will create the folder only if it does not already exist: https://developer.bigfix.com/action-script/reference/file/folder-create.html

I would generally NOT recommend doing something like this on the root of the drive. I consider this a bad practice in general.

I would instead recommend using the BigFix download folder (which gets cleaned up), or something similar to C:\Windows\Temp\_BigFix\


Related:

1 Like