call a .bat file from VB  
Author Message
SystemHack





PostPosted: Wed Mar 29 18:52:12 CST 2006 Top

VB Scripts >> call a .bat file from VB

Hello I would like to either call a bat file from with a vb login script or
incorporate into the existing vbscript. The vbscript works fine for home
office it's the remote branches I need to figure out. Thank you in advanced!

the following is part of the .bat file that I want work with:

IF SACRAMENTO==%BRANCH% GOTO SACRAMENTO
IF NEWARK==%BRANCH% GOTO NEWARK
IF SANTEE==%BRANCH% GOTO SANTEE
IF TACOMA==%BRANCH% GOTO TACOMA
IF SPOKANE==%BRANCH% GOTO SPOKANE
IF DELTA==%BRANCH% GOTO DELTA
IF PORTLAND==%BRANCH% GOTO PORTLAND
IF SALTLAKE==%BRANCH% GOTO SALTLAKE
IF LASVEGAS==%BRANCH% GOTO LASVEGAS
IF TUCSON==%BRANCH% GOTO TUCSON
IF BAKERSFIELD==%BRANCH% GOTO BAKERSFIELD

GOTO ENDERROR
:SACRAMENTO
REM ***WINDOWS 2000 DRIVE MAPPING
net use n: /d
NET USE L: \\SACRAMENTOSVR\USERSAC\%USERNAME% /PERSISTENT:NO

GOTO END
:NEWARK
REM ***WINDOWS 2000 DRIVE MAPPING
NET USE L: \\NEWARKSVR\USERNEWARK\%USERNAME%

GOTO END
:SANTEE
REM ***WINDOWS 2000 DRIVE MAPPING
NET USE L: \\SANTEESVR\USERSANTEE\%USERNAME%

GOTO END
:TACOMA
REM ***WINDOWS 2000 DRIVE MAPPING
net use l: \\TACOMASVR\USERTACOMA\%USERNAME% /PERSISTENT:NO

GOTO END
:SPOKANE
REM ***WINDOWS 2000 DRIVE MAPPING
NET USE L: \\SPOKANESVR\USERSPOKANE\%USERNAME% /PERSISTENT:NO

GOTO END
:DELTA
REM ***WINDOWS 2000 DRIVE MAPPING
NET USE L: \\DELTASVR\USERDELTA\%USERNAME% /PERSISTENT:NO

GOTO END
:PORTLAND
REM ***WINDOWS 2000 DRIVE MAPPING
NET USE L: \\PORTLANDSVR\USERPORTLAND\%USERNAME% /PERSISTENT:NO

GOTO END
:SALTLAKE
REM ***WINDOWS 2000 DRIVE MAPPING
NET USE L: \\SALTLAKESVR\USERSALTLAKE\%USERNAME% /PERSISTENT:NO

GOTO END
:LASVEGAS
REM ***WINDOWS 2000 DRIVE MAPPING
NET USE L: \\LASVEGASSVR1\USERLASVEGAS\%USERNAME% /PERSISTENT:NO

GOTO END
:TUCSON
REM ***WINDOWS 2000 DRIVE MAPPING
NET USE L: \\TUCSONSVR\USERTUCSON\%USERNAME% /PERSISTENT:NO

GOTO END
:BAKERSFIELD
REM ***WINDOWS 2000 DRIVE MAPPING
NET USE L: \\BAKERSFIELDSVR\USERBAKERSFIELD\USERNAME% /PERSISTENT:NO

GOTO END
:ENDERROR
@ECHO ****YOUR LOGIN SCRIPT DID NOT RUN CORRECTLY...PLEASE CALL FOR HELP AND
REPORT THE FOLLOWING ERROR****
@ECHO ****YOUR BRANCH NAME VARIABLE IS NOT SET*****
PAUSE
GOTO VERYEND
:END
rem net time \\stlrsvr02 /set /yes
CALL %LOGONSERVER%\NETLOGON\exuser.bat
:VERYEND

--
Felix

Visual Studio355  
 
 
Marty





PostPosted: Wed Mar 29 18:52:12 CST 2006 Top

