>
> "CypherBit" <CypherBit[ at ]discussions.microsoft.com> wrote in message
> news:F2D90718-C10F-4D36-BC31-AF9C7D98F711[ at ]microsoft.com...
> >
> > "Al Dunbar" wrote:
> >
> >>
> >> "CypherBit" <CypherBit[ at ]discussions.microsoft.com> wrote in message
> >> news:73A1EF8C-BB68-47C0-BC0A-0692D3AA7B8B[ at ]microsoft.com...
> >> >I found this code here:
> >> >
http://www.tech-forums.net/showthread.php?s=&threadid=138872 which I'd
> >> > love
> >> > to use, but it has all sorts of weird chars in it. Since I have close
> >> > to
> >> > zero
> >> > (very close) knowledge here I'd greatly appreciate it if some one could
> >> > clean
> >> > it up.
> >> >
> >> > I basically want to run a given program if the first argument is true,
> >> > something else if the 2nd and if not, then something else.
> >> >
> >> > Welcome in advance.
> >>
> >> I tried my hand at it and came up with this:
> >>
> >> '===
> >> dim WshShell
> >>
> >> Set WshShell = WScript.CreateObject("WScript.Shell")
> >>
> >> wscript.echo Wscript.Arguments.Item(2)
> >>
> >> if Wscript.Arguments.Item(1) = "g318606D2" then
> >>
> >> WshShell.run "D:\Program Files\TrueCrypt\TrueCrypt.exe /v " _
> >> & Wscript.Arguments.Item(0) _
> >> & " g:\d1.tc /lz /q", 1, true
> >>
> >> elseif Wscript.Arguments.Item(2) = "PackardBell" then
> >>
> >> WshShell.run "D:\Program Files\2xExplorer\2xExplorer.exe
> >> D:\MyDirsD\Temp\PodcastQueue " _
> >> & Wscript.Arguments.Item(0) & "g:\", 1, true
> >>
> >> else
> >>
> >> WshShell.run "D:\Program Files\Network
> >> Associates\VirusScan\csscan.exe
> >> /target " _
> >> & Wscript.Arguments.Item(0) _
> >> & "g: /secure /quiet /log D:\Program
> >> Files\USBVirusScan\log.txt",
> >> 1, true
> >>
> >> end if
> >>
> >> '===
> >>
> >> I don't know what the extraneous characters were doing there, but some
> >> seemed to be representing a double-quote ("). There are likely errors
> >> still
> >> remaining, as I do not think it likely that the name of the executable to
> >> be
> >> run in the elseif block is "2xEcplorer.exe" or that one of its parameters
> >> would have "g:\" appended to it with no intervening space.
> >>
> >> I do think I have sorted out the three cases for you, though. Now it is
> >> just
> >> a matter of reconstructing the .run parameters correctly.
> >>
> >> /Al
> >>
> >>
> >>
> >
> > Thank you very much for the quick response and cleaning up the code. Could
> > you perhaps help me out a bit more. In the structure in the first if there
> > are multiple & I'd very much like to simplify this if possible, but am
> > running into problems. This is what I currently have:
> >
> > dim WshShell
> >
> > Set WshShell = WScript.CreateObject("WScript.Shell")
> >
> > wscript.echo Wscript.Arguments.Item(2)
> >
> > if Wscript.Arguments.Item(1) = "g318606D2" then
> >
> > WshShell.run "d:\username\programs\usbvirusscan\something.bat" _
> > & Wscript.Arguments.Item(0) , 1, true
> >
> > elseif Wscript.Arguments.Item(2) = "PackardBell" then
> >
> > WshShell.run "d:\username\programs\usbvirusscan\somethingelse.bat" _
> > & Wscript.Arguments.Item(0) , 1, true
> >
> > else
> >
> > WshShell.run "D:\Program Files\Network Associates\VirusScan\csscan.exe
> > /target " _
> > & Wscript.Arguments.Item(0) _
> > & "g: /secure /quiet /log D:\Program Files\USBVirusScan\log.txt", 1, true
> >
> > end if
> >
> > but if I run that from a cmd prompt using wscript code.vbs I get a
> > "Subscript out of range" 800A0009 Line 5, Char 1.
>
> This seems likely because you did not provide three command line arguments
> so that there would be one to correspond to "Wscript.Arguments.Item(2)"
>
> > Any ideas why? What am I doing wrong? BTW I also get errors when running
> > exactly what you posted.
>
> Did you not read where I said: "There are likely errors still remaining"?
> After all, I did not have access to test this on your computer, and my
> computer does not have the programs installed on it that you want to run,
>
> /Al
>
>
>
>