Trouble with RunAsCurrentUser

(imported topic written by wustldz)

Hello,

When I take action using the following fixlet it fails. I can see on the target client that my netuse.vbs file gets created so I’m thinking the RunAsCurrentUser part is failing but not sure why. Any help is appreciated.

Here is the fixlet.

prefetch RunAsCurrentUser.exe sha1:ee47505ebfb2790b9da8a20ed70e67158e9753d0 size:342528 http:
//software.bigfix.com/download/bes/util/RunAsCurrentUser-2.0.3.1.exe utility __Download\RunAsCurrentUser.exe   delete __appendfile delete 
"C:\Program Files\BigFix Enterprise\BES Client\netuse.vbs" appendfile Dim network, drives, i, fso, WshShell, f appendfile Set fso = CreateObject(
"Scripting.FileSystemObject") appendfile Set network = CreateObject(
"WScript.Network") appendfile set WshShell = CreateObject(
"WScript.Shell") appendfile set f = fso.CreateTextFile(WshShell.ExpandEnvironmentStrings(
"%USERPROFILE%") & 
"\drives.txt",True) appendfile Set drives = network.EnumNetworkDrives appendfile 

for i = 0 To drives.Count - 1 Step 2 appendfile f.WriteLine drives.Item(i) & 
" " & drives.Item(i+1) appendfile next appendfile f.Close copy __appendfile  
"C:\Program Files\BigFix Enterprise\BES Client\netuse.vbs" delete __appendfile   wait 
"__Download\RunAsCurrentUser.exe" --w 
"C:\Program Files\BigFix Enterprise\BES Client\netuse.vbs" delete 
"C:\Program Files\BigFix Enterprise\BES Client\netuse.vbs"

(imported comment written by SystemAdmin)

In order to run a vbs you have to use cscript.exe or wscript.exe. Such as:

Wait cscript.exe some.vbs

A quick search of the forum for cscript will give you more specifics on the correct format.

(imported comment written by wustldz)

Thanks for the reply. I ended up using wscript instead of cscript to avoid having the cmd window flash on the screen.

Now my action runs to completion and all execution details say complete to include creation of my drives.txt file on the client. That said the console says the action FAILED with Exit code 0. Is there a way to see why it says failed?

(imported comment written by SystemAdmin)

This may be due to what type of action you have. What is the success criteria? If you created a “fixlet” and not a “task” then the original relevance has to become invalid for the action to succeed. If its a task it merely has to run all lines without failing. You can still change this on your original fixlet by fixing the success criteria.

(imported comment written by SystemAdmin)

Probably the easiest way would be to capture the error from the command into a log. So you might add something like this to your action:

wait wscript.exe my.vbs

c:\output.txt 2>&1

This should capture both the output and any errors that are generated.

From the BES Console you could then create an analysis that is something like:

if (exists file “c:\output.txt”) then (lines of file “c:\output.txt”) else (“no results”)

Hope this helps.

(imported comment written by wustldz)

Alan,

That did the trick. Thanks much!