Use an existing Login (VBS) script and plug (%computer%) in, then trim all but the the last 5 caracters and plug that into another function - wsh

I am brand new to VB scripting. Work is making me explore this new avenue. I have always tried to avoid scripting whether it was VB or cmd (windows) because I am a strong believer of Group Policy and not everybody knows the ins and outs of scripting.
To my question or my end result function:
I understand there are many parts of a script I must assemble to do what I want it to do. What I am trying to accomplish is this; We have a windows 2008 domain. our environment is windows XP SP3 and windows 7. There are a bank of PCs that I must turn on Autologin with different user accounts. The bank of PCs have a specific computer name and a specific user account associated with it. For example, computer name BC-R312-10056 is associated to user account domain\10056 meaning the least 5 characters of the computer name is the allowed user account to log in to the PC and also the password is the same as the username. My task is to run a VB script to first grab the computer name, then strip all characters to only the last 5 characters, then plug that value in to the autologin script in the "username" and "password" (create variables) and presto, slap that into runonce and all computers that this script will run will have autologin enabled with the user name and password uniquely set to last 5 characters of computer name. I hope this makes sense since I have been struggling with this for a few weeks.I have found snippets and already made scripts and trying to modify and combine them to make them work for me but I am just have a hard time figuring out how to strip the characters and pass them into a variable to have them called up in the auto log in script.
I am looking for just guidance since this is my chance to learn this VB lingo and get smart.

To get the last 5 characters of the computer name use
strUserName = right(strComputerName, 5)
you can get the computer name with
Set objNetwork = CreateObject("Wscript.Network")
strComputerName = objNetwork.ComputerName

Related

Alternative to custom protocols (URI schemes)

I have been extensively using a custom protocol on all our internal apps to open any type of document (CAD, CAM, PDF, etc.), to open File Explorer and select a specific file, and to run other applications.
Years ago I defined one myprotocol protocol that executes C:\Windows\System32\wscript.exe passing the name of my VBScript and whatever argument each request has. The first argument passed to the script describe the type of action (OpenDocument, ShowFileInFileExplorer, ExportBOM, etc.), the following arguments are passed to the action.
Everything worked well until last year, when wscript.exe stopped working (see here for details). I fixed that problem by copying it to wscript2.exe. Creating a copy is now a step in the standard configuration of all our computers and using wscript2.exe is now the official configuration of our custom protocol. (Our anti-virus customer support couldn't find anything that interacts with wscript.exe).
Today, after building a new computer, we found out that:
Firefox doesn't see wscript2.exe. If I click on a custom protocol link, then click on the browse button and open the folder, I only see a small subset of .exe files, which includes wscript.exe, but doesn't include wscript2.exe (I don't know how recent this problem is because I don't personally use FireFox).
Firefox sees wscript.exe, but it still doesn't work (same behavior as described in my previous post linked above)
Chrome works with wscript2.exe, but now it always asks for confirmation. According to this article this seems to be the new approach, and things could change again soon. Clicking on a confirmation box every time is a big no-no with my users. This would slow down many workflows that require quickly clicking hundreds of links on a page and, for example, look at a CAD application zooming to one geometry in a large drawing.
I already fixed one problem last year, I am dealing with another one now, and reading that article scares me and makes me think that more problems will arise soon.
So here is the question: is there an alternative to using custom protocols?
I am not working on a web app for public consumption. My custom protocol requires the VBScript file, the applications that the script uses and tons of network shared folders. They are only used in our internal network and the computers that use them are manually configured.
First of all, that's super risky even if it's on internal network only. Unless computers/users/browsers are locked out of internet, it is possible that someone guesses or finds out your protocol's name, sends link to someone in your company and causes a lot of trouble (possibly loss too).
Anyway...
Since you are controlling software on all of the computers, you could add a mini-server on every machine, listening to localhost only, that simply calls your script. Then define host like secret.myprotocol to point to that server, e.g., localhost:1234.
Just to lessen potential problems a bit, local server would use HTTPS only, with proper certificate, HSTS and HPKP set to a very long time (since you control software, you can refresh those when needed). The last two, just in case someone tries to setup the same domain and, for whatever reason, host override doesn't work and user ends up calling a hostile server.
So, links would have to change from myprotocol://whatever to https://secret.myprotocol/whatever.
It does introduce new attack surface ("mini-server"), but should be easy enough to implement, to minimize size of that surface :). "Mini-server" does not even have to be real www server, a simple script that can listen on socket and call wscript.exe would do (unless you need to pass more info to it).
Real server has more code that can have bugs in it, but also allows to add more things, for example a "pass through" page, that shows info "Opening document X in 3 seconds..." and a "cancel" button.
It could also require session login of some kind (just to be sure it's user who requests action, and not something else).
The title of this blog post says it all: Browser Architecture: Web-to-App Communication Overview.
It describes a list of Web-to-App Communication techniques and links to dedicated posts for some of them.
The first in the list is Application Protocols, which I have been using for years already, and it started to crumble in the last year or so (hence my question).
The fifth is Local Web Server, which is the one described by ahwayakchih.
UPDATE (this update follows the update on the blog post above mentioned)
Apparently I wasn't the only one thinking that this change in behavior was a regression, so a workaround has been issued: the old behavior (showing a checkbox that allows to remember the answer) can be restored by adding these keys to the registry:
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge]
"ExternalProtocolDialogShowAlwaysOpenCheckbox"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome]
"ExternalProtocolDialogShowAlwaysOpenCheckbox"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Chromium]
"ExternalProtocolDialogShowAlwaysOpenCheckbox"=dword:00000001

