Using Languard and VBscript

Posted on 2006-04-14
Last Modified: 2010-10-05
I am using languard to run a vbscript that will temporarily map a drive and then remove the mapped drive.  When I run the script locally, it runs without a hitch.  When I push the script to another machine, I get a "800700005 Access denied error".  The error occurrs on the line where the MapNetworkDrive method exists.  My script is below.  I've tried using different credentials, but it doesn't matter. I get the same results.  Any help would be appreciated.

Dim WSHNetwork

Set WSHNetwork = WScript.CreateObject("WScript.Network")

WSHNetwork.MapNetworkDrive "G:", "\\ima4\netlogon\manualupdates"

Const OverwriteExisting = TRUE

Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile "g:\scx2kpx.xslt" , "C:\STRATA\VIEW32\Users\NS000000\scx2kpx.xslt", OverwriteExisting

WSHNetwork.RemoveNetworkDrive "G:"
Question by:InsightMedia
    LVL 26

    Expert Comment

    does net use work for you?

    Author Comment

    Well, yes & no.  The batch file would be much less complicated, I admit.

    I originally created a batch file thtat contained "net use g: \\ima4\netlogon\manualupdates" (which operated seemlessly), but I ran into a snag using the xcopy command.  I want the script/batch file to execute w/no interaction from the users.

    The xcopy command prompts to "create file or directory" & prompts overwrite protection.  I know that both of these are supposed to have the ability to be disabled with /I and /Y respectively, but the "/I" doesn't seem to work.  I even tried "Echo /I|xcopy" with no luck.  That issue prompted to switch to a scripting method, which works flawlessly when excuted at the desktop but not when being pushed to the desktop.

    Any tips here?  Am I making this too complicated?  Am I overlooking something here?  I am getting down to the wire & need to push this out.
    LVL 26

    Accepted Solution


    if net use works for you use it

    i.e from vbscript

    Dim wshShell, objEnvironment
    Set wshShell = CreateObject("WScript.Shell")
    Set objEnvironment = wshShell.Environment("System")
    wshShell.Run objEnvironment.Item("COMSPEC") & " /c net use g: \\ima4\netlogon\manualupdates",, true

    Const OverwriteExisting = TRUE

    Set FSO = CreateObject("Scripting.FileSystemObject")
    FSO.CopyFile "g:\scx2kpx.xslt" , "C:\STRATA\VIEW32\Users\NS000000\scx2kpx.xslt", OverwriteExisting

    Set objEnvironment = Nothing
    Set wshShell = Nothing

    Author Comment

    I didn't know about "COMPSPEC".  I had to add credentials to the net use command & deleted the drive after copying the file.  After that, it worked great!  Thanks for your help!!

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now