Will workndows script host run script in Chrome browser - wsh

Dim Wsh
Set objShell =CreateObject("WScript.Shell")
Set objExec = objShell.Exec("C:\Program Files\Google\Chrome\Application\chrome.exe https://<internal company VPN address>")
Wscript.Sleep 1000
objShell.AppActivate("<Title page>")
Wscript.Sleep 1000
Wsh.SendKeys "<username>"
Wscript.Sleep 1000
Wsh.SendKeys "{TAB}"
Wsh.Sendkeys "<password>"
Wscript.Sleep 1000
Wsh.SendKeys "{ENTER}"
I am getting a WSH "objectRequired ." runtime error on trying to run the following script.
What happens is :
Chrome Browser opens up correctly to Chrome and the
included https address ( internal vpn address )
However it stops with the stated runtime error just prior to the
because the cursor is not focused in that text box.
My understanding is that WSH cannot treat Chrome browser and an object and that
java script would work however I need advice or starte code to help me along.
Objective is to
1 . set focus on the username text box then
tab to password text box then hit the
enter key and log in

Related

Wscript and Tor Browser

so I'm new to all of this and I need to know if wscripts would work with tor browser, and what would that code look like. i need the bot to go to a website and click a button and then go to another different website, and all on tor browser. I was wonder if that's possible and what I would have to write for it to work.
No. Tor Browser uses Firefox which does not support Microsoft VBScript, and the default security settings may not permit it even if it did.
The only way it may work is if a user configures an old version of Internet Explorer to use Tor's SOCKS proxy. Edge doesn't support VBScript at all.
This article also points out that Microsoft killed VBScript by default in IE in August 2019. What is VBScript, and Why Did Microsoft Just Kill It?
Try something like this:
Option Explicit
Dim s
Set s = CreateObject("WScript.Shell")
s.Run "torbrowsername"
WScript.Sleep (16000)
s.SendKeys "^{T}"
WScript.Sleep (1000)
s.SendKeys "website1.example"
s.SendKeys "{ENTER}"
WScript.Sleep (4000)
s.SendKeys "{TAB}"
s.SendKeys "{SPACE}"
WScript.Sleep (4000)
s.SendKeys "^{T}"
s.SendKeys "website2.example"
s.SendKeys "{ENTER}"

What would cause InternetExplorerMedium to work on one machine but not another?

I have a VBA script in Access that logs onto a website and downloads some data, I built it using a laptop and use the code of
Dim objIE As InternetExplorerMedium 'special object variable representing the IE browser
Dim aEle As HTMLLinkElement 'special object variable for an <a> (link) element
Dim element As HTMLLinkElement
Set objIE = New InternetExplorerMedium
On Error GoTo Errorhandler
objIE.Visible = False
DoCmd.Hourglass (True) 'navigate IE to this web page
objIE.navigate www.google.com ' google just for example
Then it inputs the login info into the proper boxes and logs in.
Which works fine, however I installed this front end on another user's PC and it no longer works, it just opens the page but fills in no info.
However, if I change,
Set objIE = New InternetExplorerMedium
to
Set objIE = CreateObject("InternetExplorer.Application")
then it works on their PC. But this change does not work on my laptop.
What would cause this issue and how could I standardize this so I can install on any windows machine without worry of this occurring.
Notes:
We are both on the company LAN, and both are running windows 10 Home.
It was something incredibly simple, I just had to add the website I was accessing as a trusted site in Internet Explorer.

VBS script fails to run when called as a Scheduled Task in Windows 8

I have created a VBS script that runs perfectly fine when manually run on Windows 8 Home computers even on IDs that have no admin rights. This same script fails repeatedly no matter what user credentials I've used to run it through a scheduled task on computer start up. I've tried the system, admin, and unprivileged user IDs that are on the machine all with no success.
This same VBS script has no issues at all being run from a scheduled task on multiple Windows 7, and Windows 8.1 Home and Professional machines.
This script attempts to successfully ping a website, and upon successful ping will POST data to the web page with the current time of the local computer.
boolExitFlag = False
Do
If Ping("HOSTNAME") Then
Call pingsuccess
boolExitFlag = True
End If
WScript.sleep 1000
Loop while boolExitFlag <> True
Sub pingsuccess
set oHTTP = CreateObject("Microsoft.XMLHTTP")
oHTTP.open "POST", "URL",false
oHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oHTTP.setRequestHeader "Content-Length", Len("send=send&time=" & Hour(Now) & ":" & Minute(Now) & ":" & Second(Now))
oHTTP.send "send=send&time=" & Hour(Now) & ":" & Minute(Now) & ":" & Second(Now)
End Sub
Function Ping(strHost)
Dim oPing, oRetStatus, bReturn
Set oPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus where address='" & strHost & "'")
For Each oRetStatus In oPing
If IsNull(oRetStatus.StatusCode) Or oRetStatus.StatusCode <> 0 Then
bReturn = False
Else
bReturn = True
End If
Set oRetStatus = Nothing
Next
Set oPing = Nothing
Ping = bReturn
End Function
When the scheduled task is run on the Windows 8 machines I see
"The task is currently running. (0x41301)" with no success. I have tried nearly EVERYTHING to attempt to get this working outside of writing a batch script to run the VBS script. That just seems excessively unnecessary though.
The only way that I could manage to get Windows 8 to run this VBS script was to create a batch file that called the VBS, and checked the box in the scheduled task to "Run with highest privileges". Without both the script would not run. I am not 100% sure why only Windows 8 fails miserably without doing this.
The batch file contained only the following code.
start "" "C:\path\to\script.vbs"

