Tietcth Posted September 13, 2010 Share Posted September 13, 2010 (edited) I need to enable the file and print sharing in the connection properties. I have the script developed to do what I want mostly except I need to have a if exist in the script to check if the box is already checked. Any help would be appreciated. (Oh yeah by the way this is for windows xp) MsgBox(0,"System Changes","System changes in progress by your IT department........",10) ;Lock mouse and keyboard BlockInput(1) ; Open Network Connections Control Panel applet Run("control ncpa.cpl") WinWaitActive("Network Connections") ; Selects Local Area Connection properties Send("l") Send("!F") Send("r") WinWaitActive("Local Area Connection") ; Select File And Printer Sharing for Microsoft Networks send("File") Send("{TAB 5}") Send("{ENTER}") ; Close Local Area Connection properties screen and Network Connections window WinClose("Network Connections") ;Unlock mouse and keyboard Blockinput(0) test.au3 Edited September 13, 2010 by Tietcth Link to comment Share on other sites More sharing options...
wakillon Posted September 13, 2010 Share Posted September 13, 2010 search for _Net_Share_ShareAddIt can help you! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Tietcth Posted September 13, 2010 Author Share Posted September 13, 2010 search for _Net_Share_ShareAddIt can help you! Im trying to just enable file and printer sharing so I can install the symantec Endpoint protection client remotely. File and printer sharing has to be turned on unfortunately to do the install remotely. Link to comment Share on other sites More sharing options...
Tietcth Posted September 14, 2010 Author Share Posted September 14, 2010 Im trying to just enable file and printer sharing so I can install the symantec Endpoint protection client remotely. File and printer sharing has to be turned on unfortunately to do the install remotely.Basically, I need help with writing the part of the script that varifies whether the box for file and printer sharing is checked or not and if it is checked then end script. If it isnt checked then continue on with the script. I guess you would call it get check box value? Link to comment Share on other sites More sharing options...
Tietcth Posted September 14, 2010 Author Share Posted September 14, 2010 Basically, I need help with writing the part of the script that varifies whether the box for file and printer sharing is checked or not and if it is checked then end script. If it isnt checked then continue on with the script. I guess you would call it get check box value?I found this If GuiCTRLRead ($Checkbox1) = $GUI_CHECKED Then but cant seem to manipulate it to work for me. Link to comment Share on other sites More sharing options...
damon Posted September 14, 2010 Share Posted September 14, 2010 (edited) i use contrlcommand and there is a "IsChecked" that returns a 1 if checked and a 0 if not and you can use the same command to check or uncheck the box. I have also found it better to use that send because you can tie it to button instances. damon oh, and to answer your question, $var = guictrlread($checkbox1) msgbox (0,"",$var) 1 = checked 4 = unchecked so you could do $var = guictrlread($checkbox1) if $var = 1 then msgbox(0,"","Checked") else msgbox(0,"","Unchecked") endif Edited September 14, 2010 by damon It always amazes me how one little thing can cause so much havoc Link to comment Share on other sites More sharing options...
Tietcth Posted September 14, 2010 Author Share Posted September 14, 2010 i use contrlcommand and there is a "IsChecked" that returns a 1 if checked and a 0 if not and you can use the same command to check or uncheck the box. I have also found it better to use that send because you can tie it to button instances. damonoh, and to answer your question, $var = guictrlread($checkbox1) msgbox (0,"",$var)1 = checked4 = uncheckedso you could do$var = guictrlread($checkbox1)if $var = 1 then msgbox(0,"","Checked")else msgbox(0,"","Unchecked")endifIm getting an error: Variable used without being declared when I run the script. Link to comment Share on other sites More sharing options...
Tietcth Posted September 15, 2010 Author Share Posted September 15, 2010 Im getting an error: Variable used without being declared when I run the script.This is what I have so farGlobal $CHECKBOX1 = "file and printer sharing for microsoft networks"MsgBox(0,"Please wait","System changes in progress by your IT department........",10);Lock mouse and keyboardBlockInput(1); Open Network Connections Control Panel appletRun("control ncpa.cpl")WinWaitActive("Network Connections"); Selects Local Area Connection propertiesSend("l")Send("!F")Send("r")WinWaitActive("Local Area Connection");Checkbox state$var = GUICtrlRead($CHECKBOX1)if $var = 4 Thenelseif $var = 1 thenEndIf;Enable file and printer sharingsend("File ")Send("{TAB 5}")Send("{ENTER}"); Close Local Area Connection properties screen and Network Connections windowWinClose("Network Connections");Unlock mouse and keyboardBlockInput(0) Link to comment Share on other sites More sharing options...
Tietcth Posted September 16, 2010 Author Share Posted September 16, 2010 anyone have any more ideas or comments? Link to comment Share on other sites More sharing options...
Varian Posted September 16, 2010 Share Posted September 16, 2010 (edited) Why not just useRunWait(@Comspec & ' /c netsh firewall set service type = fileandprint mode = enable') RegWrite('HKLM\SYSTEM\CurrentControlSet\Control\Lsa', 'forceguest', 'REG_DWORD', '0')I know it is depreciated in Windows 7, but it still works and saves you from messing with the listview Edited September 16, 2010 by Varian Link to comment Share on other sites More sharing options...
Tietcth Posted September 16, 2010 Author Share Posted September 16, 2010 Why not just useRunWait(@Comspec & ' /c netsh firewall set service type = fileandprint mode = enable') RegWrite('HKLM\SYSTEM\CurrentControlSet\Control\Lsa', 'forceguest', 'REG_DWORD', '0')I know it is depreciated in Windows 7, but it still works and saves you from messing with the listview I modified that registry entry and it doesnt seem to enable file and print sharing. I can do the firewall with policy but the actual file and print sharing in the network connections I cant via policy. Any other ideas? Link to comment Share on other sites More sharing options...
Tietcth Posted September 16, 2010 Author Share Posted September 16, 2010 I modified that registry entry and it doesnt seem to enable file and print sharing. I can do the firewall with policy but the actual file and print sharing in the network connections I cant via policy. Any other ideas?forceguest is to enable or disable simple file sharing. Link to comment Share on other sites More sharing options...
Varian Posted September 16, 2010 Share Posted September 16, 2010 You are right..my solution doesn't help. I modified your script that should work on x86 windows 7 but I am not sure on x64...I know it does not work on my 2008R2 which is x64. Let me know if it works on a 64-bit Windows 7 box (if you have one)expandcollapse popup#include <GuiListView.au3> #include <Misc.au3> _Singleton(@ScriptName, 0) Global $hListView, $hItemFound Global $sTitle = '[REGEXPTITLE:(?i)Network Connections; CLASS:CabinetWClass]' Global $wTitle = '[REGEXPTITLE:(?i)Local Area Connection]' Global $CHECKBOX1 = 'File And Printer Sharing For Microsoft Networks' MsgBox(0,'Please wait','System changes in progress by your IT department........',10) ;Lock mouse and keyboard BlockInput(1) ;Open Network Connections Control Panel applet Run('control ncpa.cpl') WinWait($sTitle, '') Do WinActivate($sTitle, '') Until WinActive($sTitle, '') ; Selects Local Area Connection properties ControlSend($sTitle, '', '', 'l') ControlSend($sTitle, '', '', '!F') ControlSend($sTitle, '', '', 'r') WinWaitActive($wTitle, '') $hListView = ControlGetHandle($wTitle, '', 'SysListView321') $ItemCount = _GUICtrlListView_GetItemCount($hListView) For $i = 0 To $ItemCount - 1 Do WinActivate($wTitle, '') Until WinActive($wTitle, '') _GUICtrlListView_SetItemSelected($hListView, $i) $Text = _GUICtrlListView_GetItemText($hListView, $i) ;Sleep(50) If StringInStr($Text, 'Sharing') Then $State = _GUICtrlListView_GetItemState($hListView, $i, $LVIS_STATEIMAGEMASK) Switch $State Case 8192 ;Item is Checked ControlClick($wTitle, '', 'Button7') WinWaitClose($wTitle, '') WinClose($sTitle, '') ExitLoop ;Do nothing Here Since Already Checked Case 12288 ;Item is unchecked ControlSend($wTitle, '', $hListView, '{SPACE}') ControlClick($wTitle, '', 'Button6') WinWaitClose($wTitle, '') WinClose($sTitle, '') EndSwitch ExitLoop EndIf ControlSend($wTitle, '', $hListView, '{DOWN}') Next BlockInput(0) Link to comment Share on other sites More sharing options...
Tietcth Posted September 21, 2010 Author Share Posted September 21, 2010 Thanks so much for your help! I really appreciate it. You are right..my solution doesn't help. I modified your script that should work on x86 windows 7 but I am not sure on x64...I know it does not work on my 2008R2 which is x64. Let me know if it works on a 64-bit Windows 7 box (if you have one)expandcollapse popup#include <GuiListView.au3> #include <Misc.au3> _Singleton(@ScriptName, 0) Global $hListView, $hItemFound Global $sTitle = '[REGEXPTITLE:(?i)Network Connections; CLASS:CabinetWClass]' Global $wTitle = '[REGEXPTITLE:(?i)Local Area Connection]' Global $CHECKBOX1 = 'File And Printer Sharing For Microsoft Networks' MsgBox(0,'Please wait','System changes in progress by your IT department........',10) ;Lock mouse and keyboard BlockInput(1) ;Open Network Connections Control Panel applet Run('control ncpa.cpl') WinWait($sTitle, '') Do WinActivate($sTitle, '') Until WinActive($sTitle, '') ; Selects Local Area Connection properties ControlSend($sTitle, '', '', 'l') ControlSend($sTitle, '', '', '!F') ControlSend($sTitle, '', '', 'r') WinWaitActive($wTitle, '') $hListView = ControlGetHandle($wTitle, '', 'SysListView321') $ItemCount = _GUICtrlListView_GetItemCount($hListView) For $i = 0 To $ItemCount - 1 Do WinActivate($wTitle, '') Until WinActive($wTitle, '') _GUICtrlListView_SetItemSelected($hListView, $i) $Text = _GUICtrlListView_GetItemText($hListView, $i) ;Sleep(50) If StringInStr($Text, 'Sharing') Then $State = _GUICtrlListView_GetItemState($hListView, $i, $LVIS_STATEIMAGEMASK) Switch $State Case 8192 ;Item is Checked ControlClick($wTitle, '', 'Button7') WinWaitClose($wTitle, '') WinClose($sTitle, '') ExitLoop ;Do nothing Here Since Already Checked Case 12288 ;Item is unchecked ControlSend($wTitle, '', $hListView, '{SPACE}') ControlClick($wTitle, '', 'Button6') WinWaitClose($wTitle, '') WinClose($sTitle, '') EndSwitch ExitLoop EndIf ControlSend($wTitle, '', $hListView, '{DOWN}') Next BlockInput(0) Link to comment Share on other sites More sharing options...
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