is the code tags
 Code:
;;;;;;;;;;;;;;;
; Utrulling av xxx til lokal maskin.
; Laget av xxx, 02.05.2007
;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;   				
; Om gammel Windows versjon eller Vista vises tekst og beskjed om at det må oppgraderes.
;;;;;;;;;;;;;;;
$debug = "yes"
If @DOS="4.0" 
; OR @DOS="6.0"
	MESSAGEBOX ("xxx støtter ikke ditt operativ system, vennligst kontakt lokal IT ansvarlig", "xxx", 48)
	Exit
Endif

;;;;;;;;;;;;;;;
; Lager en variabel til hvor xxx filene ligger.
;;;;;;;;;;;;;;;
IF EXIST ("q:\xxx\xxx.exe")
	$fildir = q:\xxx\
	If $debug = "yes"
		MESSAGEBOX ("filedir = q", "xxx")
	EndIf
		
EndIf

If Exist ("h:\xxx\xxx.exe")
	$fildir = h:\xxx\
	If $debug = "yes"
		MESSAGEBOX ("filedir = h", "xxx")
	EndIf
	
EndIf

If Exist ("p:\xxx\xxx.exe")
	$fildir = p:\xxx\
	If $debug = "yes"
		MESSAGEBOX ("filedir = p", "xxx")
	EndIf
EndIf


;;;;;;;;;;;;;;;
; Funksjon for å se om xxx kjører
;;;;;;;;;;;;;;;
Break on

$pid= EnumProcess("xxx.exe")
If $pid <> ""
			If $debug = "yes"
				MESSAGEBOX ("xxx kjører funksjon", "xxx")
			EndIf

		Run "%programfiles%\xxx\xxx.exe"
		Exit
EndIf

Sleep 5

Function EnumProcess($exe, optional $terminate, optional $Computer)
	DIM $winmgmts, $ExecQuery, $Process, $id, $getobject, $
	If Not $computer	$computer=@WKSTA	EndIf
	$winmgmts="winmgmts:{impersonationLevel=impersonate}!//$COMPUTER"
	Select
		Case Val($exe)>0
			$ExecQuery="select * from Win32_Process where ProcessId='$exe'"
			$GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
			For Each $Process In $GetObject
				If $terminate		$=$Process.Terminate	EndIf
				$EnumProcess = $Process.name
				Next
			$GetObject=''
		Case VarType($exe)=8
			$ExecQuery="select * from Win32_Process where Name='$exe'"
			$GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
			For Each $Process In $GetObject
				If $terminate		$=$Process.Terminate	EndIf
				$id=$Process.ProcessId
				$EnumProcess = "$Id" + "|" + "$EnumProcess"
				Next
			$EnumProcess=Left($EnumProcess,Len($EnumProcess)-1)
			$GetObject=''
		Case 1
			Exit 1
		EndSelect
EndFunction

;;;;;;;;;;;;;;;
; Oppretter xxx Directory i Program filer mappen uavhengig av OS språk. 
; NB !!! VIRKER IKKE PÅ VISTA ENDA !!!   					  			
;;;;;;;;;;;;;;;
;	If $debug = "yes"
;		MESSAGEBOX ("Lage fildir", "xxx")
;	EndIf

;CD %programfiles%
;MD "xxx"

;;;;;;;;;;;;;;;						   				
; @DOS=5.0 er Windows 2000, @DOS=5.1 er Windows XP, @DOS=5.2 er Windows 2003, @DOS=6.0 er Windows Vista
; Speiler mappen på serveren ut på klientmaskin. I silent mode.
; NB !!! VIRKER IKKE PÅ VISTA ENDA !!!
;;;;;;;;;;;;;;;
	
MESSAGEBOX ("Oppgradering pågår.  Vennligst Vent. 
xxx vil starte automatisk når oppgradreingen er ferdig", "xxx Oppgragering", 64, 5)

	If $debug = "yes"
		MESSAGEBOX ("Sjekke Windows versjon og kopiere", "xxx")
	EndIf

If @DOS="5.0" OR @DOS="5.1" OR @DOS="5.2" OR @DOS="5.3" OR @DOS="6.0"
	If Exist ("q:\xxx\xxx.exe")
		Shell 'ROBOCOPY q:\xxx\distribusjon\ "%programfiles%\xxx\ /MIR /R:1 /W:1'
	Else
	If Exist ("p:\xxx\xxx.exe")
;		Shell 'ROBOCOPY p:\xxx\distribusjon\ "%programfiles%\xxx  /MIR /R:1 /W:1'
		Shell 'ROBOCOPY p:\xxx\distribusjon\ c:\testdir\xxx\ /MIR /R:1 /W:1'
	Else
	If Exist ("H:\xxx\xxx.exe")
		Shell 'ROBOCOPY h:\xxx\distribusjon\ "%programfiles%\xxx\ /MIR /R:1 /W:1'
	EndIf
EndIf
					

;;;;;;;;;;;;;;;
; Funksjon for laging av Shortcut.
;;;;;;;;;;;;;;;

	If $debug = "yes"
		MESSAGEBOX ("shortcut", "xxx")
	EndIf


function WshShortCut($path,$targetpath,optional $arguments,optional $startdir,optional $iconpath,optional $style)

dim $shell,$shortcut
$shell=createobject("wscript.shell")
if $shell
   	$shortcut=$shell.createshortcut($path)
if $shortcut
     	$shortcut.targetpath=$targetpath
	if $arguments
       	$shortcut.arguments=$arguments
	endif
	if $startdir
  	     	$shortcut.workingdirectory=$startdir
	endif
	if $iconpath
    		$shortcut.iconlocation=$iconpath
	endif
	if $style
    		$shortcut.windowstyle=$style
	endif
$shortcut.save
$shortcut=0
endif
$shell=0
endif
exit @error
endfunction

WshShortCut("%USERPROFILE%\Desktop\xxx.lnk","$fildir\xxx.EXE") 
EndIF

;;;;;;;;;;;;;;;
; Avslutte med å starte xxx
;;;;;;;;;;;;;;;

	If $debug = "yes"
		MESSAGEBOX ("starte xxx", "xxx")
	EndIf


run "%programfiles%\xxx\xxx.exe"


Here u go \:\)


Edited by daddster (2007-05-04 10:11 AM)