0

In the batch file I am writing which suffices for my need, I'm calling an app (WinMsg.exe) that creates a messagebox using text input. It offers two input switches, -m for text quoted or in a named variable containing text, and -f to read input from a text file, which can be taken from a named variable. The -m limit is 255 chrs while the -f limit is longer. The text I want as input is >255 chrs and is stored in one or more variables. I can use multiple variables with -m but it breaks when the total exceeds 255 chrs. So it appears -f will have to be used. My question is, if -f is expecting a filename, is there a way to "disguise" or somehow redirect my text string variables to be read as if they were actually contained in a file, and without first writing the variable content to a file? I've not seen any questions with quite the same objective and I have doubts that it is even possible but I want to be sure.

7
  • 3
    If you've determined that you must use the -file, option, then you must by virtue of that provide a file as input. What's stopping you from writing to a temporary file reading it in as input and deleting it again? the read/write option is unlikely to be noticeably less efficient.
    – Compo
    Oct 19, 2018 at 16:22
  • While is entirely possible to do that without adverse performance, I'm concerned that if there is a high frequency of writes and the disk is SSD then it would cause a reduction of the disk lifespan. Maybe. If it can be avoided I'd prefer to. Oct 19, 2018 at 16:31
  • I agree with @Compo. Sounds like you are using Bill Stewart's WinMsg
    – user6811411
    Oct 19, 2018 at 16:34
  • 1
    @iYAMGzORM, a ramdisk should do it for you. Still file write/read, but never hits your SSD or spinning disk: google.com/…
    – jwdonahue
    Oct 19, 2018 at 18:46
  • 1
    @jwdonahue, that is a good idea but does require a third party program. The newer versions of Windows Server do allow you to create RAM DISKS with Powershell though. I can't find any documentation on if it can be done on Windows 7 or Windows 10. I think this is because a Server Role needs to be enabled which would not be part of Windows 7 or Windows 10 OS.
    – Squashman
    Oct 19, 2018 at 19:48

1 Answer 1

0

There is absolutely no need to think about your SSD. A high end SSD with plenty of free space in a home computer lasts centuries.

This reads from StdIn by line and displays in a Msgbox

Set Inp = WScript.Stdin
Do Until Inp.AtEndOfStream
    MsgBox Inp.Readline
Loop

Or the whole file

Set Inp = WScript.Stdin
MsgBox Inp.ReadAll

To use

Cscript //nologo "C:\folder\file.vbs" < "c:\windows\win.ini"
4
  • The MTBF is definitely higher than in the past, but don't they still slow down with increased use?
    – jwdonahue
    Oct 20, 2018 at 2:57
  • MTBF is a measure of reliability not lifetime. A 100,000 hour MTBF means that if you run 100,000 of them one will fail each hour.
    – CatCat
    Oct 20, 2018 at 3:41
  • I know what it means. The question still stands, don't they slow down with age? Has that curve changed substantially?
    – jwdonahue
    Oct 21, 2018 at 2:57
  • Under normal circumstances your drive will break with age before it reaches it operating life. Writing win.ini every second to a 1 terabyte drive will use up 1/3000th of your operating life in 34 years.
    – CatCat
    Oct 21, 2018 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.