У меня есть то, что люди хотят использовать iPad для доступа к образу VDI.Некоторое время назад я создал скрипт, который будет отображать пользователя в зависимости от того, где он находится внутри AD.Это не работает с iPad, так как я не могу передать файл parm с iPad в образ VDI.Я сейчас ищу способ, чтобы просто выйти из скрипта, если нет файла parm.
Вот мой сценарий: Как вы думаете, что будет лучшим способом проверить, есть ли пользователь на iPad?Если они есть на iPad, как закрыть и не запускать этот скрипт?
' *********************************************************************
' 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