UG Guru Posted May 23, 2006 Posted May 23, 2006 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 Quote
Leaders snarfblam Posted May 23, 2006 Leaders Posted May 23, 2006 Can you invoke subst.exe (system32 program) through the shell to do this? Quote [sIGPIC]e[/sIGPIC]
UG Guru Posted May 24, 2006 Author Posted May 24, 2006 (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 May 24, 2006 by PlausiblyDamp Quote
Leaders snarfblam Posted May 24, 2006 Leaders Posted May 24, 2006 I would much rather run use a standard Windows command than add an extra dependancy (and extra code) to my project, but that's just me. Quote [sIGPIC]e[/sIGPIC]
UG Guru Posted May 25, 2006 Author Posted May 25, 2006 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. Quote
Leaders snarfblam Posted May 25, 2006 Leaders Posted May 25, 2006 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. Quote [sIGPIC]e[/sIGPIC]
ZeroEffect Posted May 26, 2006 Posted May 26, 2006 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 Quote If you can't find it, Build It. There is no place Like 127.0.0.1 also don't forget 1 + 1 = 10
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.