2

What I have is that people want to use the iPad to access the VDI image. I have created a script some time ago that will map a user based on where they are inside AD. That doesnt work with the iPad since I cant pass the parm file from the iPad to the VDI image. I am now looking for a way to that will just exit the script if no parm file is present.

Heres my script: What do you feel would be the best way to either check to see if the user is on an iPad? If they are on an iPad how to close and not run this script?

' *********************************************************************
'    Assign default printer for Citrix Server based on pulled PARM file
'
'    v100a    XXX     xx/xx/xxxx   - Original Version
'    v110a    MRH     03/24/2010   - Removed V: Drive reference and
'                                    changed it to UNC Path.
'                                  - Added Execute FastLaunch on 
'                                    change of Default Printer from
'                                    RightFax to something else.
'    v120a    MRH     03/25/2010   - Made reading of the Param file
'                                    more robust.  It must be at least
'                                    8 characters in length.
'    v130a    MRH     04/02/2010   - If pnagent.exe is already running
'                                    do not attempt to launch it again.
'    v140a    MRH     04/02/2010   - More error checking around reading
'                                    the C:\oasGold\oaaparm.ini file. 
'                                    Locate the = and read from there.
'    v150a    MRH     05/14/2010   - Fixed Determining if the printer is
'                                    moved from RightFax to other printer.
'
' *********************************************************************

Option Explicit 
Dim objFSO, objFile, objFileS, strLine, ParmID, net, WshNetwork, Counter
Dim eqLoc
Dim OShell, exestr
Dim oReg, strKeyPath, strValue

' Create Shell object for running command
set Oshell = CreateObject("Wscript.Shell")

'creates network object for printer setup later
Set net = CreateObject("WScript.Network")
Set WshNetwork = WScript.CreateObject("WScript.Network") 

'Open the fso
 Set objFSO = CreateObject("Scripting.FileSystemObject")

' Copy the Param file from thin client to C:\
' Map Printer Based on the Param File.
If objFSO.FileExists("\\Client\C$\oasgold\oaaparm.ini") then
'copy parm file from thin client to citrix virtual disk
Objfso.CopyFile "\\Client\C$\oasgold\oaaparm.ini", "C:\oasgold\",TRUE

Set objFileS = objFSO.GetFile("C:\oasGold\oaaparm.ini")

If (objFileS.Size >= 8) Then
    'creates file object and opens parm file
    Set objFile = objFSO.OpenTextFile("C:\oasGold\oaaparm.ini", 1)

    'reads first line of parm file into strLine
    strLine = LCase(objFile.ReadLine)

    'Locate the equal and read the ParmID, the next 4 characters
    'If no equals then set param to ????
    eqLoc = InStr(1, strLine, "=", 1)
    If (eqLoc > 0) then
        ParmID = Mid(strLine, eqLoc+1, 4)
    Else
        ParmID = "????"
    End If

    ' Close Param file.
    objFile.Close
Else
    ' Unable to Read Param File, set it to something unique to notify us that the files is bad.
    ParmID = "????"
End If

