KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Update/Install KiXforms
Goto page 1, 2  Next
 
Post new topic   Reply to topic    KiXforms Forum Index -> Script Archive
View previous topic :: View next topic  
Author Message
krabourn
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 273
Location: San Antonio. TX

PostPosted: Thu Apr 03, 2003 4:01 am    Post subject: Update/Install KiXforms Reply with quote

Well I have finally got around to posting the UDFs. Please direct comments to http://www.kixforms.org/forum/viewtopic.php?t=47 to that I can keep this clean.

Thanks

Code:
;FUNCTION:   fnUpdateKiXForms
;
;ACTION:   Update or install kixforms on a local or remote computer.
;         Optionally backup the old kixforms.dll to a directory on
;         the target computer.
;
;AUTHOR:   krabourn - Kelly Rabourn
;
;CONTRIBUTORS:   NTDOC/Chris S/Radimus/Lonkero/Sealeopard
;
;VERSION:    1.1
;
;DATE CREATED:   2003/05/09
;
;DATE MODIFIED:
;
;KIXTART:   4.02
;
;SYNTAX:   fnUpdateKiXForms($SourceFile, OPTIONAL $TargetComputer, OPTIONAL $BackupDir)
;
;PARAMETERS:
;   $SourceFile
;      This is the full path to the kixform.dll.
;
;   $TargetComputer
;      Optional.  This is the name of the computer to install kixforms.dll
;
;   $BackupDir
;      Optional.  The is path to the directory on the target computer to put
;      backups of the old .dll.
;
;RETURNS:   Error codes for for success(0) or failure.
;
;REMARKS:   This needs WMI to register the kixforms.dll.
;
;DEPENDENCIES:   WMI
;
;EXAMPLE:
;   BREAK ON
;   $Nul = fnUpdateKiXForms(@ScriptDir + '\kixforms.dll', 'Computer', @ScriptDir + '\BACKUP\')
;   IF @Error <> 0
;      $Nul = MessageBox ('KixForms could not be updated.', 'Error: ' + @Error, 16)
;      QUIT 1
;   ENDIF
;   SLEEP 2
;   $test = CreateObject("Kixtart.FORM")
;   IF @Error
;      ? 'Failed'
;   ENDIF
;   $test=0
;   QUIT 1

FUNCTION fnUpdateKiXForms($SourceFile, OPTIONAL $TargetComputer, OPTIONAL $BackupDir)
   DIM $fnError, $SourceVersion, $TargetDir, $TargetFile, $TargetVersion, $WMIComputer
   IF NOT $TargetComputer
      $TargetComputer = @Wksta
   ENDIF
   $SourceVersion = GetFileVersion($SourceFile)
   $TargetFile = '\\' + $TargetComputer + '\' + Join(Split(ReadValue('\\'+$TargetComputer+'\HKCR\CLSID\' + ReadValue('HKCR\Kixtart.Form\CLSID', '') + '\InprocServer32', ''), ':'), '$$')
   $TargetVersion = GetFileVersion($TargetFile)
   IF ($TargetVersion = '' OR $TargetVersion < $SourceVersion)
      IF InGroup ('\\' + $TargetComputer + '\' + SidToName('S-1-5-32-544')) - 1 + @InWin, '\\' + $TargetComputer + '\' + SidToName('S-1-5-32-547')) - 1 + @InWin)
         $TargetSystemRoot = '\\' + $TargetComputer + '\' + Join(Split(ReadValue ('\\' + $TargetComputer + '\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'SystemRoot'), ':'), '$$') + '\'
         $TargetDir = $TargetSystemRoot + Split(ReadValue ('\\'+$TargetComputer + '\HKLM\SYSTEM\CurrentControlSet\Control\Windows', 'SystemDirectory'), '\')[1] + '\'
         $WMIComputer = GetObject("winmgmts:{impersonationLevel=impersonate}!//" + $TargetComputer + "/root/cimv2:Win32_Process")
         IF $TargetFile
            IF $BackupDir
               $BackupDir = '\\' + $TargetComputer + '\' + Join(Split($BackupDir, ':'), '$$')
               IF NOT Exist ('$BackupDir')
                  MD ('$BackupDir')
               ENDIF
               IF NOT Exist ($BackupDir + $TargetVersion)
                 MD ($BackupDir + $TargetVersion)
               ENDIF
               COPY $TargetFile $BackupDir + $TargetVersion + '\'
            ENDIF
            $Nul = $WMIComputer.Create('regsvr32 ' + $TargetFile + ' /s /u')
            DEL $TargetFile
         ENDIF
         COPY $SourceFile $TargetDir
         IF @Error = 0
            $Nul = $WMIComputer.Create('regsvr32 ' + $TargetDir + '\kixforms.dll /s')
         ELSE
            $fnError = @Error
         ENDIF
      ELSE
         $fnError = 5
      ENDIF
   ENDIF
   EXIT $fnError
ENDFUNCTION


Code:
;FUNCTION:   fnUpdateKiXFormsLocal
;
;ACTION:   Update or install kixforms on a local computer.
;
;AUTHOR:   krabourn - Kelly Rabourn
;
;CONTRIBUTORS:   NTDOC/Chris S/Radimus/Lonkero/Sealeopard
;
;VERSION:    1.1
;
;DATE CREATED:   2003/05/09
;
;DATE MODIFIED:
;
;KIXTART:   4.02
;
;SYNTAX:   fnUpdateKiXForms($SourceFile)
;
;PARAMETERS:
;   $SourceFile
;      This is the full path to the kixform.dll.
;
;RETURNS:   Error codes for for success(0) or failure.
;
;REMARKS:   This should work on most Windows 9x/NT/2K/XP.
;
;DEPENDENCIES:   
;
;EXAMPLE:
;   BREAK ON
;   $Nul = fnUpdateKiXFormsLocal(@ScriptDir + '\kixforms.dll')
;   IF @Error <> 0
;      $Nul = MessageBox ('KixForms could not be updated.', 'Error: ' + @Error, 16)
      QUIT 1
;   ENDIF
;   SLEEP 2
;   $test = CreateObject("Kixtart.FORM")
;   IF @Error
;      ? 'Failed'
;   ENDIF
;   $test=0
;   QUIT 1
FUNCTION fnUpdateKiXFormsLocal($SourceFile)
   DIM $fnError, $SourceVersion, $TargetDir, $TargetFile, $TargetVersion
   $SourceVersion = GetFileVersion($SourceFile)
   $TargetFile = ReadValue('HKCR\CLSID\' + ReadValue('HKCR\Kixtart.Form\CLSID', '') + '\InprocServer32', '')
   $TargetVersion = GetFileVersion($TargetFile)
   IF ($TargetVersion = '' OR $TargetVersion < $SourceVersion)
      IF InGroup ('\\' + @Wksta + '\' + SidToName('S-1-5-32-544')) - 1 + @InWin, '\\' + @Wksta + '\' + SidToName('S-1-5-32-547')) - 1 + @InWin)
         $TargetDir = ExpandEnvironmentVars(ReadValue('HKLM\SYSTEM\CurrentControlSet\Control\Windows', 'SystemDirectory'))
         IF $TargetFile
            SHELL 'regsvr32 ' + $TargetFile + ' /s /u'
            DEL $TargetFile
         ENDIF
         COPY $SourceFile $TargetDir
         IF @Error = 0
            SHELL 'regsvr32 ' + $TargetDir + '\kixforms.dll /s'
            $fnError = @Error
         ELSE
            $fnError = @Error
         ENDIF
      ELSE
         $fnError = 5
      ENDIF
   ENDIF
   EXIT $fnError
ENDFUNCTION

_________________
Kelly


Last edited by krabourn on Sat May 10, 2003 2:55 am; edited 5 times in total
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Sealeopard
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 436
Location: Boston, MA

PostPosted: Thu Apr 03, 2003 2:45 pm    Post subject: Reply with quote

/i'd change the example from
Code:
$test = CreateObject("Kixtart.FORM")
;   IF NOT $test
to
Code:
$test = CreateObject("Kixtart.FORM")
;   IF @ERROR

_________________
Jens

'There are two kinds of vessels, submarines and targets.'
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Mon May 05, 2003 10:47 am    Post subject: Reply with quote

first of all...
the dependency for the local UDF is not correct.

then I must wonder why the need for 2 UDFs.

also, there is no administrators group in non-english installs.

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Sealeopard
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 436
Location: Boston, MA

PostPosted: Mon May 05, 2003 12:07 pm    Post subject: Reply with quote

In that case it might be better to test for
Code:
IF @PRIV='ADMIN'
a s this should work across all (localized) operating systems.
_________________
Jens

'There are two kinds of vessels, submarines and targets.'
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Mon May 05, 2003 12:16 pm    Post subject: Reply with quote

can't as it is gonna work for domain rights, not local
_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Sealeopard
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 436
Location: Boston, MA

PostPosted: Mon May 05, 2003 12:22 pm    Post subject: Reply with quote

But we requested that it also checks for local ADMIN resolution Very Happy
_________________
Jens

'There are two kinds of vessels, submarines and targets.'
Back to top
View user's profile Send private message Send e-mail MSN Messenger
krabourn
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 273
Location: San Antonio. TX

PostPosted: Mon May 05, 2003 1:17 pm    Post subject: Reply with quote

I took out WMI for the local version dependancies.

If someone can tell me how to check for admin rights that will work for non-english versions, I will change it.

I Will have to double check @Priv. Will @Priv return Admin for a power user?

_________________
Kelly
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Sealeopard
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 436
Location: Boston, MA

PostPosted: Mon May 05, 2003 1:33 pm    Post subject: Reply with quote

Nope, ADMIN = Administrators (or localized equivalent)
_________________
Jens

'There are two kinds of vessels, submarines and targets.'
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Yokozuna
KiXforms Novice
KiXforms Novice


Joined: 22 Apr 2003
Posts: 1

PostPosted: Wed May 07, 2003 3:42 pm    Post subject: Reply with quote

Have you thought about including a function for removing the dll on exit ?

This would be useful when running a script on a production server.

After unregistering the dll, I have tried to delete it but I am unable to do it until the script stops running. This has forced me to run my Kixtart script in a batch file then followed by a line to delete the kixforms.dll as the last line in the batch file.

What do you think ?

Regards
Yokozuna
Back to top
View user's profile Send private message
Sealeopard
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 436
Location: Boston, MA

PostPosted: Wed May 07, 2003 3:50 pm    Post subject: Reply with quote

Why would you want to install/remove the DLL every time a script runs? This also assumes that there's only one script running at any thime that uses this DLL.
_________________
Jens

'There are two kinds of vessels, submarines and targets.'
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Fri May 09, 2003 10:59 am    Post subject: Reply with quote

the registering could be done on the fly but that also is only worthy way if hkcu is registering would work.

anyway, to retrieve local-admin rights see:
LocalAdmin() - checks for membership of local admin group

_________________
Hammer


Last edited by Lonkero on Fri May 09, 2003 2:27 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Sealeopard
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 436
Location: Boston, MA

PostPosted: Fri May 09, 2003 11:53 am    Post subject: Reply with quote

The on-the-fly registering or register/unregister requires that there's only one script running at a time. I don't think this is a good assumption to operate under.
_________________
Jens

'There are two kinds of vessels, submarines and targets.'
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Fri May 09, 2003 2:28 pm    Post subject: Reply with quote

not if all your scripts would register.
_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
krabourn
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 273
Location: San Antonio. TX

PostPosted: Fri May 09, 2003 4:03 pm    Post subject: Reply with quote

Lonkero

Do you know the power user sid? If someone tells me what it is. I will make change and then there will be no language barriers for the groups.

_________________
Kelly
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Rod
KiXforms Webmaster
KiXforms Webmaster


Joined: 22 Feb 2003
Posts: 202
Location: United Kingdom

PostPosted: Fri May 09, 2003 6:57 pm    Post subject: Reply with quote

You can use the following to ascertain the localised name of the power users group:
Code:
$sPowerUsers = SIDToName("S-1-5-32-547")

Rod.

_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Script Archive All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group