'Startup VB script to install UltraVNC and mv2 driver
on error resume next

Dim WshShell, Fso, objWMIService, colItems
Set WshShell = CreateObject("WScript.Shell")
Set Fso = CreateObject("Scripting.FileSystemObject")

If Not (Fso.FileExists((WshShell.ExpandEnvironmentStrings("%PROGRAMFILES%"))&"\UltraVNC\winvnc.exe")) Then

   'Install UltraVNC app with setup config file (you have to prepare it on test computer before)
   WshShell.Run "\\share\UltraVNC_1_1_9_X86_Setup.exe /verysilent /loadinf=\\share\ultravnc.inf" , 1, True

   'Import security group members to registry with .reg file (you have to export it on test computer before)
   WshShell.Run "regedit /s \\share\ultravnc_acl.reg", 1, True


   'Install mv2 driver (video accelerator)
   If Not (Fso.FileExists((WshShell.ExpandEnvironmentStrings("%WINDIR%"))&"\SYSTEM32\mv2.dll")) Then

      'Windows XP section
      Set objWMIService = GetObject("winmgmts:")   
      Set colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_OperatingSystem where Version like '5.1%'")   
      For Each objItem In colItems    

         'Install driver (you have to create and apply GPO to allow silent installation 
         'of drivers that are not signed by Microsoft on Windows XP computers)
         WshShell.CurrentDirectory = "\\share\driver\xp"
         WshShell.Run "setupdrv install", 1, True
      Next   

      'Windows Vista / 7 section
      Set objWMIService = GetObject("winmgmts:")   
      Set colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_OperatingSystem where Version like '6.1%'")   
      For Each objItem In colItems  

         'Import TrustedPublisher certificate to ignore questions from Windows Defender 
         '(you have to export certificate from test computer before installation) 
         WshShell.Run "certutil -addstore TrustedPublisher \\share\uvnc_bvba.cer", 1, True
         WScript.Sleep 3000 'just for sure

         'Install driver
         WshShell.CurrentDirectory = "\\share\driver\vista"       
         WshShell.Run "setupdrv install", 1, True
      Next   

   End If

   '—hange default ultravnc server config file with yours (you have to prepare it on test computer before)
   If (Fso.FolderExists((WshShell.ExpandEnvironmentStrings("%PROGRAMFILES%"))&"\UltraVNC\")) Then
      Fso.CopyFile "\\share\ultravnc.ini", (wshShell.ExpandEnvironmentStrings("%PROGRAMFILES%")) & "\UltraVNC\", TRUE  
   End If

   'Restart ultravnc service
   WshShell.Run "net stop uvnc_service", 1, True
   WshShell.Run "net start uvnc_service", 1, True

End If