Get Status of Driver Inside Visual Basic - drivers

I'm currently trying to detect which drivers appear as "not working" in visual basic.
This unknown device is a good example of what I'm trying to grab (notice how it has the flag DN_HAS_PROBLEM).
I've tried using searches such as:
Dim searcher As New ManagementObjectSearcher( "root\CIMV2", "SELECT * FROM Win32_SystemDriver")
And running a loop in the searcher.Get() through this documentation
However, none of these seem to return what I am looking for.
Would anyone happen to know how I can get the DN_ statuses within Visual Basic?
Thanks!

The Win32_SystemDriver class documentation lists these Status properties:
OK
Error
Degraded
Unknown
Pred Fail
Starting
Stopping
Service
Stressed
NonRecover
No Contact
Lost Comm
...whereas DN_HAS_PROBLEM comes from the CM_Get_DevNode_Status function, or perhaps also from other system calls.
There may not be a way to get that specific code from the API you're using, but perhaps the existing Status properties will suffice for your needs if you don't need to know more specific failure reasons.
If you do need to know that specific status, you'll have to call other APIs, like the one I called out.

Related

SerialSearch with Cursors

I am trying to use SerialSearch to identify about 800 titles with a single keyword. When I run:
serialSearch = SerialSearch(query={"title": "myKeyword"})
it gives me the first 200. I would like to get the remaining 600. I saw there is a start parameter that appears to be deprecated in favor of a cursor but I can't find any details on how to implement it. Is there a reference example for this?
With the current development version you can pass start=200 to the class, to get entries ranging from 200 to 399.
Install via
pip install git+https://github.com/pybliometrics-dev/pybliometrics
Then use
serialSearch = SerialSearch(query={"subject": "ECON"}, start=200, refresh=True)
The refresh=True bit is important, otherwise pybliometrics will use the old information.
Eventually Scopus implements pagination with cursors akin to the Scopus Search API, which would solve this problem.

Can I enable / Disable an Azure Service Bus Topic using Powershell

I have spent a couple of hours search for a solution to disable my Azure Service Bus Topics using Powershell.
The background for this is we want to force a manual failover to our other region.
Obviously I could click in the Portal:
but I want to have a script to do this.
Here is my current attempt:
Any help would be great.
Assuming you're sure your $topic contains the full description, modify the status parameter in the array and then splat it back using the UpdateTopic method. I'm afraid I can't test this at present.
$topic.Status = "Disabled"
$topicdesc = $NamespaceManager.UpdateTopic($topic)
I don't think you'll need to set the entity type for the Status, nor do you require semi-colons after each line of code in your loop.
References
PowerShell Service Bus creation sample script (which this appears to be based off): https://blogs.msdn.microsoft.com/paolos/2014/12/02/how-to-create-service-bus-queues-topics-and-subscriptions-using-a-powershell-script/
UpdateTopic method: https://msdn.microsoft.com/en-us/library/azure/microsoft.servicebus.namespacemanager.updatetopic.aspx
Additional note: please don't screenshot the code - paste it in. I'd rather copy-and-paste than type things out.

Is it possible to use a control without putting it on a form in VB6?

I'm pretty sure about the answer to this, but I'm trying a variety of things to get a very stubborn project to work. One idea was to try to run code through a control without defining it on a form.
So, for example, my original code looked like this:
frmProcess.MyViewer.MaxPageSize = 100
frmProcess.MyViewer.ResetPages
frmProcess.MyViewer.AddPageToView "C:\TestPage1.txt"
I've changed it to:
Dim objViewer As MyViewer
objViewer.MaxPageSize = 100
objViewer.ResetPages
objViewer.AddPageToView "C:\TestPage1.txt"
I get an error window with "Run-time error '91': Object variable or With block variable not set".
But there doesn't seem to be a way to 'set' this control. Is this just impossible, or is there another way to do it that doesn't require a form?
EDIT: I ended up abandoning this entire path of activity, as an alternate solution was found that got around the problem I was having with this form freezing. I don't want to delete this question in case someone else comes along and can benefit from the answers, which are potentially useful.
Try this on a form.
Dim objViewer As MyViewer
Set objViewer = Controls.Add("MyViewer", "MyViewer1")
objViewer.MaxPageSize = 100
objViewer.ResetPages
objViewer.AddPageToView "C:\TestPage1.txt"
I've had similar situations in the past. If all else fails and you have to use a form you can do something crude like
1) Set the .Left property of the control to a negative number (like -10000) so the control doesn't appear on the form, the user can not see it
2) Make the entire form not visible..
ActiveX controls normally expect a number of services from their containers, for example persistence. They are also "packaged and marked" in ways that set the kinds of instantiation they support.
See Introduction to ActiveX Controls.
While it is perfectly possible for a control to be created in such a way as to make many of the available services optional, most controls are created from template code that requires a number of them. And most controls that are "visible at runtime" are going to require container services.
However that doesn't mean a control can't be designed to support containerless instantiation. A well known example of such a control is Microsoft Script Control 1.0 (MSScriptControl.ScriptControl) which can be used either way.