Start .vbs script without icon of wscript.exe in the taskbar

How can I Start .vbs script without icon of wscript.exe in windows taskbar
Unlike the CScript.exe, Windows does not show the WScript.exe host executable icon by default (shows Popup, MsgBox, InputBox and Echo only). Check the difference:
start "" cscript 30598853.vbs
will show a Windows script host icon in the Windows taskbar whilst
start "" wscript 30598853.vbs
will not. In both cases, an additional Windows script host icon will appear for a while (i.e. for the duration of the Popup is active in given example)...
Create a sample 30598853.vbs script as follows:
Dim WshShell, BtnCode
Set WshShell = WScript.CreateObject("WScript.Shell")
Do
BtnCode = WshShell.Popup( _
WScript.ScriptName & vbNewLine & "Exit script?" _
, 5 _
, WScript.FullName _
, vbOKCancel + vbQuestion)
If BtnCode = vbOK Then Exit Do
Wscript.Sleep 15000
Loop
Edit
To the best of my belief, a window invoked via Popup method or MsgBox function or InputBox function (and Echo method in case of the WScript.exe host executable as well) will always show it's icon in the taskbar. This happens regardless of that particular window is on top or isn't.
Read in another forum that one could assign a fully transparent icon to a particular executable...

How to send text file to printer

As i read in some fingerprint manual we can send text file to the printer. Means we can write the program in the text editor and send the whole program as a text file to the printer using the communication program using some transfer commands.
for in my host there is a file called myfile.txt in D:/ with the fallowing data
10 PRPOS 200,200
20 DIR 3
30 ALIGN 5
40 PRIMAGE “GLOBE.1”
50 PRINTFEED
RUN
How can i send this file to printer and execute the instrucations to print the image.
Please give me some code reference.
There are several ways to do this from the command line. For example:
type foo.txt > lpt1:
Or
copy foo.txt lpt1:
Or
print foo.txt
Or
notepad /p foo.txt
If you need to do it programmatically, you can execute any of those commands using the system() function or CreateProcess().
If you're on an Intermec handheld and you're connected to a Bluetooth printer, you should be able to open a serial port to COM6 and send your file over. What programming language? There should be plenty of Serial Port communication code examples out there.
My experience with Intermec PM4i label printer was a roller coaster but know I have a working app.
I tried Windows printer pipeline through generictext driver. It does work from Notepad but with few corner cases.
Printing directly from Notepad works fine until I tried QRCODE image with a very long text line. Image did not print out. Made qrcode text a short few characters and same script worked fine.
INPUT OFF
NASC 1252
BF OFF
FT "Swiss 721 Bold BT",12,0,100
PP 50,500:PT "Text line goes here"
PP 400,400:AN 7:BARSET "QRCODE",1,1,7,2,4
PB "ABC123 aabbcc....very long text goes here...I mean about 200 chars or more"
PRINTFEED
It was like Notepad cut text to a right side border and command string was broken. I made a printing preferences A3-landscape and it accepted longer text but still was not enough for all use cases.
All printers have a physical max printing width but it should not be considered in a fingerprint/directprotocol script files. After all we are not printing this text as-is but submitting commands to the printer.
My solution was to create Java application which opens a raw TCP socket to 11.22.33.44:9100 address and writes text lines, lines terminated by NL(#10). Works fine. Another helper tool I did was Delphi app.exe to read IP address from Windows printer object. I can submit label printouts "directly" from Excel application.
End users edit Excel data rows and click PRINT LABELS button
vba macro parses a fingerprint template file with ${FIELD1} find-and-replace substitutes
file is written to %wintemp%/intermec_script.txt folder
call app.exe to read IP address of user chosen printer
call java app to submit intermec_script.txt to IP:PORT socket
I should create same socket submit app in Delphi to drop javavm dependency but this solution was faster for my use case. I am more familiar with Java than my Delphi skill level.

Resources