Programmatically check whether Windows 7 is activated - c#

Background:
I am creating system images that will be loaded onto several workstations. Windows activation will occur after the images are loaded onto the workstation. These computers will not be connected to the Internet and will be activated over the phone.
Question:
I would like to check programmatically if Windows 7 is activated or not, so that our software will not run if Windows 7 is not activated. Our software is written in C#.

The Software Licensing API - SLIAPI, take at look at SLIsGenuineLocal(). (Replaces LegitCheck)

You can run "Slmgr.vbs" on the machine and then redirect the output to check.
System.Diagnostics.Process.Start(#"cscript Slmgr.vbs > D:\\log.txt");
This will return all the information you need. Not the cleanest way to do it though.

You may check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Activation Technologies\AdminObject\Store\TotalValidations and see if it is 1. This may not be the definative way to verify activation, but you should at least be abel to see if it was validated.

You can use this reference: https://github.com/Marko97IT/CWA
In the README.md you can find the download link.

Not sure if it applies to Win7, but I found a post that checks XP for activation using a Win32_WindowsProductActivation class.
I'll build a test one on my machine (x64 Win7) and see if it returns activated or not, but at least gives you something to try out in the mean time.
EDIT (wish I kept reading the docs) A comment on that class page mentions that this class, on Win 7 and other versions) appears to be replaced with the Software Licensing Classes. I'll see if I can get a working result.

Related

Is there an alternative for the SendKeys class that will work with Windows 10

I cannot find any definitive information anywhere but the System.Windows.Forms.SendKeys class appears to have been blocked / disabled / depreciated in Windows 10.
I wrote a demo program that monitors the users keystrokes and if a user enters a known code it will pop up a form and then go off to a document database and return various strings (company names / addresses / contact lists etc) and replace the typed code with the retrieved string. SendWait is used to send the retrieved strings to whatever program typed the code.
I built the program on the companies Windows 7 desktops but when I ran it on my personal Windows 10 system it didn't work. A lot of reading later and I feel like a complete idiot but I cant let them take this project any further knowing that they wont be on Win7 forever.
So my question is has this sort of functionality definitely been disabled in Windows 10 or is there another way or method I would be able to use to achieve this behavior of inserting text into running programs.
Any help appreciated.
I found this Forum-Thread:
https://www.tenforums.com/software-apps/49635-sendkeys-not-working-windows-10-a.html
SendKeys is Blocked in W10. In W8.1 it still works.
There are other anoying things, like not allowing App to Read or Wright to Drive C. The "file" is there but W10 "hides" it or simply not allowing to access it.
There are Netwok problems also, not allowing App to work on LAN environement.
Well, my opinion is that W10 behaves like Malware to user PC. Useless.
They had no solution.
It looks as if Sendkeys works with some apps and not others. I can automate an older app by sending it keystrokes but newer apps like Chrome don't respond. The inconsistent behavior has seriously messed up scripts that worked fine under Win 7.
I have not found any official documentation that says that Sendkeys has been deprecated so the inconsistency looks to be a Windows 10 bug.

How to get verb for pin to taskbar in Windows 10?