'based on Parm ID select which printer to setup
Select Case ParmID
    Case "????"
        Wscript.Echo "Invalid Parm ID: " & ParmID & ". No Windows printer selected!!!"
    Case "xxxx"
        Wscript.Echo "Invalid Parm ID: " & ParmID & ". No Windows printer selected!!!"
    Case "iej3"
        net.AddWindowsPrinterConnection "\\print1\e-it-hal4000-ps"
        WshNetwork.SetDefaultPrinter "\\print1\e-it-hal4000-ps"
    Case "c5in"
        net.AddWindowsPrinterConnection "\\print1\E-4E1-MFD-PS"
        WshNetwork.SetDefaultPrinter "\\print1\E-4E1-MFD-PS"
    Case "f8it"
        net.AddWindowsPrinterConnection "\\print1\E-4E1-MFD-PS"
        WshNetwork.SetDefaultPrinter "\\print1\E-4E1-MFD-PS"
    Case "f7it"
        net.AddWindowsPrinterConnection "\\print1\ep-spc2-mfd-ps"
        WshNetwork.SetDefaultPrinter "\\print1\ep-spc2-mfd-ps"
    Case "iel4"
        net.AddWindowsPrinterConnection "\\print1\e-2ne1-ps"
        WshNetwork.SetDefaultPrinter "\\print1\e-2ne1-ps"
    Case "iel9"
        net.AddWindowsPrinterConnection "\\print1\e-2nw1-ps"
        WshNetwork.SetDefaultPrinter "\\print1\e-2nw1-ps"
    Case "iei3"
        net.AddWindowsPrinterConnection "\\print1\e-4n1-ps"
        WshNetwork.SetDefaultPrinter "\\print1\e-4n1-ps"
    Case "ieh5"
        net.AddWindowsPrinterConnection "\\print1\e-5sfrt-ps"
        WshNetwork.SetDefaultPrinter "\\print1\e-5sfrt-ps"
    Case "iee8"
        net.AddWindowsPrinterConnection "\\print1\e-5n1-ps"
        WshNetwork.SetDefaultPrinter "\\print1\e-5n1-ps"
    Case "7jq6"
        net.AddWindowsPrinterConnection "\\print1\e-ns-5sinpat-ps"
        WshNetwork.SetDefaultPrinter "\\print1\e-ns-5sinpat-ps"
    Case "ieg5"
        net.AddWindowsPrinterConnection "\\print1\e-6e1-ps"
        WshNetwork.SetDefaultPrinter "\\print1\e-6e1-ps"
    Case "ieg7"
        net.AddWindowsPrinterConnection "\\print1\e-6n2-ps"
        WshNetwork.SetDefaultPrinter "\\print1\e-6n2-ps"
    Case "ieg1"
        net.AddWindowsPrinterConnection "\\print1\e-6s1-ps"
        WshNetwork.SetDefaultPrinter "\\print1\e-6s1-ps"
    Case "iem4"
        net.AddWindowsPrinterConnection "\\print1\E-CVS-HOLDING-PS"
        WshNetwork.SetDefaultPrinter "\\print1\E-CVS-HOLDING-PS"
    Case "98ic"
        net.AddWindowsPrinterConnection "\\print1\ec3-frtdsk-mfd-ps"
        WshNetwork.SetDefaultPrinter "\\print1\ec3-frtdsk-mfd-ps"
    Case "ido0"
        net.AddWindowsPrinterConnection "\\print1\ec4-frtdsk-ps"
        WshNetwork.SetDefaultPrinter "\\print1\ec4-frtdsk-ps"
    Case "i0ic"
        net.AddWindowsPrinterConnection "\\print1\ec5-frtdsk-ps"
        WshNetwork.SetDefaultPrinter "\\print1\ec5-frtdsk-ps"
    Case "k4ic"
        net.AddWindowsPrinterConnection "\\print1\ec6-frtdsk-ps"
        WshNetwork.SetDefaultPrinter "\\print1\ec6-frtdsk-ps"
    Case "k0ig"
        net.AddWindowsPrinterConnection "\\print1\ec6-nursery-ps"
        WshNetwork.SetDefaultPrinter "\\print1\ec6-nursery-ps"
    Case "i4ic"
        net.AddWindowsPrinterConnection "\\print1\ec5-nursery-ps"
        WshNetwork.SetDefaultPrinter "\\print1\ec5-nursery-ps"
    Case "94ic"
        net.AddWindowsPrinterConnection "\\print1\EC2-PEDS1-MFD-PS"
        WshNetwork.SetDefaultPrinter "\\print1\EC2-PEDS1-MFD-PS"    
    Case "96ic"
        net.AddWindowsPrinterConnection "\\print1\EC2-PEDS2-PS"
        WshNetwork.SetDefaultPrinter "\\print1\EC2-PEDS2-PS"    
    Case "70vl"
        net.AddWindowsPrinterConnection "\\print1\EC2-WMNSERV2-PS"
        WshNetwork.SetDefaultPrinter "\\print1\EC2-WMNSERV2-PS"
    Case "52it"
        net.AddWindowsPrinterConnection "\\print1\EC2-WMNSERV1-MFD-PS"
        WshNetwork.SetDefaultPrinter "\\print1\EC2-WMNSERV1-MFD-PS"
    Case "ied4"
        net.AddWindowsPrinterConnection "\\print1\7east1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\7east1-ps"
    Case "ied7"
            net.AddWindowsPrinterConnection "\\print1\e-7n1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\e-7n1-ps"
    Case "ief0"
            net.AddWindowsPrinterConnection "\\print1\e-7s1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\e-7s1-ps"
    Case "a2ic"
            net.AddWindowsPrinterConnection "\\print1\e-7w1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\e-7w1-ps"    
    Case "70tx"
            net.AddWindowsPrinterConnection "\\print1\w-cps-nurst1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-cps-nurst1-ps" 
    Case "4m6n"
            net.AddWindowsPrinterConnection "\\print1\w-adup-nurst1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-adup-nurst1-ps"
    Case "4m5h"
            net.AddWindowsPrinterConnection "\\print1\w-neuro-nurs1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-neuro-nurs1-ps"
    Case "4m5i"
            net.AddWindowsPrinterConnection "\\print1\w-neuro-nurs2-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-neuro-nurs2-ps"
    Case "ei38"
            net.AddWindowsPrinterConnection "\\print1\w-suro-nurs1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-suro-nurs1-ps"
    Case "ei39"
            net.AddWindowsPrinterConnection "\\print1\w-suro-nurs2-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-suro-nurs2-ps"
    Case "n1gj"
            net.AddWindowsPrinterConnection "\\print1\w-orth-nurs1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-orth-nurs1-ps"
    Case "n2gj"
            net.AddWindowsPrinterConnection "\\print1\w-orth-nurs2-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-orth-nurs2-ps"
    Case "j6gj"
            net.AddWindowsPrinterConnection "\\print1\w-reha-nurs2-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-reha-nurs2-ps"
    Case "n0gj"
            net.AddWindowsPrinterConnection "\\print1\w-reha-nurs1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-reha-nurs1-ps"
    Case "7jv4"
            net.AddWindowsPrinterConnection "\\print1\w-reha-nurs3-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-reha-nurs3-ps"
    Case "c8ic"
            net.AddWindowsPrinterConnection "\\print1\w-cc-nurs1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-cc-nurs1-ps"
    Case "g0ic"
            net.AddWindowsPrinterConnection "\\print1\w-cc-nurs2-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-cc-nurs2-ps"
    Case "4m1g"
            net.AddWindowsPrinterConnection "\\print1\w-cc-nurs3-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-cc-nurs3-ps"
    Case "70tq"
            net.AddWindowsPrinterConnection "\\print1\w-adol-nurst1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-adol-nurst1-ps"
    Case "4m6q"
            net.AddWindowsPrinterConnection "\\print1\w-afd-nurstn1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-afd-nurstn1-ps"
    Case "14it"
            net.AddWindowsPrinterConnection "\\print1\w-smh-nurst1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-smh-nurst1-ps"
    Case "4m5s"
            net.AddWindowsPrinterConnection "\\print1\ac_hp4050_ps"
            WshNetwork.SetDefaultPrinter "\\print1\ac_hp4050_ps"
    Case "4m1p"
            net.AddWindowsPrinterConnection "\\print1\w-actr-hp4kt-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-actr-hp4kt-ps"
    Case "d8gj"
            net.AddWindowsPrinterConnection "\\print1\W-INDC-HP4KT-PS"
            WshNetwork.SetDefaultPrinter "\\print1\W-INDC-HP4KT-PS" 
    Case "iei9"
            net.AddWindowsPrinterConnection "\\print1\e-5woutpt-ps"
            WshNetwork.SetDefaultPrinter "\\print1\e-5woutpt-ps"
    Case "e6ir"
            net.AddWindowsPrinterConnection "\\print1\w-mh-stafstn1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-mh-stafstn1-ps"
    Case "l7ir"
            net.AddWindowsPrinterConnection "\\print1\w-ops-nursta1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-ops-nursta1-ps"
    Case "iej5"
            net.AddWindowsPrinterConnection "\\print1\e-ops1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\e-ops1-ps"
    Case "ij99"
            net.AddWindowsPrinterConnection "\\print1\E-SURG-AMADMT-PS"
            WshNetwork.SetDefaultPrinter "\\print1\E-SURG-AMADMT-PS"
    Case "ijc5"
            net.AddWindowsPrinterConnection "\\print1\ep-bhilab-mfd-ps"
            WshNetwork.SetDefaultPrinter "\\print1\ep-bhilab-mfd-ps"
    Case "70rq"
            net.AddWindowsPrinterConnection "\\print1\w-ns-fcu-ps"
            WshNetwork.SetDefaultPrinter "\\print1\w-ns-fcu-ps"
    Case "f6in"
            net.AddWindowsPrinterConnection "\\print1\e-3e-cath-ps"
            WshNetwork.SetDefaultPrinter "\\print1\e-3e-cath-ps"
    Case "f5in"
            net.AddWindowsPrinterConnection "\\print1\e-3w-ptr1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\e-3w-ptr1-ps"
    Case "ijh4"
            net.AddWindowsPrinterConnection "\\print1\e-gi1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\e-gi1-ps"
    Case "ijj1"
            net.AddWindowsPrinterConnection "\\print1\e-3e-teemfd-ps"
            WshNetwork.SetDefaultPrinter "\\print1\e-3e-teemfd-ps"
    Case "id17"
            net.AddWindowsPrinterConnection "\\print1\e-gi1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\e-gi1-ps"
    Case "f9in"
            net.AddWindowsPrinterConnection "\\print1\e-4s-frtptr1-ps"
            WshNetwork.SetDefaultPrinter "\\print1\e-4s-frtptr1-ps"
    Case "k4ig"
            net.AddWindowsPrinterConnection "\\print1\E-4N-FRTDSK-PS"
            WshNetwork.SetDefaultPrinter "\\print1\E-4N-FRTDSK-PS"
    Case "if99"
            net.AddWindowsPrinterConnection "\\print1\E-SURG-AMADMT-PS"
            WshNetwork.SetDefaultPrinter "\\print1\E-SURG-AMADMT-PS"
