Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automating Micros CAL

Status
Not open for further replies.

Brewskisandfrickles

IS-IT--Management
Dec 22, 2022
13
CA
Hey all,

Our org uses a huge amount of workstations via tablet interface. I'm looking for a way to automate the CAL procedure when setting up or resetting a workstation. Does anyone know of a way to do this such a via command line or installer answer files? I can't seem to find any info or documentation of this online so I suspect I may have to result to using scripts that just click and type on the screen manually like a human.
 
Just wanted to share an update for anyone that may be looking to do this in the future. I couldn't find a way to automate it cleanly, so I built a powershell script that just clicks on the screen like a human.
- This script is meant for Simphony Multi-Tenant CALing so the proccess may differ from your environment, but with some minor tweaking to the pixel that the mouse is clicking on, you could make this work for any version of CAL and any type of simphony/RES
- This script is built specifically for devices with a 1280x1024 resolution. You will need to adjust the locations the pixels click on if your resolution is different.
- This script relies on the fact the device is already named in windows and uses the name of the device to select a property number. Our devices are all labelled P33WS02. P33 = Property 1033 in EMC, WS02 = Workstation 2. So I have a list of all of our locations in order of their property number. The script reads the devices windows name and then selects the correct property based on the name. This logic is all very specific to my company so you may need to adjust this for your needs.
- This script uses an installed shield answer file to install CAL silently, then it waits 25 seconds for the screen to popup where you actually CAL the device. You may want to make your own answer file, ho
Code:
wever, mine thats included in the script should work fine.

$SiteList = @(
    'dummy',
    'New York 1234 Mcdonalds',
    'London 2523 Mcdonalds'
    
)

$Computername = hostname
$Sitenumber = [int]$Computername.ToUpper().split('P').split('T')[1]
$SiteNamePosition = 380