Sugar CRM SOAP API - Problems with Auto Incrementing Key and set_entry

I've tried the SugarCRM forums for this problem as well, but I was wondering if anyone here has run into a similar issue and would be willing to share the solution.
We are working with the SOAP API for Sugar CRM via the Sugar On Demand system and their appears to be a problem - which at the moment looks very much like a bug.
The Module we trying to work with is the case module. We are running the set_entry action on the case module. It worked the first time we did this, but now it refuses to allow us to enter any more modules. I've checked the log files and made sure that we are submitting anything in the case_number field to over ride this, but whenever we try to add a new case we get the following error showing up in the log:
Query Failed: INSERT into cases set id='bb53030e-0f2f-5787-f403-4dde57cde36e', name='New RMA Request Test', date_entered='2011-05-26 13:37:15', date_modified='2011-05-26 13:37:15', modified_user_id='b1256ced-011d-7c1a-e1f3-4d4004ea4e9a', created_by='b1256ced-011d-7c1a-e1f3-4d4004ea4e9a', description='fjdlkas', deleted='0', assigned_user_id=null, team_id=null, team_set_id='ded0fbb0-c5dc-74ee-0622-4d22eb653a80', type=null, status=null, priority=null, resolution=null, system_id=1, work_log=null, account_id=null: MySQL error 1062: Duplicate entry '2147483647' for key 2
This is a bit odd for a few reasons:
I've confirmed that the corresponding key is auto-incrementing.
I am not submitting that number anywhere.
The next auto-increment value when I check the setting in the Studio is actually 2147483648.
Can someone explain what I need to do with the SOAP API to stop it from overriding the auto-increment value on my table?
Edit: I get the same error if I try to add a case via the interface, so I suspect this could be a problem with the CRM configuration itself rather than a SOAP related issue like I originally thought.
I would try to increase the size of the case_number field from an int(11) to something bigger and see if that fixes the issue.

Customize Error Reporting via E-mail in Pylons

I am sending myself WebApp error reports from Pylons when users hit critical errors and I would love to be able to get the full output of session[] in the reports and customize it to my liking, but I've got no idea how to do that, or where the report is actually created / put together.
Anyone know how I can accomplish that?
The short answer is that you will have to roll your own for this functionality. WebError is the package used to handle this, and it doesn't provide any extension points. Your best bet may be to use a fork of it with your changes, although even then the code is not pretty.
I thank Michael for answering me, without really giving me anything to build on. That meant I had to figure it out myself, and that's always a good thing :)
What I did was, I looked at /config/middleware.py in my Pylons project and found this line:
app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
I made my own ErrorHandler def and my own ErrorMiddleware class at the top of the middleware.py file:
class ClaraErrorMiddleware(ErrorMiddleware):
def exception_handler(self, exc_info, environ):
# do what ever you want with the exc_info or environ vars
super(ClaraErrorMiddleware, self).exception_handler(exc_info, environ) # call parent
pass
def ClaraErrorHandler(app, global_conf, **errorware):
if asbool(global_conf.get('debug')):
return ErrorHandler(app, global_conf, **errorware)
else:
return ClaraErrorMiddleware(app, global_conf, **errorware)
So now, I can throw in some extra variables I want to be sent with my error emails. Simple enough ...