VB Scripts >> call a .bat file from VB
Launching scripts/executables is easy with the .Run method in WScript.Shell, you
can choose the Windows style (minimized, hidden, etc.) and whether or not you
want to wait for it to finish:
http://msdn.microsoft.com/library/en-us/script56/html/6f28899c-d653-4555-8a59-49640b0e32ea.asp

If you need access to the program's output (stdout) then try the .Exec method in
WScript.Shell:
http://msdn.microsoft.com/library/en-us/script56/html/5593b353-ef4b-4c99-8ae1-f963bac48929.asp




> Hello I would like to either call a bat file from with a vb login script or
> incorporate into the existing vbscript. The vbscript works fine for home
> office it's the remote branches I need to figure out. Thank you in advanced!
>
> the following is part of the .bat file that I want work with:
>
> IF SACRAMENTO==%BRANCH% GOTO SACRAMENTO
> IF NEWARK==%BRANCH% GOTO NEWARK
> IF SANTEE==%BRANCH% GOTO SANTEE
> IF TACOMA==%BRANCH% GOTO TACOMA
> IF SPOKANE==%BRANCH% GOTO SPOKANE
> IF DELTA==%BRANCH% GOTO DELTA
> IF PORTLAND==%BRANCH% GOTO PORTLAND
> IF SALTLAKE==%BRANCH% GOTO SALTLAKE
> IF LASVEGAS==%BRANCH% GOTO LASVEGAS
> IF TUCSON==%BRANCH% GOTO TUCSON
> IF BAKERSFIELD==%BRANCH% GOTO BAKERSFIELD
>
> GOTO ENDERROR
> :SACRAMENTO
> REM ***WINDOWS 2000 DRIVE MAPPING
> net use n: /d
> NET USE L: \\SACRAMENTOSVR\USERSAC\%USERNAME% /PERSISTENT:NO
>
> GOTO END
> :NEWARK
> REM ***WINDOWS 2000 DRIVE MAPPING
> NET USE L: \\NEWARKSVR\USERNEWARK\%USERNAME%
>
> GOTO END
> :SANTEE
> REM ***WINDOWS 2000 DRIVE MAPPING
> NET USE L: \\SANTEESVR\USERSANTEE\%USERNAME%
>
> GOTO END
> :TACOMA
> REM ***WINDOWS 2000 DRIVE MAPPING
> net use l: \\TACOMASVR\USERTACOMA\%USERNAME% /PERSISTENT:NO
>
> GOTO END
> :SPOKANE
> REM ***WINDOWS 2000 DRIVE MAPPING
> NET USE L: \\SPOKANESVR\USERSPOKANE\%USERNAME% /PERSISTENT:NO
>
> GOTO END
> :DELTA
> REM ***WINDOWS 2000 DRIVE MAPPING
> NET USE L: \\DELTASVR\USERDELTA\%USERNAME% /PERSISTENT:NO
>
> GOTO END
> :PORTLAND
> REM ***WINDOWS 2000 DRIVE MAPPING
> NET USE L: \\PORTLANDSVR\USERPORTLAND\%USERNAME% /PERSISTENT:NO
>
> GOTO END
> :SALTLAKE
> REM ***WINDOWS 2000 DRIVE MAPPING
> NET USE L: \\SALTLAKESVR\USERSALTLAKE\%USERNAME% /PERSISTENT:NO
>
> GOTO END
> :LASVEGAS
> REM ***WINDOWS 2000 DRIVE MAPPING
> NET USE L: \\LASVEGASSVR1\USERLASVEGAS\%USERNAME% /PERSISTENT:NO
>
> GOTO END
> :TUCSON
> REM ***WINDOWS 2000 DRIVE MAPPING
> NET USE L: \\TUCSONSVR\USERTUCSON\%USERNAME% /PERSISTENT:NO
>
> GOTO END
> :BAKERSFIELD
> REM ***WINDOWS 2000 DRIVE MAPPING
> NET USE L: \\BAKERSFIELDSVR\USERBAKERSFIELD\USERNAME% /PERSISTENT:NO
>
> GOTO END
> :ENDERROR

> REPORT THE FOLLOWING ERROR****

> PAUSE
> GOTO VERYEND
> :END
> rem net time \\stlrsvr02 /set /yes
> CALL %LOGONSERVER%\NETLOGON\exuser.bat
> :VERYEND
>
> --
> Felix