Page 1 of 1 1
Topic Options
#72282 - 2002-12-19 03:53 PM RemoteInstall()
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
Someone want to test / review this...

update 1.1
code:
 break on

$computer="wheelerc_2nd"
$appdir="\\ada06\setup$$\apps"
$Folder="Acrobat Reader"
$executable="setup.exe"
$param=""
RemoteInstall($computer, $AppDir, $folder, $executable, $param)

exit

Function RemoteInstall($computer, $appDir, $folder, $executable, $param)
dim $rd, $command
$rd = '%comspec% /c RD /s /q "c:\Temp\$folder" >nul'
$command= '"c:\temp\$folder\$executable $param"'
if right($executable,4)=".msi"
$command='c:\winnt\system32\msiexec.exe /i "c:\temp\$folder\$executable"'
endif
? "Copying Files"
shell '%comspec% /c xcopy "$appdir\$folder" "\\$computer\c$$\Temp\$folder\" /s /v /h /y /i /q'
? "Running exe"
$ = RMTEXEC($computer, $command)
? "adding Runonce key for cleanup"
$ = Runonce($folder,$rd,1,$computer)
endfunction


FUNCTION RMTEXEC($computer, $command)
dim $Connect
$Connect = GetObject("winmgmts:{impersonationLevel=impersonate}!//$computer/root/cimv2:Win32_Process")
$RMTEXEC = $Connect.Create($Command)
exit @error
$Connect = 0
ENDFUNCTION

Function RunOnce($title, $Command, optional $systemwide, optional $Computer)
dim $regkey
$regkey='HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce'
select
case $systemwide and $computer
$regkey='\\$computer\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce'
case not $systemwide and $computer
$sid=RemoteSid($computer)
$regkey='\\$computer\HKEY_USERS\'+$SID+'\Software\Microsoft\Windows\CurrentVersion\RunOnce'
case not $systemwide
$regkey='HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce'
endselect
$runonce=writevalue($regkey,$Title,$command,'REG_SZ')
$runonce=@ERROR
endfunction

Function RemoteSid($computer, optional $remoteusername)
dim $sid, $logonname, $index, $HKUsidSMWCVE
$index=0
:sidloop
$sid=enumkey("\\$computer\HKEY_USERS\",$index)
if not @error
$HKUsidSMWCVE = "HKEY_USERS\$sid\Software\Microsoft\Windows\CurrentVersion\Explorer"
$LogonName=readvalue("\\$computer\$HKUsidSMWCVE","Logon User Name")
if $remoteusername=$LogonName or not @error
$RemoteSid=$sid
exit 0
return
else
$index=$index+1
$sid=''
goto sidloop
endif
endif
endfunction



[ 19. December 2002, 16:54: Message edited by: Radimus ]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#72283 - 2002-12-23 01:13 PM Re: RemoteInstall()
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
This one is cool I tested and works well
This one is good to deploy small applications or patches

One sugestion

Can we make it for group of comeputres ? some thing like we are doing for SU_install script...
I think it is possible to read computer names from a text file and putting into a loop [Frown] may be..
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#72284 - 2002-12-23 03:24 PM Re: RemoteInstall()
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
code:
$comps=readprofilestring('computers.ini','Workstations','')
for each $comp in $comps
$rc=remoteinstall($comp,...)
next

_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1592 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.061 seconds in which 0.029 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org