Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm currently trying to convert an old vbs file into .net

The file is a remote installation script for some software.

It uses wmi to install the program remotely however wmi can't install from a mapped drive and we don't want to have to insert the CD on all of the remote machines (there are quite a few).

To get around this the script maps the remote c$ copies the installation files, installs the program and then removes the installation files. It then moves onto the next remote host in the list.

 

How would I go about creating the mapping to the remote c$ to the U: drive of the local machine used to install the program in .net??

The mapping will need to pass a user name and password.

 

Cheers

Posted (edited)
Can you invoke subst.exe (system32 program) through the shell to do this?

 

Not sure if I can, or if I want to. I'd prefer not to make a call to a command line argument.

 

I've managed to work out how to get the wsh runtime library referenced in my project and used the same/similar scripting code to get the desired effect.

 

The reference I need in my project was a com reference to the windos script host object model. This added iwshruntimelibrary as a reference in my project

 

Imports IWshRuntimeLibrary 

sub main()

Dim neto As New WshNetwork

'map a host admin share drive to u: using a username and password
neto.MapNetworkDrive("u:", "\\myhost\C$", , "myhost\user", "password")

'remove mapping
neto.RemoveNetworkDrive("u:")

end sub

 

This seems to do the trick.

Edited by PlausiblyDamp
Posted

The WSH Runtime library is inbuilt into windows just like subst however subst has issues on win 2000 server with no fix.

After a bit of research I've found net use would be a better alternative.

 

However I prefer to use something that does this in code as I can control timing of events in code better than having to check to see if the shell has finished.

 

Also if an error happens in the shell It's harder to get that error back into the app to trap and accomodate it isn't it? All I'd be able to tell is that the shell failed?

 

I may be missing some tricks or not understanding the implications of using WSH in my code though. After all I'm no expert.

  • Leaders
Posted
Well, those are some good points. Maybe you are better off using WSH DLLs after all; I just hate using DLLs. I can't stand dependancy and version issues.
[sIGPIC]e[/sIGPIC]
Posted

How about using "net use" and shell a .bat file. any other commands could be formated there i.e. user name passwork blah blah blah.

 

Your thoughts

 

ZeroEffect

If you can't find it, Build It.

 

There is no place Like 127.0.0.1 also don't forget 1 + 1 = 10

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...