Just something for you guys to comment on:
Usage:
- Install the service
- Dump neccessary files in SWAP\temp
- Dump .SWAP file in SWAP\jobs
- Wait
Code:
;****************************************************************************
;
;SCRIPT/FUNCTION : SWAP.kix
;
;ACTION : Run things with Admin Powers
;
;AUTHOR : Patrick Rutten (MightyR1@hotmail.com)
;
;CONTRIBUTORS : -
;
;SCRIPT VERSION : 1.0.0.0 - 2004-06-17
; Initial Release
;
;SYNTAX : None, is used in SWAP service
;
;PARAMETERS : -
;
;RETURNS : -
;
;REMARKS : After installing the Start With Admin Powers Service (see
; SWAPInstaller.kix), you are able to run things with
; admin powers.
; This script scans the SWAP\jobs folder to execute a job
; with Local System rights. After execution, the jobfile
; is moved to the SWAP\complete folder.
; .SWAP files are simple ini files, containing one section
; (command), containing one key (cmd). See Template.swap
; as an example.
;
;DEPENDENCIES : -
;
;EXAMPLE(S) : Hello.swap
; [Command]
; Cmd='c:\swap\bin\wkix32.exe c:\swap\temp\hello.kix'
; Hello.kix
; $rc=MessageBox('Hello from SWAP.','<-SWAP->',64+4096,3)
;
;KNOWN ISSUES : -
;
;KIXTART VERSION : 4.22
;
;KIXTART BBS : -
;
;****************************************************************************
;
;
;Enable Break to allow killing the script without logoff
Break on
;Set some global options
$rc=SetOption('Explicit','ON')
$rc=SetOption('NoVarsInStrings','ON')
;Declare variables
DIM $swapdir,$bindir,$completedir,$jobsdir,$logsdir,$tempdir
DIM $rc,$job
$swapdir='c:\swap'
$bindir=$swapdir+'\bin'
$completedir=$swapdir+'\complete'
$jobsdir=$swapdir+'\jobs'
$logsdir=$swapdir+'\logs'
$tempdir=$swapdir+'\temp'
$wait=60
;Infinite loop
While 1
;Check for *.swap files
$job=Dir($jobsdir+'\*.swap')
If $job
;Read the command to execute
$cmd=ReadProfileString($jobsdir+'\'+$job,'Command','Cmd')
;Execute and wait
Shell '%comspec% /c '+$cmd
;Move swap file to the complete folder
Copy $jobsdir+'\'+$job $completedir+'\'+$job
DEL $jobsdir+'\'+$job
EndIf
Sleep $wait
Loop
;Exit the script
Exit 0
Code:
;****************************************************************************
;
;SCRIPT/FUNCTION : SWAPInstaller.kix
;
;ACTION : Installs Start With Admin Powers Service
;
;AUTHOR : Patrick Rutten (MightyR1@hotmail.com)
;
;CONTRIBUTORS :
;
;SCRIPT VERSION : 1.0.0.0 - 2004-06-17
; Initial Release
;
;SYNTAX : -
;
;PARAMETERS : -
;
;RETURNS : -
;
;REMARKS : Must be an admin to install a service
;
;DEPENDENCIES : XNET.exe (in the KiXtart download)
; WKIX32.exe (in the KiXtart download)
; SRVANY.exe (in the rktools.exe download from M$)
; SWAP.kix
;
; All files must be in the same folder as this script
;
;EXAMPLE(S) : -
;
;KNOWN ISSUES : -
;
;KIXTART VERSION : 4.22
;
;KIXTART BBS : -
;
;****************************************************************************
;
;
;Enable Break to allow killing the script without logoff
Break on
;Set some global options
$rc=SetOption('Explicit','ON')
$rc=SetOption('NoVarsInStrings','ON')
;Declare variables
Dim $variables
DIM $swapdir,$bindir,$completedir,$jobsdir,$logsdir,$tempdir
DIM $rc,$job
DIM $swapclient
;Get the SWAPclient
cls
'Give the machine name to install the SWAP service on (\\MACHINE):' ?
gets $swapclient
;Check if Client exist
$rc=Dir($swapclient+'\c$\boot.ini')
if @error
? 'Error connecting to '+$swapclient+' (EC='+@error+')'
exit 1
endif
;Assign variables
$swapdir=$swapclient+'\c$\swap'
$bindir=$swapdir+'\bin'
$completedir=$swapdir+'\complete'
$jobsdir=$swapdir+'\jobs'
$logsdir=$swapdir+'\logs'
$tempdir=$swapdir+'\temp'
;Create SWAP structure
MD $swapdir
MD $bindir
MD $completedir
MD $jobsdir
MD $logsdir
MD $tempdir
Copy @SCRIPTDIR+'.' $bindir
;Install SWAP Service
shell @SCRIPTDIR+'\XNET INSTALL '+$swapclient+'\SWAP /b:c:\swap\bin\srvany.exe'
;Modify SWAP Service settings
$rc=WriteValue($swapclient+'\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SWAP','Description','Start With Admin Powers Service','REG_SZ')
$rc=WriteValue($swapclient+'\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SWAP','DisplayName','SWAP','REG_SZ')
$rc=WriteValue($swapclient+'\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SWAP','ErrorControl',&1,'REG_DWORD')
$rc=WriteValue($swapclient+'\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SWAP','ImagePath','c:\swap\bin\srvany.exe','REG_EXPAND_SZ')
$rc=WriteValue($swapclient+'\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SWAP','ObjectName','LocalSystem','REG_SZ')
$rc=WriteValue($swapclient+'\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SWAP','Start',&2,'REG_DWORD')
$rc=WriteValue($swapclient+'\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SWAP','Type',&110,'REG_DWORD')
$rc=WriteValue($swapclient+'\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SWAP\Parameters','AppDirectory','c:\swap\temp','REG_SZ')
$rc=WriteValue($swapclient+'\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SWAP\Parameters','AppEnvironment','','REG_SZ')
$rc=WriteValue($swapclient+'\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SWAP\Parameters','Application','c:\swap\bin\wkix32.exe','REG_SZ')
$rc=WriteValue($swapclient+'\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SWAP\Parameters','AppParameters','c:\swap\bin\swap.kix','REG_SZ')
$rc=WriteValue($swapclient+'\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SWAP\Security','Security', +
'01001480a0000000ac000000140000003000000002001c0001000000028' +
'01400ff010f00010100000000000100000000020070000400000000001800fd010200010100000000000512000000' +
'7300000000001c00ff010f000102000000000005200000002002000000006500000018008d0102000101000000000' +
'0050b0000002002000000001c00fd0102000102000000000005200000002302000000006500010100000000000512' +
'000000010100000000000512000000','REG_BINARY')
;Start SWAP Service
shell @SCRIPTDIR+'\XNET START '+$swapclient+'\SWAP'
get $rc
;Exit the script
Exit 0