$cSource = @'
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public class Clicker
{
//[URL unfurl="true"]https://msdn.microsoft.com/en-us/library/windows/desktop/ms646270(v=vs.85).aspx[/URL]
[StructLayout(LayoutKind.Sequential)]
struct INPUT
{ 
    public int        type; // 0 = INPUT_MOUSE,
                            // 1 = INPUT_KEYBOARD
                            // 2 = INPUT_HARDWARE
    public MOUSEINPUT mi;
}

//[URL unfurl="true"]https://msdn.microsoft.com/en-us/library/windows/desktop/ms646273(v=vs.85).aspx[/URL]
[StructLayout(LayoutKind.Sequential)]
struct MOUSEINPUT
{
    public int    dx ;
    public int    dy ;
    public int    mouseData ;
    public int    dwFlags;
    public int    time;
    public IntPtr dwExtraInfo;
}

//This covers most use cases although complex mice may have additional buttons
//There are additional constants you can use for those cases, see the msdn page
const int MOUSEEVENTF_MOVED      = 0x0001 ;
const int MOUSEEVENTF_LEFTDOWN   = 0x0002 ;
const int MOUSEEVENTF_LEFTUP     = 0x0004 ;
const int MOUSEEVENTF_RIGHTDOWN  = 0x0008 ;
const int MOUSEEVENTF_RIGHTUP    = 0x0010 ;
const int MOUSEEVENTF_MIDDLEDOWN = 0x0020 ;
const int MOUSEEVENTF_MIDDLEUP   = 0x0040 ;
const int MOUSEEVENTF_WHEEL      = 0x0080 ;
const int MOUSEEVENTF_XDOWN      = 0x0100 ;
const int MOUSEEVENTF_XUP        = 0x0200 ;
const int MOUSEEVENTF_ABSOLUTE   = 0x8000 ;

const int screen_length = 0x10000 ;

//[URL unfurl="true"]https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310(v=vs.85).aspx[/URL]
[System.Runtime.InteropServices.DllImport("user32.dll")]
extern static uint SendInput(uint nInputs, INPUT[] pInputs, int cbSize);

public static void LeftClickAtPoint(int x, int y)
{
    //Move the mouse
    INPUT[] input = new INPUT[3];
    input[0].mi.dx = x*(65535/System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width);
    input[0].mi.dy = y*(65535/System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
    input[0].mi.dwFlags = MOUSEEVENTF_MOVED | MOUSEEVENTF_ABSOLUTE;
    //Left mouse button down
    input[1].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
    //Left mouse button up
    input[2].mi.dwFlags = MOUSEEVENTF_LEFTUP;
    SendInput(3, input, Marshal.SizeOf(input[0]));
}
}
'@
Add-Type -TypeDefinition $cSource -ReferencedAssemblies System.Windows.Forms,System.Drawing
$wshell = New-Object -ComObject wscript.shell;


#Prepare workstation by turning off firewall,ipv6,setting ipv6,etc.
Set-ItemProperty –Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' –Name AutoAdminLogon -Value "1"
New-ItemProperty –Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' –Name DefaultUserName -Value "user"
New-ItemProperty –Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' –Name DefaultPassword -Value 'user'
Set-ItemProperty –Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' –Name DefaultUserName -Value "user"
Set-ItemProperty –Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' –Name DefaultPassword -Value 'user'
Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private -Verbose
netsh advfirewall firewall set rule group="Network Discovery" new enable=Yes
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorAdmin -Value 0
Get-NetAdapterBinding | Where-Object ComponentID -EQ 'ms_tcpip6' | Disable-NetAdapterBinding -ComponentID 'ms_tcpip6'

Sleep 5


#Install CAL
$AnswerFile = @'
[{D2C63C6D-1FAC-4A7F-A994-F02F056CB853}-DlgOrder]
Count=0
'@

$AnswerFile > C:\bin\McrsCAL144\install.iss
C:\Bin\McrsCAL144\setup.exe /s /f1C:\bin\McrsCAL144\install.iss


#Wait for CAL
Sleep 27
#Click on dropdown
[Clicker]::LeftClickAtPoint(700,440)
sleep .6
#Select Multi Tenant Simphony
[Clicker]::LeftClickAtPoint(700,535)
sleep .6
#Click on OrgPA
[Clicker]::LeftClickAtPoint(600,535)
sleep .6
$wshell.SendKeys('') <----- ENTER YOUR INFO HERE
sleep .6
#Click on Server Name
[Clicker]::LeftClickAtPoint(600,500)
sleep .6
$wshell.SendKeys('') <----- ENTER YOUR INFO HERE
sleep .6
#Click on Update
[Clicker]::LeftClickAtPoint(700,500)
sleep .6
#Click on next
[Clicker]::LeftClickAtPoint(700,580)
sleep 3


#Click on Usernamebox
[Clicker]::LeftClickAtPoint(700,460)
$wshell.SendKeys('') <----- ENTER YOUR INFO HERE
sleep .6
#Click on Password
[Clicker]::LeftClickAtPoint(700,520)
$wshell.SendKeys('') <----- ENTER YOUR INFO HERE
sleep .6
#Click on Server
[Clicker]::LeftClickAtPoint(700,580)
$wshell.SendKeys('') <----- ENTER YOUR INFO HERE
sleep .6
#Click on Next
[Clicker]::LeftClickAtPoint(700,630)
sleep 3

#Click on site search box
$wshell.SendKeys($Site)
sleep .6
[Clicker]::LeftClickAtPoint(790,350)
sleep .6
#Click on site name
[Clicker]::LeftClickAtPoint(700,$SiteNamePosition)
sleep .6
#Click on next
[Clicker]::LeftClickAtPoint(730,780)
sleep 3

#Click on computer name search
[Clicker]::LeftClickAtPoint(600,725)
sleep .6
$wshell.SendKeys($Computername)
sleep .6
#click on Find button
[Clicker]::LeftClickAtPoint(770,725)
sleep .6
#Click on computer name
[Clicker]::LeftClickAtPoint(470,510)
sleep .6
#Click on Save
[Clicker]::LeftClickAtPoint(770,690)


As an added bonus, here is an automatic uninstall script to remove CAL cleanly:

Code:
#Uninstall CAL
$AnswerFile = @'
[{D2C63C6D-1FAC-4A7F-A994-F02F056CB853}-DlgOrder]
Dlg0={D2C63C6D-1FAC-4A7F-A994-F02F056CB853}-SdWelcomeMaint-0
Count=3
Dlg1={D2C63C6D-1FAC-4A7F-A994-F02F056CB853}-MessageBox-0
Dlg2={D2C63C6D-1FAC-4A7F-A994-F02F056CB853}-SdFinish-0
[{D2C63C6D-1FAC-4A7F-A994-F02F056CB853}-SdWelcomeMaint-0]
Result=303
[{D2C63C6D-1FAC-4A7F-A994-F02F056CB853}-MessageBox-0]
Result=6
[{D2C63C6D-1FAC-4A7F-A994-F02F056CB853}-SdFinish-0]
Result=1
bOpt1=0
bOpt2=0
'@
$AnswerFile > C:\bin\McrsCAL144\uninstall.iss

Get-Process -Name Servicehost | Stop-Process -force
Get-Process -Name McrsCal | Stop-Process -force
Get-process -name WIN7CALStart | Stop-Process -force

C:\Bin\McrsCAL144\setup.exe /s /f1C:\bin\McrsCAL144\uninstall.iss

Remove-item c:\micros -force -Recurse
Remove-item 'C:\Program Files (x86)\MICROS' -recurse -force
Remove-Item -Path 'HKLM:\SOFTWARE\WOW6432Node\Micros' -recurse -force
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top