I'm trying to pin an exe to taskbar in windows 10. But I'm not able to find verb for pin/unpin to taskbar.
I have tried the same code on windows 7 and 8.1 machine, its working fine, but its not working on windows 10 machine.
VB Code:
Dim ShellApp, Desktop
ShellApp = CreateObject("Shell.Application")
Desktop = ShellApp.NameSpace("C:\ProgramData\ABC.exe").Parsename("ABC.exe").invokeverb("taskbarpin")
This issue was reported already (see also SO question).
And one possible solution (on the same page, re-posting it here):
Posted by Misha Rudiy on 11/5/2015 at 7:30 AM
For new OS installs you can still pin to the taskbar via the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\TBDEn registry key.
Example: In an SCCM Task Sequence, I have a batch script that runs after the "Setup Windows and Configuration Manager" step that basically contains reg-adds.
Syntax (REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\TBDEn" /v SBOEM0 /t REG_EXPAND_SZ /d "%%ALLUSERSPROFILE%%\Microsoft\Windows\Start Menu\Programs\Mozilla Firefox.lnk" /f)
You can add additional links by adding values and incrementing SBOEM0 to SBOEM1 etc.
Thanks to Wayne Ye http://www.codeproject.com/Articles/185512/Programmatically-PIN-shortcut-onto-Taskbar-on-Win7.aspx for pointing this method out back in 2011.
Somethings to note, there seems to be little public documentation on this. It most likely only works as a post imaging step (see my reference to SCCM), but I am not 100% sure. The above mentioned site states that it takes place during the DASH process. I wasn't able to find any documentation on how\when a DASH process works with Windows OSes. This may be information that is only privy to OEMS.

Hide/Disable Start Button in Windows 8.1

I've searched a lot these days to find a way to programmatically hide or disable the start button in Windows 8.1, but could not find any useful information
Is there any way to do this? Either with C# or with some registry-keys...
A short explanation why I need to hide the button:
We have a .NET Desktop Application which runs on WinXP, Vista and 7 in a self-made kiosk mode. Now we have to get it running in Win8 (8.1) but as expected, the new Start-Menu (Metro, Modern UI, whatever you call it) is always there.
I already managed to disable the Hot Corners, but the Start Button in the left corner still appears when you move you mouse over it, and it also starts the Metro - what we don't want.
Any help would be appreciated!
It seems that there is no such way...
But you could use a third party tool like one of these http://lifehacker.com/how-can-i-hide-the-start-button-in-windows-8-1-1478012124.
This question belongs on SuperUser, since it's not code related, but I'll have a go at it.. You should create a system account with an assigned access. Here, read these two articles: first second
According to these articles, it shouldn't take you more than 5 minutes to achieve what you want.
... find a way to programmatically hide or disable the start button in Windows 8.1...
See Registry Key Controlling Start Button in Windows 8.1? on SuperUser. According to one commentor, there is no simple fix like a registry key. Tools like 7+ Taskbar Tweaker inject a DLL into explorer hook/subclass/redirect some of its methods.
If you are going to write your own DLL and inject it into Explorer, then you might want to take a look at Microsoft's Detours Library. I've used it in the past and its actually easy to use. The description from the website: Detours intercepts Win32 functions by re-writing the in-memory code for target functions. The Detours package also contains utilities to attach arbitrary DLLs and data segments to any Win32 binary.

Run Application at window Login Screen

I have made C# winform keyboard that i need to run at windows login screen so that user can enter password to specific user account. the computer which is using this application doses not have physical kb.
i came across GINA some say this is the solution but there are discussions that it is only supports till win XP win vista and 7 has different scheme.
any ideas?
I don't think is this something you could write in .NET, per this thread. But GINA was replaced with Credential Providers.
There is a sample here.
Why not use the onscreen keyboard?
http://forums.techarena.in/customize-desktop/1131979.htm
If you're using windows vista or or windows 7 it already has an on screen keyboard. Just choose the "Ease of Access" icon and then check "Type without the keyboard"
I know this question is old but for those looking for a super quick and dirty way with C# to do this, and not use C++ or C:
Registry:
Modify HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\magnify.exe (Add it if you need to) and then add a String value to the key:
Debugger
Make Debugger value equal to the path to the exe you want to run. Just tested this solution with a C# application on Windows 7 and 10 and both work as expected (You must launch the Magnifier with Win+U, or use Easy of access center.
Here is the output of my registry for this key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\magnify.exe]
"Debugger"="C:\\Path\\to\\exe\\application.exe"

Winform application doesn't run properly

In my home and work pc's and in one friend of mine's it runs just ok, but when i sent it to someone else it 'loads' for 10 seconds responseless, then there is an error:
alt text http://dl.dropbox.com/u/3045472/Sem%20t%C3%ADtulo-1.png
Since it works on at least four computers, i assume the program itself is just ok (same exact EXE).
What could be happening ?
info:
C#
.net 3.5
worked on Windows 7 32/64 bits,
windows XP and vista.
does some threading simple stuff, but
it doesn't even open the form, and it
doesn't open up running either, so
the functionality is irrelevant.
There are infinitely many possible answers. So I will give you the way to figure it out instead.
Add a handler for the event: AppDomain.CurrentDomain.UnhandledException of type UnhandledExceptionEventHandler.
You will be able to see the reason for the crash. It's probably best to write it out to a file somewhere anyway.
The first check is to make sure the .NET framework is already installed on the target machine, then make use of Brian's suggestion (which will not even work if the framework is not installed!).

Categories