fcjoe
Active Members-
Posts
53 -
Joined
-
Last visited
fcjoe's Achievements
Wayfarer (2/7)
0
Reputation
-
I went to that link, but the first line is "Don't use this in production environment !" I plan on running this on all computers in my company.
-
I used an example (write to file) compiled it, added as a service and when I started it got the same error.
-
Here is my code, basically copied the VBScript from link below and recoded for AutoIt http://gallery.technet.microsoft.com/scriptcenter/Disable-wireless-f3bcf66f Dim $objWMIService Dim $colLAN, $colWiFi Dim $objWiFi, $objLAN Dim $strWirelessName Dim $State = "" Dim $wireStatus = "" Dim $wifiStatus = "" ;Dim $oVBS $oVBS = ObjCreate("ScriptControl") $oVBS.language = "VBScript" Global Const $Nothing = $oVBS.eval("Nothing") $oVBS = $Nothing While 1 $strWirelessName = GetWirelessName() $objWMIService = ObjGet("winmgmts:.rootCIMV2") $colLAN = $objWMIService.ExecQuery("Select * From Win32_NetworkAdapter Where NetConnectionID like 'Local Area Connection' and PhysicalAdapter='True'") $colWiFi = $objWMIService.ExecQuery ("Select * From Win32_NetworkAdapter Where NetConnectionID =" & "'" & $strWirelessName & "'" & " and PhysicalAdapter='True'") For $objWiFi In $colWiFi If $objWiFi.Netconnectionstatus = 2 Then $wifiStatus = True ;MsgBox(0,"","WiFi Connected") Else $wifiStatus = False ;MsgBox(0,"","WiFi DIS-Connected") EndIf Next For $objLAN in $colLAN If $objLAN.Netconnectionstatus=2 Then $wireStatus = True ;$State = False ;this is very importnat variable to determine when to enable or disbale wireless connection Else $wireStatus = False EndIf Next If $wireStatus = False And $wifiStatus = False Then EnableWireless($strWirelessName) ElseIf $wireStatus = True And $wifiStatus = True Then DisableWireless($strWirelessName) EndIf Sleep(5000) WEnd Func GetWirelessName() Local $strKeyPath = "SYSTEMCurrentControlSetControlNetwork{4D36E972-E325-11CE-BFC1-08002BE10318}" Local $objReg Local $arrSubKeys[25] Local $SubKey Local $strValueName Local $dwValue Local $strValue Local $intRet Const $HKLM = 0x80000002 $objReg = ObjGet("winmgmts:.rootdefault:StdRegProv") $objReg.Enumkey($HKLM ,$strKeyPath,$arrSubKeys) For $SubKey In $arrSubKeys $strValueName = "MediaSubType" $objReg.GetDWORDValue($HKLM,$strKeyPath & "" & $SubKey & "" & "Connection",$strValueName,$dwValue) If $dwValue = 2 Then $strValueName = "Name" $objReg.GetStringValue($HKLM,$strKeyPath & "" & $SubKey & "" & "Connection",$strValueName,$strValue) ExitLoop EndIf Next Return($strValue) EndFunc Func EnableWireless($strNetConn) Local $objShell, $colConnections, $objConn, $objNetwork, $objEnable, $objVerb Local $strEnable = "En&able" Const $NETWORK_CONNECTIONS = 0x31 $objShell = ObjCreate("Shell.Application") $colConnections = $objShell.Namespace($NETWORK_CONNECTIONS) For $objConn In $colConnections.Items If $objConn.Name = $strNetConn Then $objNetwork = $objConn ExitLoop EndIf Next $objEnable = $Nothing ;Enable NIC For $objVerb In $objNetwork.verbs If $objVerb.name = $strEnable Then $objEnable = $objVerb ExitLoop EndIf Next If $objEnable <> $Nothing Then $objEnable.DoIt Sleep(60000) EndFunc Func DisableWireless($strNetConn) Local $objShell, $colConnections, $objConn, $objNetwork, $objDisable, $objVerb Local $strDisable = "Disa&ble" Const $NETWORK_CONNECTIONS = 0x31 $objShell = ObjCreate("Shell.Application") $colConnections = $objShell.Namespace($NETWORK_CONNECTIONS) For $objConn in $colConnections.Items If $objConn.Name = $strNetConn Then $objNetwork = $objConn ExitLoop EndIf Next $objDisable = $Nothing For $objVerb in $objNetwork.verbs if $objVerb.name = $strDisable Then $objDisable = $objVerb ExitLoop EndIf Next If $objDisable <> $Nothing Then $objDisable.DoIt Sleep(3000) EndFunc
-
Guinness, AutoIt 3.3.6.1 Windows 7 64Bit SC command: sc create ManageWireless binPath= D:CodeWirelessManageWireless.exe Have not tried one of the examples but I will try that now and report back.
-
Hello, I have a compiled script that runs with no problems when I run it manually. I used the SC command to add it as a service but when I try to start it I get an error. Error: 1503: The service did not responds to the start control request in a timely fashion. This is the first time I've tried adding one of my scripts as a service. Is there something I need to add to the code to send a signal to windows that it has started successfully? Or is something else causing this issue? If you need the code let me know and I will post it. Thanks, Joe
-
UEZ, I'm converting this VBScript code http://gallery.technet.microsoft.com/scriptcenter/Disable-wireless-f3bcf66f BrewManNH, That seems to work
-
Hello, I needed to recreate the VBScript constant Nothing in AutoIt and found this posting on the forums I use the code excactly as written $oVBS = ObjCreate("ScriptControl") $oVBS.language = "VBScript" Global Const $Nothing = $oVBS.eval("Nothing") $oVBS = $Nothing However, I get an error "Variable must be of type object" on this line: $oVBS.language = "VBScript" Anyone know what the issue is and how to fix it? I'm on version 3.3.6.1 Thanks, Joe
-
Hello, I have a script that installed network printers (shared on a Windows server). Unfortunatly I lost the source code and now I need to rewrite it for a new printer server and printers and work on Windows 7. I wrote it a long time ago. Best I can remember was it was converted from a VBScript and all you had to do was specify the path (\\servername\printername). No loading drivers or any of that other stuff. I tried looking for the sample script i originally found on here years ago but all I can find are post about installing local printers or network printers not on a Windows server. Can anyone help? Thanks, Joe
-
Runwait() not working on Windows 7
fcjoe replied to fcjoe's topic in AutoIt General Help and Support
I didn't know about #RequireAdmin, we only recently started deploying Windows 7. Thanks, Joe -
Hello, I'm having a problem with Runwait on Windows 7. The following line works fine on XP with no problems but on 7 it does nothing. RunWait("\\servername\sharename\DS Software\Microsoft\Office\2010\setup.exe") I got the return code, which was 0 and @error only returned 1 which isn't very usefull. Is there some known problem with Windows 7 and runwait function? Thanks, Joe
-
That was simple, I feel stupid. Thank you, Joe
-
Function IsAccountDisabled(intUAC) Const ADS_UF_ACCOUNTDISABLE = 2 If intUAC And ADS_UF_ACCOUNTDISABLE Then IsAccountDisabled = True Else IsAccountDisabled = False End If End Function I have a VBScript that I'm converting to AutoIT. What it does is query Active Directory for all accounts and doesn't count the ones that are disabled. The function in VBScript to to determine if it is disabled is below ' Function to perform an AND comparison against the AD field UserAccountControl to determine if the account is disabled Function IsAccountDisabled(intUAC) Const ADS_UF_ACCOUNTDISABLE = 2 If intUAC And ADS_UF_ACCOUNTDISABLE Then IsAccountDisabled = True Else IsAccountDisabled = False End If End Function It will return True is the account is disabled. However, VBScript and Autoit treet 'AND' differently. Does anyone know how to get this to work in AutoIt? Thank you, Joe
-
I figured it out. I downloaded bitsadmin from Windows XP Support tools, which is an older version. I did some searching and found that there is a newer version in Windows Server 2003 Service Pack 2 32-bit Support Toolslink This newer version works with no problems. So the problem wasn't with my script, but with bitsadmin.exe itself. Thank you for all your help Wakillon Joe