# Dienst unter WinXP per script de-/aktivieren



## Caliterra (6. September 2006)

Hallo,

folgendes Script habe ich für AutoIt geschrieben, da es ja sehr verwandt mit vbs ist poste ich mal hier.

Das Script soll diverse Dienste stoppen und dann deaktivieren oder aktivieren und dann starten.
Es funktioniert eigentlich auch, aber nur eigentlich. Die Dienste werden im starttyp verändert aber nach dieser Veränderung über die Registry lassen sie sich nicht mehr starten. Gibt es dort eine Prüfsumme oder sowas? In der mmc wird der Starttyp richtig aus gegeben.





```
;# VMstopper

$tvar_1 = "Möchten Sie die VMware Dienste stoppen?"
$tvar_2 = "Möchten Sie die VMware Dienste starten?"
$tvar_3 = "Keine Aktion durchgeführt!"
$tvar_4 = "Aktion erfolgreich durchgeführt!"
$var_1 = ProcessExists ( "vmware-authd.exe" ) 
$var_2 = ProcessExists ( "vmnetdhcp.exe" ) 
$var_3 = ProcessExists ( "vmnat.exe" ) 
$var_4 = ProcessExists ( "vmount2.exe" ) 

if $var_1 <> 0 AND $var_2 <> 0 AND $var_3 <> 0 AND $var_4 <> 0 Then

	$res = MsgBox ( 4, "VMware Dienste de-/aktivieren.", $tvar_1 )
	
	; YES = 6
	if $res = 6 Then
		
		ProgressOn("Progress Meter", "Increments every task", "0 percent")
		;-------------------------------
		$i = 0
		ProgressSet( $i, $i & " percent")
		;-------------------------------
		Run(@ComSpec & " /c " & 'net stop "VMware Authorization Service"', "", @SW_HIDE)
		$var = 1111
		While 1 ;use infinite loop since ExitLoop will get called
			$var = ProcessExists ( "vmware-authd.exe" ) 
			If $var = 0 Then ExitLoop
		WEnd
		RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VMAuthdService", "Start", "REG_DWORD", "00000004")	
		;-------------------------------
		$i = 25
		ProgressSet( $i, $i & " percent")
		;-------------------------------
		Run(@ComSpec & " /c " & 'net stop "VMware DHCP Service"', "", @SW_HIDE)
		$var = 1111
		While 1 ;use infinite loop since ExitLoop will get called
			$var = ProcessExists ( "vmnetdhcp.exe" ) 
			If $var = 0 Then ExitLoop
		WEnd
		RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VMnetDHCP", "Start", "REG_DWORD", "00000004")
		;-------------------------------
		$i = 50
		ProgressSet( $i, $i & " percent")
		;-------------------------------
		Run(@ComSpec & " /c " & 'net stop "VMware NAT Service"', "", @SW_HIDE)
		$var = 1111
		While 1 ;use infinite loop since ExitLoop will get called
			$var = ProcessExists ( "vmnat.exe" ) 
			If $var = 0 Then ExitLoop
		WEnd
		RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VMware NAT Service", "Start", "REG_DWORD", "00000004")
		;-------------------------------
		$i = 75
		ProgressSet( $i, $i & " percent")
		;-------------------------------
		Run(@ComSpec & " /c " & 'net stop "VMware Virtual Mount Manager Extended"', "", @SW_HIDE)
		$var = 1111
		While 1 ;use infinite loop since ExitLoop will get called
			$var = ProcessExists ( "vmount2.exe" ) 
			If $var = 0 Then ExitLoop
		WEnd
		RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\vmount2", "Start", "REG_DWORD", "00000004")
		;-------------------------------
		$i = 100
		ProgressSet(100 , "Done", "Complete")
		;-------------------------------
		sleep(500)
		ProgressOff()
		
		MsgBox ( 0, "VMware Dienste de-/aktivieren.", $tvar_4 )
		
	Else
		MsgBox ( 0, "VMware Dienste de-/aktivieren.", $tvar_3 )
	EndIf

ElseIf $var_1 = 0 AND $var_2 = 0 AND $var_3 = 0 AND $var_4 = 0 Then
	
	$res = MsgBox ( 4, "VMware Dienste de-/aktivieren.", $tvar_2 )
	
	if $res = 6 Then
		; aktivieren der Dienste
		RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VMAuthdService", "Start", "REG_DWORD", "00000002")
		RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VMnetDHCP", "Start", "REG_DWORD", "00000002")
		RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\vmount2", "Start", "REG_DWORD", "00000002")
		RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VMware NAT Service", "Start", "REG_DWORD", "00000002")
		
		ProgressOn("Progress Meter", "Increments every task", "0 percent")
		;-------------------------------
		$i = 0
		ProgressSet( $i, $i & " percent")
		;-------------------------------
		Run(@ComSpec & " /c " & 'net start "VMware Authorization Service"', "", @SW_HIDE)
		$var = 1111
		While 1 ;use infinite loop since ExitLoop will get called
			$var = ProcessExists ( "vmware-authd.exe" ) 
			If $var <> 0 Then ExitLoop
		WEnd
		;-------------------------------
		$i = 25
		ProgressSet( $i, $i & " percent")
		;-------------------------------
		Run(@ComSpec & " /c " & 'net start "VMware DHCP Service"', "", @SW_HIDE)
		$var = 1111
		While 1 ;use infinite loop since ExitLoop will get called
			$var = ProcessExists ( "vmnetdhcp.exe" ) 
			If $var <> 0 Then ExitLoop
    	WEnd
		;-------------------------------
		$i = 50
		ProgressSet( $i, $i & " percent")
		;-------------------------------
		Run(@ComSpec & " /c " & 'net start "VMware NAT Service"', "", @SW_HIDE)
		$var = 1111
		While 1 ;use infinite loop since ExitLoop will get called
			$var = ProcessExists ( "vmnat.exe" ) 
			If $var <> 0 Then ExitLoop
    	WEnd
		;-------------------------------
		$i = 75
		ProgressSet( $i, $i & " percent")
		;-------------------------------
		Run(@ComSpec & " /c " & 'net start "VMware Virtual Mount Manager Extended"', "", @SW_HIDE)
		$var = 1111
		While 1 ;use infinite loop since ExitLoop will get called
			$var = ProcessExists ( "vmount2.exe" ) 
			If $var <> 0 Then ExitLoop
    	WEnd
		;-------------------------------
		$i = 100
		ProgressSet(100 , "Done", "Complete")
		;-------------------------------
		sleep(500)
		ProgressOff()
		
		MsgBox ( 0, "VMware Dienste de-/aktivieren.", $tvar_4 )
		
	Else
		MsgBox ( 0, "VMware Dienste de-/aktivieren.", $tvar_3 )
	EndIf
		
Else

	MsgBox ( 0, "Dienste sind unregelmässig de-/aktiviert! Keine Aktion duchgeführt!", $var )

EndIf

Exit
```


----------

