Batch script/PowerShell advanced conditionals implementation - windows

My question is in regards to how I should go about implementing a batch script/PowerShell cmdlet on Windows that does the following:
When a browser window is open that has the window/page title "Blank" then send the "tab" key, send login credentials to text boxes on webpage and then send the "enter" key.
I found this article (Automatic login to a website on windows 7/Chrome via batch file) about sending login credentials in a web browser, which is very similar to what I want to do, however I want the script to ONLY run if the browser is already open and has a specific value in the window title. This is for an authentication system for the network running on my server that asks me to re-login every 30 days, and will open up a browser window automatically when it needs me to login. So, when it opens the window, I want the script to be able to automatically login for me. Since the server is unattended (GUI wise), I want the re-authentication to occur automatically. My plan would be to have this set as a scheduled task and have it run nightly, to verify that the system is still authenticated. If the system is not authenticated, I want the batch file/cmdlet to login for me.
I did some research and found information about using conditions for batch files, but I couldn't find any information about how I would use the window title or any other program attribute to base my conditional off of.
People have suggested using PowerShell, so I am totally open to that as well if you have a recommendation for implementation via that route.
Please let me know if you need any further information, or have any questions.

You can do it with Powershell.
Here is an example for getting the window name, it should be possible to use it to detect Internet explorer to.
$selectedWindows = get-process | Where-Object { $_.MainWindowTitle -match "Editor"}
in $selectedWindows there are all windows which title matches "Editor"
Now you can get the $selectedWindows in front and use sendKeys to work with the Window.
For getting the Window activated and in front i have a short example here:
http://pastecode.org/index.php/view/22992037

Related

windows 11 url scheme not opening application compiled by golang

I want to create an OAuth registration/login process for my non-web application written in golang. For that, when my application is opened, I open the browser with an OAuth URL and after the successful authenitcation, the redirect_uri is set to my own url scheme myapp:// to reopen my application and pass the authentication token to it.
I managed to let my golang application register it's url scheme itself with Handling url schemes with golang?
and wenn I type in my scheme like myapp:// the browser prompts me as expected if I want to open my application.
But when I click "yes open it" it just opens a cmd very shortly (or nothing when I compile it with go build -ldflags -Hwindowsgui) and nothing else happens and I also don't get any logfiles written by my application, so I am pretty sure that nothing is executed.
If I change the executeable path in the registry of the scheme to open something like C:\Windows\System32\notepad.exe it opens the Windows editor as expected.
I also tried to put my application in a Windows-folder but still nothing is executed.
I can't find any ressource on the internet regarding this problem.
Do I need to do something security wise so my application is executed, because it seems that Windows blocks the execution of my application?
One guess would be that my freshly compiled golang executable is not digital signed and therefor not executed because of security risks? Or is there something else I'm missing?
Or is there another way to create url schemes for applications in local development?
Thanks for any help!

Hide username completely while the machine is auto logging in

I have a unique requirement, I have setup a PC which would auto login to a particular user id say 'autologinuser', when ever we switch on the PC it would automatically logs into 'autologinuser' as configured.
During the login, it would show which using is getting logged in with welcome text under it.
I would like to hide the user name and don't want to visible during auto login process, only windows text should be visible.
Can this be possible?
Thanks & Regards,
-Anil Katta
Looks like windows operating system don't provide this feature at this point of time, and there is no specific registry to do so.
May be this feature good to expect in future releases.

Firefox extension: Secret Agent - User Agent String Randomizer - Application testing

