Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a tricky one (spiced up with getObject) 1

Status
Not open for further replies.

uladzik

Programmer
Feb 12, 2001
55
0
0
BY
I have a VBS script on my local machine. I'd like to call a DUN (Dial Up Network connection) file from that script.

I've tried the following method:
Code:
Set dun = GetObject("c:\windows\desktop\nextra.dun")
but it doesn't work. Any suggestions? I'd be very thankful.

Just to give you some more background information:

1) If you want to try it yourself but you don't have a DUN file, just go to "My Computer", click on "Dial-Up Networking" and choose "Make new connection". Then cut&paste the file (not the shortcut) to the desktop. So you'll get a file with DUN extension on your desktop. If you double-click the icon, the "Connect To" dialogbox is launched. That's what I need to launch from my VBS.

2) I also tried to find the associated program by searching the file types, and it turned out that DUN files are handled by Rundll32.exe. Thus, I've tried to run a command line "rundll32 c:\windows\desktop\nextra.dun" but it didn't work either.

Looking forward to any help!
Thanks in advance,
Uladzik
---
---
 
I got the code to work in the following manner. You were right about rundll handling the .DUN file, but you need to include the parameters that Windows sends to it..

The DUN file I created was called test.dun and I placed it on my windows desktop.

set shell = createobject("WSCRIPT.shell")
shell.run "C:\WINDOWS\RUNDLL32.EXE RNAUI.DLL,RnaRunImport c:\windows\desktop\test.dun"
set shell= nothing
 
Try uning the FileSystemObject if you want to manipulate files in VBS
 
Swany's solution was exactly what I needed (that's why I gladly gave him a star ;)). I am aware of FSO (and use it extensively) but it's no applicable in this particular case. My question to Swany though: how can I find out all the properties and methods for "WSCRIPT.shell" object? Thanks in advance!
---
---
 
Swany, thanks again! I actually have been there before but downloaded only VBScript55 and JScript55 language help not noticing that there is also WSH help file available.

One more question about the mysteries of VBScript (or secretes of the trade)? How did you figure out that Windows forms this command line
Code:
"C:\WINDOWS\RUNDLL32.EXE RNAUI.DLL,RnaRunImport c:\windows\desktop\test.dun"
when the user clicks test.dun file? What would be the strategy to figure out required parameters for a program file? ---
---
 
Your welcome.

As for finding the params, it was pretty easy. I simply went into explorer, then folder options. I Clicked file types, found Dial up Networking File, then clicked edit. I clicked single clicked Open then clicked edit again.

There you can see the full command line that is used to run the program.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top