Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Using NCPA.CPL to access Local Area Conn. properties

plarocque (MIS) (OP)
13 Mar 07 10:56
Hi,

I'm trying (and failing) to find a way of scripting access  directly to the 'General' tab of 'Local Area Connections' properties, i.e. without having to go through the 'Control Panel > Network Connections' route then right-clicking on 'Local Area Connection' then choosing the 'Properties' button.

I've tried using the following command:
rundll32.exe shell32.dll,Control_RunDLL ncpa.cpl,,1
(found on VBNet) but this still only gets me to the 'Local Area Connection'.

Does anyone know of a way?

Pierre.
linney (TechnicalUser)
13 Mar 07 16:29
Will something like Autoit do anything for you?

AutoIt-- Freeware:
http://www.autoitscript.com/autoit3/
plarocque (MIS) (OP)
14 Mar 07 7:03
I don't know, perhaps. I will have a look. Thank you anyway.
linney (TechnicalUser)
14 Mar 07 17:11
Have you tried your luck here?

Vbscript Forum.
http://www.tek-tips.com/threadminder.cfm?pid=329
TheLad (TechnicalUser)
15 Mar 07 7:01
What are you actually trying to do when you bring up the Properties screen?  As Linney has hinted, you can probably use VBScript to achieve what you want

BTW, if you run CONTROL NCPA.CPL, it does the same job as your RUNDLL32 statement...

--------------------------------------
"Insert funny comment in here!"
--------------------------------------

plarocque (MIS) (OP)
15 Mar 07 7:14
I'm trying to access the TCP/IP properties page. It will be a vbscript that run once when a thin client is getting installed. The person installing the hardware will have to specify either if the thin will use a DHCP to obtain an IP address, or if it will use a static IP, and if it is the  case, enter it.

Because vbscript is so limited with interaction with the user, I thought it would be simpler to use the actual applet then to create a new one to ask and receive input from the user.

LINNEY:

Haven't tried anything yet, I had a quick look, looks promising but the problem is, as we are a gouverment office, I'm not suppose, or I don't have the right to use freeware/shareware.
Rick998 (IS/IT--Management)
15 Mar 07 7:51
Plarocque,

I used to use AutoIt but now tend to use AutoHotkey more frequently instead. (See http://www.autohotkey.com/)

Whichever one you use, once you are happy with your script, just compile it into an executable using the compilers that are provided with each program. That way you don't have to install either AutoIt or AutoHotkey itself on the PC's at work.

Here's an example AutoHotkey script. Copy/Paste it into Notepad and save as something like 'nic-properties.ahk'.

CODE

; Open Network Connections
Run ncpa.cpl
WinWaitActive, Network Connections,
 
; Select the first object starting with L and open its Status window
Send, L{ENTER},
WinWaitActive, Local Area,
 
; Press the Properties button to open its window
Send, {SPACE},
sleep, 200
WinWait, Local Area,
IfWinNotActive, Local Area, , WinActivate, Local Area,
WinWaitActive, Local Area,

When you run this using AutoHotkey it will open the Properties of the Local Area Network Connection for you.

Hope this helps...
TheLad (TechnicalUser)
15 Mar 07 8:58
And this is the VBScript equivalent.  Just paste the code into a text file, save it with a VBS extension (eg NETWORK.VBS) then double-click on it to run it.  If you were to automate the running of this code, you would need to use WSCRIPT (eg WSCRIPT NETWORK.VBS)

CODE

set WshShell = CreateObject("WScript.Shell")

'Launch NCPA and wait for 2 seconds
WshShell.Run "control ncpa.cpl"
WScript.Sleep 2000

'Wait until the application has loaded - Check every second
While WshShell.AppActivate("Network Connections") = FALSE
wscript.sleep 1000
Wend

'Bring the application to the foreground
WshShell.AppActivate "Network Connections"
WScript.Sleep 500

'Send keys to select the first connection starting with L
WshShell.SendKeys "L"
WScript.Sleep 501

'Send keys to Bring up the File Menu
WshShell.SendKeys "%f"
WScript.Sleep 501

'Send keys to Choose Properties (shortcut key is R)
WshShell.SendKeys "r"
WScript.Sleep 501

--------------------------------------
"Insert funny comment in here!"
--------------------------------------

plarocque (MIS) (OP)
15 Mar 07 9:10
I have posted many questions over time in different forum in here, but never received as many helpful hint as this one generate, it's great.  Thank you to every one. I think I've got all the tools I need to continue my project.

Thanks again.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close