Extension Link: https://www.dephormation.org.uk/?page=81
This plugin is great. It has one problem though, on pages that use AJAX to make http requests, it switches the user agent for each request and confuses many ajax applications.
What I want to do is figure out where the preferences for this plugin are saved. Particularly, where all the User-Agent Strings that are currently being used are located. I would like to do this so that I could edit these settings outside of firefox before I open the browser so as to "hot swap" one user agent string for each browsing session at a time. I have looked through all kinds of .sqlite databases in my firefox profile but still haven't found the information.
I am using Watir-Webdriver with ruby to application test.
As Mr Palant said... simply changing general.useragent.override would achieve what you want.
Type about:config in the address bar, accept the warning, and filter on useragent and you'll see the setting.
I gather (but haven't tested) this preference may not affect the user agent presented to client side Javascript code. So if your Ajax code references navigator.useragent you might find the real user agent is returned despite your override setting.
Pete (author of SecretAgent).
www.secretagent.org.uk
PS See also
https://developer.mozilla.org/en/Document_Object_Model_%28DOM%29/window.navigator.userAgent
You don't need an add-on for that - changing general.useragent.override preference (create it if not present yet) is enough to set a different user agent string. In Firefox you can do it under about:config, when Firefox isn't running you can add this preference to the file prefs.js in the Firefox profile.

run kiosk .app at startup in mac

i want to startup an application (.app) at startup in a GUEST ACCOUNT in mac(snow leopard). THe app disables all shortcuts and dock as well(using kiosk). The user must enter a token number to login . I have made the app but i cant force every other service to stop . If i put it in boot sequence through system->services, the app does not come at front. instead it is launched but is in the doc and i have to left click it to launch it in front. :(
(i want to do this programmatically by editing the boot sequence of mac OS )
Problem is I used kiosk and it only works when my application is in front.
So i need to perform this that i cant figure out.
1) run my app only(after login and NO OTHER SERVICE) and rest of the mac should boot once my app has exited.
Thanks in advance
for any help that u can provide
I already tried to tell you in your previous question that you are probably going the wrong way. If you put something into a user´s login items, it can easily be deactivated by holding "shift" while logging in (which you probably do not want); also, completely hacking your Mac OS Startup routine (if it can be done) is a bit too much in my eyes.
You should seriously consider
using a login/policy banner (realised for example here) which would pop up over the loginwindow (so a user has to agree)
using a loginwindow hook combined with a logout hook to change the user password (e.g. based on a hidden password-list and using dscl -passwd or pwpolicy) once the user logs out. This way you should be able to generate passwords based on a list and validate them (token system)
Yours, Asmus
P.S.: on your previous question you commented on mipadi´s answer that you have found a great link, thought it´s missing. Could you maybe add this, as this might be interesting for other people in the future.

Session 0 Isolation

Vista puts out a new security preventing Session 0 from accessing hardware like the video card, and the user no longer logs into session 0. I know this means that I cannot show the user a GUI, however, does that also mean I can't show one at all? The way my code is set up right now, it would be more work to make it command line only, however if I can use my existing code and just programmatically manage the GUI it would take a lot less code.
Is this possible?
The article from MSDN says this:
• A service attempts to create a user interface (UI), such as a dialog box, in Session 0. Because the user is not running in Session 0, he or she never sees the UI and therefore cannot provide the input that the service is looking for. The service appears to stop functioning because it is waiting for a user response that does not occur.
Which makes me think it is possible to have an automated UI, but someone told me that you couldn't use SendKeys with a service because it was disabled in Session 0.
EDIT: I don't actually need to show the user the GUI
You can show one; it just doesn't show up.
There is a little notification in the taskbar about there being a GUI window and a way to switch to it.
Anyway, there actually is a TerminalServices API command to switch active session that you could call if you really needed it to show up.
You can write a separate process which provides the UI for your service process. The communication between your UI and service process can be done in various ways (search the web for "inter process communication" or "IPC").
Your service can have a GUI. It's simply that no human will ever see it. As the MSDN quote suggests, a service can display a dialog box. The call to MessageBox won't fail; it just won't ever return — there won't be anyone to press its buttons.
I'm not sure what you mean by wanting to "manage the GUI." Do you actually mean pretending to send input to the controls, as with SendInput? I see no reason that it wouldn't be possible; you'd be injecting input into your own program's queue, after all, and SendInput's Vista-specific warnings don't say anything about that. But I think you'd be making things much more complicated than they need to be. Revisit the idea to alter your program to have no UI at all. (That's not the same as having a console program. Consoles are UI.)
Instead of simulating the mouse messages necessary to click a button, for instance, eliminate the middle-man and simply call directly the function that the button-click event would have called.

Resources