VBS using LIKE to compare strings “Sub or Function not defined”

前端 未结 4 1757
一整个雨季
一整个雨季 2020-12-10 20:32

I\'m trying to make a script to connect a network printer to a user computer. The script uses the computer name who needs the printer as a parameter.

Printers names

4条回答
  •  感情败类
    2020-12-10 21:05

    A way to do that with select case. This version of instr() is case sensitive, but other versions aren't. instr() returns the position of the found substring, which here is always one.

    select case 1
      case instr(strPrinter, "") + 1
        wscript.echo "empty"
      case instr(strPrinter, "printer_USA")
        wscript.echo "server_USA"
      case instr(strPrinter, "printer_SPAIN")
        wscript.echo "server_SPAIN"
      case instr(strPrinter, "printer_ITALY"), instr(strPrinter, "printer_RUSSIA")
        wscript.echo "other known ones"
      case else
        wscript.echo "not registered"
    end select
    

提交回复
热议问题