Zohar

[Closed] How to Run a Shortcut to the "Local Area Network" Network Connection?

15 posts in this topic

#1 ·  Posted (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 you

Zohar

Edited by Zohar

Share this post


Link to post
Share on other sites



Runnnig ncpa.cpl, opens the Network Connections list.

I want to directly run a specific connection from there,

and not to show the list..

Share this post


Link to post
Share on other sites
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."

Share this post


Link to post
Share on other sites

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?


False Positive Reporter - Mass email all anti virus vendors with an attachment of your program for fast and easy whitelisting.

PortableApps.com App Creation Wizard  - A simple GUI-based Wizard for creating PortableApps.

SoundBoard - Play any song or sound you want at the press of a hotkey.

My GitHub Page: https://github.com/BetaLeaf

Share this post


Link to post
Share on other sites

Hi Starstar

Thank 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)

Share this post


Link to post
Share on other sites

create a shell object and click the menu item you want.

 

Saludos

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by Zohar

Share this post


Link to post
Share on other sites

probably yes,

 

Saludos

Share this post


Link to post
Share on other sites

Interesting

 

I tried

ShellExecute("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)

 

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

you can always

run( "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 can
set a shortcut key in .lnk file properties example control + alt + m then

Send("{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" solution

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.

then

run( "cmd /k ""ShortcutPath.lnk""", "", @SW_SHOWMAXIMIZED )

tell me if it works for you...

Edited by CrypticKiwi

Share this post


Link to post
Share on other sites

#12 ·  Posted (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.

then

run( "cmd /k ""ShortcutPath.lnk""", "", @SW_SHOWMAXIMIZED )

tell me if it works for you...""

Edited by CrypticKiwi

Share this post


Link to post
Share on other sites

Hi CrypticKiwi

Thank you very much for the ideas.

 

When I run

Run("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..

 

Share this post


Link to post
Share on other sites

#14 ·  Posted (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 :P

Edited by CrypticKiwi

Share this post


Link to post
Share on other sites

#15 ·  Posted (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 by Zohar

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now