aphesia Posted October 19, 2009 Posted October 19, 2009 (edited) hello guys, i´m looking for a script which enables or disables a network connection on win7 x64.. i know that this isnt a "make a script for me" area but i rly have no clue yet and the examples i found seem all not to work on x64 :/ Anyone can help me out with it? A UDF would also be rly nice but i havent found any. thanks @edit: also i would need to check if the connection is enabled or disabled what i want to do: i had to switch to vmare as virtualbox didnt support everything i wanted.. vmware starts 4 services,4 process and 2 internet connections.. all in all it slows startup and bugs the internet.. and as i only need vmware once a month i will make a script which starts all services + process, enables the network adapter of vmare and then runs the vmare.. and when i close the vmware.exe process it disabled everything again + exits @edit2: for those who are intersted in my script.. here it is.. only part missing is the "enable/disable network adapter" part.. needs vmware workstation 6.5 to be installed. expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1_1 = GUICreate("VMware Control", 301, 301, 329, 166) $Label1 = GUICtrlCreateLabel("Starting VMware Agent Service", 16, 16, 260, 17) $Label2 = GUICtrlCreateLabel("Starting VMware Authorization Service", 16, 40, 260, 17) $Label3 = GUICtrlCreateLabel("Starting VMware DHCP Service", 16, 64, 260, 17) $Label4 = GUICtrlCreateLabel("Starting VMware NAT Service", 16, 88, 260, 17) $Label5 = GUICtrlCreateLabel("Enabling VMware Network Adapter VMnet1", 16, 112, 260, 17) $Label6 = GUICtrlCreateLabel("Enabling VMware Network Adapter VMnet2", 16, 136, 260, 17) $Label7 = GUICtrlCreateLabel("Starting VMware Workstation", 16, 160, 260, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $dir = "C:\Program Files (x86)\VMware\VMware Workstation\vmware.exe" $done = 0 Dim $MyService ;name of the service to start Dim $objService Dim $objWMIService Dim $MyCurrentServiceState = "Stopped" While 1 $nMsg = GUIGetMsg() if $done = 0 Then ;-----------------------------------VMWARE AGENT SERVICE START guictrldelete($Label1) $Label1 = GUICtrlCreateLabel("Starting VMware Agent Service...", 16, 16, 260, 17) $MyService = "ufad-ws60" $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2") $objService = $objWMIService.Get("Win32_Service.Name='" & $MyService & "'") If $objService.State = $MyCurrentServiceState Then $objService.StartService() endif ProcessWait("vmware-ufad.exe") guictrldelete($Label1) $Label1 = GUICtrlCreateLabel("Starting VMware Agent Service... Done ! ", 16, 16, 260, 17) ;-----------------------------------VMWARE Authorization SERVICE START guictrldelete($Label2) $Label2 = GUICtrlCreateLabel("Starting VMware Authorization Service...", 16, 40, 260, 17) $MyService = "VMAuthdService" $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2") $objService = $objWMIService.Get("Win32_Service.Name='" & $MyService & "'") If $objService.State = $MyCurrentServiceState Then $objService.StartService() endif ProcessWait("vmware-authd.exe") guictrldelete($Label2) $Label2 = GUICtrlCreateLabel("Starting VMware Authorization Service... Done ! ", 16, 40, 260, 17) ;-----------------------------------VMWARE DHCP SERVICE START guictrldelete($Label3) $Label3 = GUICtrlCreateLabel("Starting VMware DHCP Service...", 16, 64, 260, 17) $MyService = "VMnetDHCP" $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2") $objService = $objWMIService.Get("Win32_Service.Name='" & $MyService & "'") If $objService.State = $MyCurrentServiceState Then $objService.StartService() endif ProcessWait("vmnetdhcp.exe") guictrldelete($Label3) $Label3 = GUICtrlCreateLabel("Starting VMware DHCP Service... Done ! ", 16, 64, 260, 17) ;-----------------------------------VMWARE NAT SERVICE START guictrldelete($Label4) $Label4 = GUICtrlCreateLabel("Starting VMware NAT Service...", 16, 88, 260, 17) $MyService = "VMware NAT Service" $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2") $objService = $objWMIService.Get("Win32_Service.Name='" & $MyService & "'") If $objService.State = $MyCurrentServiceState Then $objService.StartService() endif ProcessWait("vmnat.exe") guictrldelete($Label4) $Label4 = GUICtrlCreateLabel("Starting VMware NAT Service... Done ! ", 16, 88, 260, 17) ;-----------------------------------Enable adapter 1 sleep(1000) guictrldelete($Label5) $Label5 = GUICtrlCreateLabel("Enabling VMware Network Adapter VMnet1...", 16, 112, 260, 17) ;-----------------------------------Enable adapter 2 sleep(1000) guictrldelete($Label6) $Label6 = GUICtrlCreateLabel("Enabling VMware Network Adapter VMnet2...", 16, 136, 260, 17) ;-----------------------------------Starting VMware Workstation guictrldelete($Label7) $Label7 = GUICtrlCreateLabel("Starting VMware Workstation...", 16, 160, 260, 17) run("" & $dir) ProcessWait("vmnat.exe") guictrldelete($Label7) $Label7 = GUICtrlCreateLabel("Starting VMware Workstation... Done !", 16, 160, 260, 17) $done = 1 WinWaitActive("VMware Workstation") EndIf if $done = 1 Then guictrldelete($Label1) guictrldelete($Label2) guictrldelete($Label3) guictrldelete($Label4) guictrldelete($Label5) guictrldelete($Label6) guictrldelete($Label7) $Label1 = GUICtrlCreateLabel("Waiting for VMware Workstation to be quit...", 16, 16, 260, 17) Dim $MyCurrentServiceState = "Running" ProcessWaitClose("vmware.exe") $done = 2 ;------------------------stopping vmware agent service guictrldelete($Label1) $Label1 = GUICtrlCreateLabel("Stoping VMware Agent Service...", 16, 16, 260, 17) $MyService = "ufad-ws60" $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2") $objService = $objWMIService.Get("Win32_Service.Name='" & $MyService & "'") If $objService.State = $MyCurrentServiceState Then $objService.StopService() EndIf ProcessWaitClose("vmware-ufad.exe") guictrldelete($Label1) $Label1 = GUICtrlCreateLabel("Stopping VMware Agent Service... Done !", 16, 16, 260, 17) ;------------------------stopping vmware authorization service guictrldelete($Label2) $Label2 = GUICtrlCreateLabel("Stopping VMware Authorization Service...", 16, 40, 260, 17) $MyService = "VMAuthdService" $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2") $objService = $objWMIService.Get("Win32_Service.Name='" & $MyService & "'") If $objService.State = $MyCurrentServiceState Then $objService.StopService() EndIf ProcessWaitClose("vmware-authd.exe") guictrldelete($Label2) $Label2 = GUICtrlCreateLabel("Stopping VMware Authorization Service... Done ! ", 16, 40, 260, 17) ;------------------------stopping vmware dhcp service guictrldelete($Label3) $Label3 = GUICtrlCreateLabel("Stopping VMware DHCP Service...", 16, 64, 260, 17) $MyService = "VMnetDHCP" $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2") $objService = $objWMIService.Get("Win32_Service.Name='" & $MyService & "'") If $objService.State = $MyCurrentServiceState Then $objService.StopService() EndIf ProcessWaitClose("vmnetdhcp.exe") guictrldelete($Label3) $Label3 = GUICtrlCreateLabel("Stopping VMware DHCP Service... Done ! ", 16, 64, 260, 17) ;------------------------stopping vmware nat service guictrldelete($Label4) $Label4 = GUICtrlCreateLabel("Stopping VMware NAT Service...", 16, 88, 260, 17) $MyService = "VMware NAT Service" $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2") $objService = $objWMIService.Get("Win32_Service.Name='" & $MyService & "'") If $objService.State = $MyCurrentServiceState Then $objService.StopService() EndIf ProcessWaitClose("vmnat.exe") guictrldelete($Label4) $Label4 = GUICtrlCreateLabel("Stopping VMware NAT Service... Done ! ", 16, 88, 260, 17) sleep(1000) guictrldelete($Label5) $Label5 = GUICtrlCreateLabel("Disabling VMware Network Adapter VMnet1", 16, 112, 260, 17) sleep(1000) guictrldelete($Label6) $Label6 = GUICtrlCreateLabel("Disabling VMware Network Adapter VMnet2", 16, 136, 260, 17) Exit EndIf Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited October 19, 2009 by aphesia
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now