A vbscript to find windows version name and the service pack - vbscript

What's the simplest way to find out which version of Windows, and which service pack, is running on a computer with VBScript?
For example I'd want to know Windows XP and Service Pack 3.

An easy way of doing this is to use the WMI class Win32_OperatingSystem which has the properties ServicePackMajorVersion, ServicePackMinorVersion, Name and Version. You can find samples here: WMI Tasks: Operating Systems
The data you get back might not be in the exact format that you want though so you might need to have some kind of lookup table to make it look exactly right.

Related

Detect Antivirus through WMI

I have come up with a situation in which an installed antivirus is not detected by wmic or it's equivalent cmdlet. The system where I am having this issue is a windows server 2016 and the antivirus is SEP (Symantec Endpoint Protection)
While doing some research I have found two possible explanations for this, but as far as I understood, these answers are pretty different, actually could even be complementary. Since I am a newcomer to WMI I would like some clarification about them.
The command I am using for retrieving the information is:
wmic /NAMESPACE:\\root\SecurityCenter2 path antivirusproduct GET ...
The first explanation1 I found is that the antivirusproduct class is not defined in server versions of windows which fits my problem since my machine is a windows server and I have tried the same command on a Win10 machine and it works.
The second explanation2 talks about the fact that in order to detect the antivirus through WMI it has to be registered on the Windows Security Center.
Having said that the main questions are:
Is the antivirusprocut class defined by the Windows Security Center provider, actually, does WSC have a WMI provider. If not which WMI provider is defining this class. I have been looking at the list of providers in the reference documentation3 and there doesn't seem to be a provider defining this so I assume this must be set by a provider coming from a third party software, hence the guess about WSC.
Regardless of the provider why would a class be defined on windows desktop versions and not on a server ones.
Any clarification is appreciated.
1 Detecting anti-virus on Windows with WMI - which namespace?
2 https://support.moonpoint.com/os/windows/commands/wmic/determine-antivirus.php
3 https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-providers

cannot create windows cluster file share using powershell/wmi

The win32_clustershare does not have a Create method on win2008r2? How does one create file shares using ideally wmi?
I thought the Win32_ClusterShare class was read only, but could be mistaken.
To do it without WMI, you can use the cmdlets in the FailoverClusters module, but you'll probably have to install Windows Management Framework 3 or (preferably) WMF 4 on your Windows 2008 R2 machine since these cmdlets aren't available in Powershell 2.0.
With 3.0+, you should be able to use Add-ClusterResource and the related cmdlets.
Apparently the win32_clustershare.create does not work as expected and is broken. Previously this class was absent altogether from windows as indicated here-
http://support.microsoft.com/kb/971403
Apparently Using win32_share does the needful even for clusters. I confirmed in HKLM\Cluster\Resources that the share is properly registered in the cluster.
Apparently windows is able to determine that the share upon creation is properly associated with a clustered disk.
I know I am not calling the win32_clustershare wrong, because I confirmed that the parameters are identical across the 2 wmi classes.
This is evident in inspecting both
(get-cimclass -ClassName win32_share).CimClassMethods["Create"].Parameters |fl *
(get-cimclass -ClassName win32_clustershare).CimClassMethods["Create"].Parameters |fl *
If you are using Windows Server 2012 R2/Windows 8.1, you can use the new and much improved SMB PowerShell modules. Have a look at https://technet.microsoft.com/en-us/library/jj635726(v=wps.630).aspx and http://windowsitpro.com/powershell/managing-file-shares-windows-powershell

Searching for srvany.exe from Windows 7 Resource Kit: is this actual software or just a book?

I'm looking for a version of the Windows Resource Kit supported on Windows 7. But I'm having a hard time finding a download location or any information on where to get that software from (e.g. installation CDs for the OS or IDE).
When searching for "windows 7 resource kit" on Google, I get a lot of results for this book from Microsoft Press:
http://www.microsoft.com/learning/en/us/book.aspx?id=13811
Do I need to buy this book to get access to the software or is there another way? I just need one executable, srvany.exe, from the resource kit. I'm wondering, does this software actually exist?
srvany.exe is in Windows 2003 Resource kit tools. This page says that it will work on Windows 7.
http://www.technlg.net/windows/download-windows-resource-kit-tools/
You may also want to add ";C:\Program Files\Windows Resource Kits\Tools" or
";C:\Program Files\Windows Resource Kits (x84)\Tools" to you path in the Environment Variables options to use it with Command Prompt.
As long as you are pretending to use an old and outdated program like srvany on Windows 7, you must know about the possible disadvantages of it:
SrvAny disadvantages in modern Windows (extracted from AlwaysUp FAQ, so they are trying to sell you their product ;-) ).
I think there are better options:
1.- The SC command (sc create MyService).
2.- The (not free, but makes things a lot easier) AlwaysUp tool, that add multiple features (like log, statistics, checking&restarting your service, email alerts... etc). As long as it has command-line management, I think it is appropriate to refer it here.
EDIT-1: The AlwaysUp FAQ is supposed to have some outdatings, i.e: it reports SrvAny as non working for Windows7/8 (thanks, #shelleybutterfly).
You can find the "Remote Server Administration Tools for Windows 7 with Service Pack 1 (SP1)" here http://www.microsoft.com/en-us/download/details.aspx?id=7887

is there any tool or software that will give the list of dlls and registry data that an application is using?

Is there any tool that give the list of dlls, registry loc and other files/data that an application need when it gets launched?
I basically need this info to know what are all such files/data that IE6 uses when it get launched in windows XP? So that, I would try to get the answer why versions of IE are tightly coupled with windows OS and also we are trying an experiment how to run IE6 on vista or win7? Not thru existing XP mode of windows 7. But like an virtualized application?
Thanks for any inputs.
procmon http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
For DLL dependency walker
At the command line: tasklist /M
IE6 is part of the OS, and as such has dependencies, either directly or indirectly, on basically everything in %windir%/system32. You might be able to find a subset that "works good enough" but you'll always have something that is a little wonky because of some mis-matched DLLs.

Registry key for Install update and hotfix information on windows 7

I am working on windows 7 support. In my application I want to gather installed updates and patches. Currently I am gathering it from WIn32_QuickFixEngineering. But it is not giving information for InstalledSDate , Description.
I need to get this either from registry or API (C++ application). In other operating system like XP, 2k3 registry keys are-
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates
But these are not present on windows 7.
Can any one give thought on this..
I was also trying to figure out where the registry key for "Hotfix" had moved to.
I am setting up a debug symbol server on Windows 7. While I was following instructions from the book Debugging Applications for Microsoft ... Windows (by John Robbins), I was getting the error "Unable to enumerate the hot fix key" from a piece of vbscript code that Mr. Robbins recommends.
I realized that the vbs code is looking for the reg key SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix, which is not present on Windows 7.
While searching for a substitute key (or any other alternative), I found some helpful information here: http://forums.cnet.com/5208-12546_102-0.html?threadID=327588
The command shown on that cnet forum was a viable substitute in my case:
wmic qfe list full
shown at the cmd.exe prompt:
C:\Users\All Users>wmic qfe list full
Windows Update Agent API
Not sure if this is your issue: InstallOn properties for QFEs are sometimes stored as 64-bit, hexdecimal timestamps. To use this as a date:
Check first whether it is a hexadecimal value. If not, it is likely a regular date value.
Then, (in C#) use this to convert it to a DateTime:
DateTime.FromFileTimeUtc( Int64.Parse(<InstallOn>, System.Globalization.NumberStyles.AllowHexSpecifier));
try looking here:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages]

Resources