Using WMI on a remote machine - client

Is it possible at all to obtain WMI information (within C#.NET) from an external source such as a hard drive with a Windows installation on?
I ask this because I'm making an automated diagnostic utility for A-Level Computing, and there are often times when the remote machine may not boot, so a host machine needs to connect somehow to the faulty machine to exchange information.
If this isn't possible, do you know any way in which I can achieve this effect (e.g. by booting into a minimal operating system such as Hiren's Boot and running the .NET application)

No you can't, to access the WMI the Windows OS and the WMI Service must be running in the remote machine.

You would have to wake the machine, WMI is a service, if it isnt running then you cant Query it.

Related

Working with windows applications remotely

I am working with some applications which are located on remote windows server. In that case I need to login remotely to this machine (using remote desktop). Having two desktops (local and remote) on one monitor is uncomfortable (I need to all the time switch between them).
Is there any similar tool to xming? I will be better for me using remote applications like a local (integrated with my local desktop).
Good day Pawel.
Could you specify your situation?
1. If you need to call and retrive exit codes from windows objects(programms and etc) remotely try to use WMI
2. If you need to execute your code remotely try to use some kinds of frameworks for example Pyro(it's implemented in Python programming language)
3. in case of using file systems locally you neede to can create share on client machine and mount it in your host machine
Best Regards,
Dmitry.

Detecting a Citrix XenDesktop Session

I'm looking to determine if our application is running on a XenDesktop session rather than locally. Here is what I have found so far:
We currently have code to detect a Citrix XenApp session similar to the solution mentioned by Helge Klein in "API for Determining if App is Running on Citrix or Terminal Services".
Sadly that solution in a XenDesktop environment is returning back a WTSClientProtocolType of 0 which signifies a local console session.
In response to the same question Josh Weatherly mentioned checking the sessionname environment variable.
However a quick console check with echo %sessionname% on the XenDesktop environment returns back 'Console'.
From "Detect citrix “application mode”?" John Sibly suggested a solution for detecting a remote session (not Citrix in particular):
GetSystemMetrics(SM_REMOTESESSION) however returns 0 which also means that it is a local session.
Does anyone know of a way to detect that it is a XenDesktop session? So far as you can see all my attempts are returning that the session is a local console session.
I'm using XenDesktop Express 5.5, accessing the desktop using the Citrix Receiver Web Plug-In.
If you are using XenDesktop for VDI, then as far as the application is concerned, the application is executing locally. VDI, or virtual desktop infrastructure, consists of delivering the GUI from a full featured desktop operating system to a remote device. Typically, the desktop O/S executes in a virtual machine on a hypervisor in a data center, and the GUI is transmitted to the remote device using Citrix' ICA stack. For example, this happens in the pooled desktops scenario.
XenApp offers virtual desktops, which is a slightly different concept. Again, the desktop is delivered to a remote device using the ICA stack. However, the desktop is no longer running on a dedicated O/S. Rather, it is one of a number of user sessions on a single Windows Server. There may be any number of users logged on to that server. This places limits on the applications that can be run, which is why applications might want to know that they are on a multi-user O/S.
What you might try to do is determine whether the GUI is being delivered remotely using the ICA stack. A simple check would involve looking for the "ProticaService", which is responsible for implementing the ICA stack.
Alternatively, you may be trying to determine if your machine is running in a VM or native to a machine. Besides the pooled scenario described in the first paragraph, XenDesktop can deliver desktop running native. This overcomes limits on virtualision I/O devices such as graphics cards used by CAD applications. In this case, you need to rule out the presence of a VMM, or hypervisor.
I have updated my answer linked to in the question with a description of how to determine the remoting protocol type in XenDesktop sessions.
You need the (not really well documented) function WFGetActiveProtocol from Citrix' WFAPI SDK. Proceed as follows:
Download the SDK (link)
Install WFApiSDK64-65.msi
In your C++ project include wfapi.h and link to wfapi[64].lib
Use the undocumented function WFGetActiveProtocol
More detail and sample code here.

Collect EventLogs from remote XP machines

I want to collate EventLogs from different machines onto one machine. Is there any way that this can be done non-programatically using Windows XP?
I think that there is no automatic way to do that provided by system. You could use Remote Desktop or SSH to access machines, but You will have to connect and retrieve logs from every machine manually.
Of course You can make your own program to do this for You.

How do I remotely obtain a system's network shares and connections?

I'm looking for a way to obtain information similar to the following console applications, remotely:
net use
net share
netstat -ano
However, I need to be able to do this without running a 3rd party application on the system. This effectively rules out using psexec to execute the command remotely, because psexec would then be installed as a service.
I should add that I have administrative credentials on the remote system. I've considered using WMI's remote execution ability, but that requires me to write output to a file and then retrieve it. It's possible, but I'd like to know if anyone has a better way.
I am using Delphi 2010.
there are a couple Delphi WMI components that allow remote access. I have not used the remote options personally though.
MagWmi - http://www.magsys.co.uk/delphi/magwmi.asp (Delphi 2010 support, and free with source)
WMISet/NTSet - http://www.online-admin.com/ntset.html (TNTShare
Manages shared resources on a local computer and remote hosts. Using this component you can change list of shared devices, see files that have been opened by remote users, watch and terminate remote sessions opened to the destination computer, change list of mapped network drives. It is not free.)
GLibWMI - Found at Torry.net, home page not available. (Delphi 2010 support and Freeware with source). Not sure if its capable of remote access. I have not used it.
Hope this helps
I think the same as Logman.
You can access this information using WMI.
GLibWMI components can be found on this website (http://neftali.clubdelphi.com) or sourceforge (http://sourceforge.net/projects/glibwmi/).
The current version is 1.8b and has a component called SharedInfo with which you can get that information.
The source code is available so you can expand it to access other WMI classes if necessary.
Regards.
P.D: Sorry for my mistakes with english.
You can enumerate shares using the NetShareEnum function (headers are in the Jedi Apilib).
I assume there must be an api for the "net use" but I have never used it (check the WNet functions). Alternative is to use the EnumNetworkDrives method of the WshNetwork com object.
As for netstat I don't think it's possible to do that remotely (other than using some kind of method to spawn a process remotely).

Determine logged on user on a remote Windows machine

Is there a way to determine who is logged on to a particular (remote) machine given the IP address (or the workstation name) of the machine?
The machines in question are on an Active Directory Domain
The user running the script probably won't have any special rights on either their local or the remote machine
Operating system is Windows XP
Any programming language is fine but ideally
VBScript (yeah I know)
C#
Java
DOS Batch file
PSloggedon from SysInternals will provide this from a batch file, however the user would require admin access on the remote machine. I doubt you can get this information without Administrator access.
Difficult to do depending on the permissioning on the machine. One way is to query WMI on the remote machine and check the owner of the explorer.exe process.
You don't need admin access. Just use net apis.
ask on news://194.177.96.26/comp.os.ms-windows.programmer.win32
where it's a FAQ

Resources