Zohar Posted November 5, 2015 Share Posted November 5, 2015 (edited) Hi I am using Windows XP SP3,I opened Windows Explorer, Navigated to Control Panel\Network Connections,then created a Shortcut to the "Local Area Network" item there,and put it in C:\. I want to run this shortcut now,so If the network connection is closed, it will now start... How can I do it? Thank youZohar Edited November 17, 2015 by Zohar Link to comment Share on other sites More sharing options...
jdelaney Posted November 6, 2015 Share Posted November 6, 2015 Wouldn't you want to just run("ncpa.cpl")? IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Zohar Posted November 6, 2015 Author Share Posted November 6, 2015 Runnnig ncpa.cpl, opens the Network Connections list.I want to directly run a specific connection from there,and not to show the list.. Link to comment Share on other sites More sharing options...
Starstar Posted November 8, 2015 Share Posted November 8, 2015 Run("control ncpa.cpl") WinWaitActive("Network Connections") Send("^a") ; or control click on the connection you need shortcut to Send("!f") Send("s") WinWaitActive("Shortcut") Send("!y") Send("!+{F4}") Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
EmilyLove Posted November 9, 2015 Share Posted November 9, 2015 Runnnig ncpa.cpl, opens the Network Connections list.I want to directly run a specific connection from there,and not to show the list..By specific, are you referring to a connection that requires you to dial up or connect before you can use it? Link to comment Share on other sites More sharing options...
Zohar Posted November 9, 2015 Author Share Posted November 9, 2015 Hi StarstarThank you, this will indeed run it,but my hope was to achieve it not via automating the GUI, but a simple programmatic way(like Run() can run an executable, without automating Windows Explorer's GUI) Link to comment Share on other sites More sharing options...
Danyfirex Posted November 9, 2015 Share Posted November 9, 2015 create a shell object and click the menu item you want. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Zohar Posted November 10, 2015 Author Share Posted November 10, 2015 (edited) Danyfirex: Thank you.It's not a MenuItem tho,it appears like a regular item in the list (just like files appear there) Does it mean I can still achieve it using the way you wrote? BetaLeaf:Sorry I missed your reply earlier.It is the "Local Area Connection" network connection Edited November 10, 2015 by Zohar Link to comment Share on other sites More sharing options...
Danyfirex Posted November 10, 2015 Share Posted November 10, 2015 probably yes, Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Zohar Posted November 11, 2015 Author Share Posted November 11, 2015 Interesting I triedShellExecute("D:\ShortcutToLAN.lnk","","","Disable")But it didn't work.When I changed the first parameter there from a shortcut to a file (JPG), and changed the verb to "Edit", then it succeeded..Maybe ShellExecute() cannot work on Shortcuts, only on files?(or maybe there's a way to make it work on shortcuts too? I don't know what to change) Link to comment Share on other sites More sharing options...
CrypticKiwi Posted November 11, 2015 Share Posted November 11, 2015 (edited) you can alwaysrun( "cmd", "", @SW_SHOWMAXIMIZED ) $hWnd = WinWait("[CLASS:cmd]", "", 1) WinActivate($hWnd) Send("Path\ShortcutName.lnk{Enter}") ;Sleep(2000) ;ProcessClose("CMD.exe")Edit: For some reason the above code runs the .lnk but doesnt enable network connection, Alternatively you canset a shortcut key in .lnk file properties example control + alt + m thenSend("{CTRLDOWN}{ALTDOWN}m{CTRLUP}{ALTUP}")just read you dont want to automate gui...dont know if the shortcut key solution falls in that category but ill look in other "programmatic" solutionEdit: got it, took me a while to crack it ^^THE SHORTCUT HAS TO BE CREATED WHILE THE NETWORK IS DISABLED! otherwise it wont work!!you also might need to elevate but try without elevation first.thenrun( "cmd /k ""ShortcutPath.lnk""", "", @SW_SHOWMAXIMIZED )tell me if it works for you... Edited November 12, 2015 by CrypticKiwi Link to comment Share on other sites More sharing options...
CrypticKiwi Posted November 12, 2015 Share Posted November 12, 2015 (edited) i added this part as an edit of my last post so maybe you missed it and i'd like your feedback if it works for you and not only in my pc....""Edit: got it, took me a while to crack it ^^THE SHORTCUT HAS TO BE CREATED WHILE THE NETWORK IS DISABLED! otherwise it wont work!!you also might need to elevate but try without elevation first.thenrun( "cmd /k ""ShortcutPath.lnk""", "", @SW_SHOWMAXIMIZED )tell me if it works for you..."" Edited November 12, 2015 by CrypticKiwi Link to comment Share on other sites More sharing options...
Zohar Posted November 17, 2015 Author Share Posted November 17, 2015 Hi CrypticKiwiThank you very much for the ideas. When I runRun("cmd /k ""ShortcutPath.lnk""")I only get a DOS window, nothing is run.. In addition I tried to create the Shortcut again, when the network connection was disabled,but there was no difference in the result.(BTW, before, when I created the network shortcut when the network was enabled, the shortcut worked when I run it manually(via Windows Explorer),I just cannot run it programatically.. and it doesn't work both, with the first one I created, nor the second one (while offline, as you suggested)). You say that it does run, for you?Maybe it's because you're on a different version of Windows than XP.. Link to comment Share on other sites More sharing options...
CrypticKiwi Posted November 17, 2015 Share Posted November 17, 2015 (edited) Yes, indeed I use a different version of Windows (8.1) so unfortunately I don't have xp and cannot test to make it work... The strange thing is that on 8.1 most .lnk shortcuts work programmatically except the enabling the network connection shortcut you want , so maybe it's a security thing? but I got it to work with the instructions in last post, it didn't work with /c only /k and only when I create the shortcut offline...ill do some more tests on different pc (win7) and see result, also I did a lot of messing around before the .lnk worked so maybe it's something I did before not the /k while offline only... I'll let you know the result....update: win7 works exactly as win 8.1 /k is important and it has to be while the connection is disabled. I'm thinking of a way to get my hands on xp easily...maybe a virtual machine but I don't have a copy :-/....or maybe you could upgrade to 7 or 8.1 it's better for security anyway Edited November 17, 2015 by CrypticKiwi Link to comment Share on other sites More sharing options...
Zohar Posted November 17, 2015 Author Share Posted November 17, 2015 (edited) Thank you so much OK then, in the future when I'll use a different version of Windows, I will get back to it.. Meanwhile, I will automate it via GUI operations.. Thank you for the help CrypticKiwi Edited November 17, 2015 by Zohar 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