Question Locked

VBS Script

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi All

I seem to be having this problem whereby I am trying to copy a little java applet from a network location. On my local PC, this works fine, however when I place this in the GPO BAT login script, the drives, which have been deleted, are still mapping when it gets to the part of calling the file from the so called mapped drive which hasnt mapped yet. Thus the program does not load. As one cannot use UNC in BAT files, I attempted to use a vbs script, but I cannot find any code to accomplish this. Has anyone got a solution for this?

6 replies

by drummerb0y

You could map the drive temporarily in the .bat for the copying portion, then remove it before it (I assume) starts mapping drives for the user logging in. And by the way, I've used UNC paths in batch files many times. So if I could see the script, I might be able to help you fix it.

by ron_jeff

echo "--> Mapping COMMON to H:"
net use h: \\server01\common
echo "--> Mapping SERVICES to I:"
net use i: \\server01\services

i:
cd \SonarAuthStartApp\
start javaw -jar SonarAuthStart.jar

by scott_heath

I have copied files using UNC paths at a command prompt before, so it should work fine in a batch\command script.

So what exactly is it you want to do with VBScript? Copy using UNC or map a drive? I can show you how to do either, just let me know.

by ron_jeff

Hi
Thanks for the prompt replies. As I had mentioned, it seems the script finishes executing before the the drives are mapped. So I am attempting to launch the program from a UNC path with a vbs script, as one cannot do it in a BAT file.
Here is the vbs script which is called from the login BAT file.

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "\\server01\services\SonarAuthStartApp\SonarAuthStart.jar", 1, true

by drummerb0y

Something like:

:mapping
echo "--> Mapping COMMON to H:"
net use h: \\server01\common
echo "--> Mapping SERVICES to I:"
net use i: \\server01\services

:loop
if exist I: (goto Sonar) else (ping 127.0.0.1 -n 10)
goto loop

:Sonar
i:
cd \SonarAuthStartApp\
start javaw -jar SonarAuthStart.jar

The "Loop" (if you can really call it a real loop) just use pings to "wait" until it checks for the mapped drive again. It will continue checking until it finds it, then moves on to running the Java app. Hope this helps. In my opinion, you should run your mapping and the program all from your VBScript.

This discussion is closed to new replies.