Hi,
Currently have a .bat file as a User log on startup script in Group Policy to run papercut when a user logs in. Below is what's in the .bat file
Start "" "C:\Program Files (x86)\PaperCut MF Client\pc-client.exe"
This works perfectly fine if the PC has PaperCut MF already installed, however some PC's dont have PaperCut MF installed and gives an error message when the user logs in.
Can this be edited to check if PaperCut MF has been installed/if that location exists and only then run. If its not installed/doesn't exist then don't do anything.
Thanks.
Batch file to run a program ONLY if it is installed on the computer
Moderator: DosItHelp
Re: Batch file to run a program ONLY if it is installed on the computer
Personally I would just redirect the error message to the NUL device. That way it is not seen.
Otherwise a simple IF EXIST command will do the trick.
Type IF /? at the command prompt to view the help for the IF command.
Otherwise a simple IF EXIST command will do the trick.
Type IF /? at the command prompt to view the help for the IF command.
Re: help with .bat file
Very simple:
Code: Select all
@ECHO OFF
SET "PC_BIN=C:\Program Files (x86)\PaperCut MF Client"
IF EXIST "%PC_BIN%\pc-client.exe" (
Start "" "%PC_BIN%\pc-client.exe"
)