Question : Windows 7 Batch execution issues

I have a folder with some scripts and files that the scripts calls and i am having some issues running them from the explorer window.

The following script works from an elevated command prompt but not from the explorer using run as administrator any ideas why?

Thanks.


@ECHO OFF
:: Check Windows version
SETLOCAL

:: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
::                                                                         ::
::    Modify the following lines; no quotes for PrnShort and PortIP!       ::
::                                                                         ::
::    The values for PrnType and TargetOS can be found in the INF file     ::
::    that comes with the (extracted) printer driver.                      ::
::                                                                         ::
:: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::

SET PrnName="2nd RICOH"
SET PrnShort="2nd RICOH"
SET PrnType="E-8100 PCL 5c"
SET DrvPath="Path to Driver"
SET InfPath="path to .inf file"
SET PortIP=printer ip address
SET TargetOS="Windows NT"

:: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
::                                                                         ::
::       End of adjustments                                                ::
::                                                                         ::
:: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::

:: Check command line arguments
SET PC=127.0.0.1
ECHO."%PC%" | FINDSTR.EXE /R /C:"[?/]" >NUL && GOTO End
PING.EXE %PC% 2>NUL | FIND.EXE  "TTL=" >NUL || (
      ECHO Computer %PC% is unavailable
      ECHO.
      GOTO End
)

:: Check if the required VBScripts are available in the current directory
SET Error=0
FOR %%A IN (prncnfg prnmngr prndrvr prnport) DO IF NOT EXIST %%A.vbs SET Error=1
IF "%Error%"=="1" GOTO End

:: Check if the printer was installed already
CSCRIPT.EXE //NoLogo prnmngr.vbs -a -s \\%PC% | FIND.EXE /I %PrnShort% >NUL && (
      ECHO A printer named %PrnShort% already exists on %PC%
      ECHO.
      GOTO End
)

:: Check if the printer port was installed already
CSCRIPT.EXE //NoLogo prnport.vbs -a -s \\%PC% | FINDSTR.EXE /E /I "IP_%PortIP%" >NUL && (
      ECHO TCP/IP printer port %PortIP% already exists on %PC%
      ECHO.
      GOTO End
)

:: Prompt the user, and allow him/her to abort the installation
:: Install the driver
CSCRIPT.EXE //NoLogo prndrvr.vbs  -a -m %PrnType% -e %TargetOS% -i %InfPath% -h %DrvPath%
:: Install the local IP print port, type raw, SNMP disabled
CSCRIPT.EXE //NoLogo prnport.vbs -a -r IP_%PortIP% -h %PortIP% -o raw -n 9100 -md
:: Install the local printer with the driver and port we just installed
CSCRIPT.EXE //NoLogo prnmngr.vbs  -a -p %PrnName% -m %PrnType% -r IP_%PortIP%
:: Configure the local printer as not shared and not published in Active Directory
CSCRIPT.EXE //NoLogo prncnfg.vbs  -t -p %PrnShort% -published -shared

:: Done
GOTO End

:End
IF "%OS%"=="Windows_NT" ENDLOCAL

Answer : Windows 7 Batch execution issues

I figured it out

It had to do with the file path apparently windows 7 does not run the batch file in the same location as you are currently in so i had to point it to the location where the VBScripts are located since they are already in windows 7

I also had to remove the following lines of the script for windows 7 as they are not needed

:: Check if the required VBScripts are available in the current directory
SET Error=0
FOR %%A IN (prncnfg prnmngr prndrvr prnport) DO IF NOT EXIST %%A.vbs SET Error=1
IF "%Error%"=="1" GOTO End
Random Solutions  
 
programming4us programming4us