Saved Bookmarks
| 1. |
Solve : IF THEN statement in a Batch file? |
|
Answer» So I am looking for some help. I need to do an IF THEN in a batch file. I currently have the below script removing some printers and installing others. But I would like to add an IF THEN so that if the new printer is installed, the bat file ends. @echo offCould you explain a bit more clearly what you want? That isn't really a batch file, it's more a LIST of CALLS to the prnmngr VBS script. Did you mean "if the new printer is already installed"? Please explain what you're doing and why and what you want to do and why. He wants to have an IF statement that goes off when a new printer is added.. This doesn't seem possible unless you try printing a test page in a FOR loop and use ERRORLEVEL to indicate that the file couldn't be printed, thus saying that no new printer was installed, this would only work if he didn't already have a printer connected.See Comments in Red Quote @echo offQuote from: Woogi on April 14, 2009, 03:52:33 PM See Comments in RedWrong syntax. IF EXIST \\HOU-02SVR\HOU-Parthenon GOTO STOP That's PROBABLY why...Quote from: Helpmeh on April 14, 2009, 04:45:56 PM Wrong syntax. IF EXIST \\HOU-02SVR\HOU-Parthenon GOTO STOP Well I am not saying that would even work, but that is the just what I am trying to do. I am trying to have the batch file check to see if a network printer is already installed, and if it is, quit the script, but if it isn't, then continue.Quote from: Woogi on April 14, 2009, 08:03:57 PM Well I am not saying that would even work, but that is the just what I am trying to do. I am trying to have the batch file check to see if a network printer is already installed, and if it is, quit the script, but if it isn't, then continue.Well, I just glanced over it, and that's what I saw.Woogi, you could use a vbs to enumerate the printers on a particular server and do something based on whether or not the printer you are asking about is in the list. Quote from: Dias de verano on April 15, 2009, 12:16:06 AM Woogi, you could use a vbs to enumerate the printers on a particular server and do something based on whether or not the printer you are asking about is in the list. Yeah not that good with VBQuote from: Woogi on April 15, 2009, 07:40:03 AM Yeah not that good with VB But you are running admin scripts? Quote from: Dias de verano on April 15, 2009, 10:12:35 AM But you are running admin scripts? And how do the two correlate?Code: [Select]cscript//nologo prnmngr.vbs -l | find/i "\\hou-02svr\HOU-Menil" || ( Cscript %windir%\system32\prnmngr.vbs -ac -p "\\hou-02svr\HOU-Menil" )untested however code will run faster in full vbscript.Quote from: Woogi on April 17, 2009, 07:49:21 AM And how do the two correlate? You are like a person paid as a truck driver who does not know how to operate the gears or clutch.Quote from: Dias de verano on April 17, 2009, 09:26:49 AM You are like a person paid as a truck driver who does not know how to operate the gears or clutch. No, I am like a truck driver who cant build a transmission. Ons inability to do one, does not prevent him from doing the other.Quote from: Reno on April 17, 2009, 09:19:20 AM Code: [Select]cscript//nologo prnmngr.vbs -l | find/i "\\hou-02svr\HOU-Menil" || ( Thank you for your help, I will try this out. |
|