VBS – Random IT Utensils https://blog.adamfurmanek.pl IT, operating systems, maths, and more. Sun, 10 Dec 2017 05:39:48 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 VBS script to send an HTTP request https://blog.adamfurmanek.pl/2018/03/10/vbs-script-to-send-an-http-request/ https://blog.adamfurmanek.pl/2018/03/10/vbs-script-to-send-an-http-request/#respond Sat, 10 Mar 2018 09:00:49 +0000 https://blog.adamfurmanek.pl/?p=2366 Another post with little script:

Set o = CreateObject("MSXML2.XMLHTTP")
o.open "GET", "https://page.com", False
o.setRequestHeader "Header", "Header value"

' Ignore certs (I bet you want to know how to do it)
' 2 stands for SXH_OPTION_IGNORE_SERVER_SSL_CERT_ERROR_FLAGS
' 13056 means ignore all server side cert error
o.setOption 2, 13056
o.send

' Read response
WScript.Echo po.responseBody

And for JSON serialization you might use this page

]]>
https://blog.adamfurmanek.pl/2018/03/10/vbs-script-to-send-an-http-request/feed/ 0
VBS script to check if workstation is locked https://blog.adamfurmanek.pl/2018/03/03/vbs-script-to-check-if-workstation-is-locked/ https://blog.adamfurmanek.pl/2018/03/03/vbs-script-to-check-if-workstation-is-locked/#comments Sat, 03 Mar 2018 09:00:46 +0000 https://blog.adamfurmanek.pl/?p=2363 Well, here it is:

Function IsWorkstationLocked( computer )
    Dim wmi : Set wmi = GetObject("winmgmts://" & computer & "/root/cimv2")
    Dim logonScreenCount : logonScreenCount = wmi.ExecQuery ("SELECT * FROM Win32_Process WHERE Name = 'LogonUI.exe'").Count

    IsWorkstationLocked = (logonScreenCount > 0)
End Function

Dim o

If IsWorkstationLocked(computer) Then
	'Do something
Else
	'Do something else
End If

]]>
https://blog.adamfurmanek.pl/2018/03/03/vbs-script-to-check-if-workstation-is-locked/feed/ 1
Running VBS script in IIS https://blog.adamfurmanek.pl/2018/02/24/running-vbs-script-in-iis/ https://blog.adamfurmanek.pl/2018/02/24/running-vbs-script-in-iis/#respond Sat, 24 Feb 2018 09:00:42 +0000 https://blog.adamfurmanek.pl/?p=2360 Continue reading Running VBS script in IIS]]> Sometimes you might want to deploy an incoming webhook for very simple use and do something when it’s called. On Windows you don’t need to have a full blown ASP.NET pipeline or even PHP server installed, you can go with simple VBS script. In this post I describe how to configure IIS to expose such a script and be able to accept incoming connections.

IIS

  1. Install IIS and CGI module
  2. Go to IIS and choose the site for VBS scripts
  3. Open Handler Mappings and choose Add Script Map…
  4. Set Request Path to *.vbs
  5. For Executable use the “C:\Windows\System32\cscript.exe” //NOLOGO %s %s
  6. Name it anything you would like

That’s it. Do not forget to add a binding.

Script

Now a simple script responding to a request.

WScript.Echo "Content-Type: text/html"
WScript.Echo "Access-Control-Allow-Origin: *"
WScript.Echo

WScript.Echo "Yep, I'm here!"

You actually need to start output in the first two lines of your script or else will ignore it. Apart from that you can do basically anything you like.

]]>
https://blog.adamfurmanek.pl/2018/02/24/running-vbs-script-in-iis/feed/ 0