Bot that DM's chosen keywords to chosen users

What I'm looking to do is to create a bot that will be in a private channel only accessible to the admins. All users will have keywords that they have chosen prior and will get notified about. Lets say user 'x', has chosen "brown" as a keyword, when a comment comes into the private channel containing the keyword "brown", I want the bot to send that message, copy and pasted, directly to the user 'x' that chose that keyword. So basically I would like to know how to make a bot they has a keyword feature that copies that exact message and dm's that user that chose that keyword.
Is this possible, if so how would I go about it?
Thanks
Most of the bots i have made, i have used python.
Selenium web-driver is fairly easy to use if you intend on scraping the data from HTML pages.
In any case, you could use flask and mysql.connector to create the user interface and login for control of the bot.
If there are any other things you want it to do, i'm sure there's a library out there to do it, or you could just launch some kind of macro or script on the server.
Be very careful of permissions and whatnot if you intend on allowing remote control of other scripts and data on the server though.

Running automated test for 24 hours with robot framework and selenium2library on jenkins

I have a test case for activation account which have 2 scenarios.
First TC is where user creates an account and gets activation link
in email and he goes to email and clicks on the link and his account
is activated.
The other TC is wherein i have to check the case where the link is
dead after 24 hours. Now i am using selenium2library and
robotframework for my test cases.
I am not able to find a way for second TC wherein i have to pause the running of TC for 24 hours before making a call to email and get the expired link. I tried going to DB and changing the timestamp of the link by -24 hours but touching DB while running TC is not a good option.
Does anyone knows a workaround for this? Is there any selenium2keyword etc to achieve this?
I think I would actually look to break down your scenario into a few different cases and determine the best way to approach each case.
TC1. Create new account and get activation link - Maybe selenium? I would actually prefer if possible to do this via and api or database call if that is where the real logic is. Then I would look to capture the URL before it is even sent out by email. It would be particularly helpful is this was a return value from an API or a value in the db. Otherwise if you end up having to go through the hassle of logging into an email system and getting it from there. The verification on this is that the URL is generated.
TC2. Setup a new account or use an existing account / URL pair that has been reset to an "pre activation" state. If you use Selenium here there is no real need for a mouse click event. Simply navigate to the URL ie (driver.get("myactivationURL")). You can then verify either in the UI a successful activation or query the db that the activation is successful.
TC3. You could do an A and B for this. One with and activated account and one with a non activated account with timestamp older than 24 hours. Verify that in both cases if the activation link is sent it gives the proper messaging and the values in the db are still correct depending on the previous state of the account.
This would be faster and more reliable than trying to wait 24 hours during the running of one long test. It would also mean you could test discrete parts of the process.
For testing purposes, would it be possible to set the expiration time of the link to something more testable, such as five minutes? It should be reasonable to assume that if it is configured to expire in five minutes and it does, then if it is configured for twenty-four hours it will, too.
Of course, you would definitely want to follow this test up with a manual check at some point. Proper testing doesn't require 100% automation. Some tests are best left to humans at a keyboard.

How to prevent user changing system date/time (in Windows 7)?

Having googled, the general advice is to create a standard, non-administrator account.
I just tried that. I only had one account, my own, which is an administrator and then created a second (not the Guest account). I logged out of my own account and into the new one and tried to change the time. Windows 7 popped up a box asking if my main account would allow this (and prompting for its password).
I have been told "it shall not be possible to change system date/time". I intended to deliver a PC with only a standard account and my s/w, but can't (I think) prevent the user from creating an administrative account and changing date/time.
Can I prevent this programatially from Delphi, or do I just have to say that if the user wants to be destructive I can't prevent it?
Generally this kind of restrictions are set using the Windows Group Policy
From delphi you can use the Group Policy API or the RSoP WMI Classes.
In your application, you can actually detect user changing system time while your application is running.
You will receive WM_TIMECHANGE when system time change.
When startup, you can saved the gettickcount (As StartTickCount) and now (As StartTime). When checking, you can check if the different between tickcount and the different between time match (allow a small discrepancy) and know the different. However, if the user change system time away from your application, this trick do not work. Maybe you can have a service which is auto start checking for this.
If you need to change back to original time, here is some resources :
CHANGE the system TIME
btw, in OS level, a normal user cannot create an admin user.

How do I set the correct decimal separator in IIS 6.0?

I hope you can help me here... I have a conflict with the decimal separator on my host's dedicated server. The DB (SQL SERVER 2005) uses dot as decimal separator. As a fact, if you query it directly using SQL Server Management you would get dots. However, when the application (.NET C# MVC 2) is running it uses comma instead of dot. I think it's a problem on the server because here in the tests server it doesn't happen.
I've been reading it might be related to regional and time zone configuration but I've already tried setting the server's time zone and regional zone to the U.S. and it still doesn't work.
The main problem for this that I have is because all views which use jquery are not working correctly, and the main issue is because many decimal numbers are set as required fields. Reprogramming it all is an option but I expect to find the way to set everything up correctly due to the size of the app.
Any help will be VERY apprecciated.
Thanks in advance,
Regards.
Regional settings are user specific. This means changing them in control panel results in changing them for the current user. But your application does not use the current user, so you need to run regedit to modify the registry (or use a script).
You need to update the regional settings of the profile running your application.
The key for decimal separator is HKEY_USERS\SID\Control Panel\International\iCurrDigits where SID is the unique identifier of the user.
With this link you can find the SID of the related user.

Resources