End Select
 Else
Wscript.Echo "Error:  No Parm file available.  Unable to Add Printer!!!"
 End If


 ' ******************************************************************************
 ' Execute Citrix PNAGENT FastLaunch, but first wait until the printer is mapped
 ' or until we give up.
 ' ******************************************************************************
 const HKEY_CURRENT_USER = &H80000001
 Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!   \\.\root\default:StdRegProv")

 For Counter = 1 to 30
 strKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\Windows"
oReg.GetStringValue HKEY_CURRENT_USER, strKeyPath, "Device", strValue

' if GT 0 then \\print1 Found in String and exit waiting for it.
If (InStr(1, strValue, "\\print1", 1) > 0) then
Exit For
 End If
wscript.sleep(1000)
Next  

exestr = chr(34) & "C:\Program Files\Citrix\ICA Client\pnagent.exe" & chr(34)   & " /CitrixShortcut: (3) /QLaunch " & chr(34) & "BryanLGH-VDI:FastLaunch" & chr(34)
'Oshell.Run exestr, 0, FALSE
Lizz
  • 1,442
  • 5
  • 25
  • 51
user770022
  • 2,899
  • 19
  • 52
  • 79
  • Interesting script, but we need a little more scenario/setup information. Like, how do the iPad users intend to connect to/use the VDI? What OS is the VDI? Might need to also know what ports does the VDI have open? It's possible you might need an ADSI/LDAP client for the iPad, depending on how the connection is established. – Lizz Nov 10 '12 at 08:50

1 Answers1

0

I would take a look into HTA or Scripts to install printers using Intranet Portals as they allow you have heuristics to make the best determination if a VB Script is feasible. Obviously there's going to be a disconnect from VBScript running on operating systems that do not support it.

You may be able to leverage browser functionalities to determine the OS and the Browser the client... and based on that, leverage the appropriate script to provide the end-user. For example, you could wrap that entire VBscript into an HTA Document that will be delivered to Windows Clients only and it will run the vb code client-side, straight from the web server hta document and the client wont care about the difference because intranet HTA documents are considered safe.

You'll need to look into some AppleScript for your other clients or some general PHP Code to make that data available for end-users to execute scripts on OS Alternatives to Windows.

Another alternative is to run a java coded applet that runs on every client.. I've seen this at other companies. They leverage these same types of functions in their VDIs. There is no automated printer install... The end user selects the printer based on their location and usually there's a geographic map of their office that runs in the browser that they use to select the script. The web-code decides for the client which script is appropriate to install that specific printer on the client's system.

Hope that helps! :)

Steve Kline
  • 805
  • 4
  • 11