Batch file help?


  1. Posts : 2
    Windows 8 Pro x64.
       #1

    Batch file help?


    Hello!
    I am new to these forums and have a question about batch files...
    ...My batch is as follows:
    Code:
    (
    echo <h1 style="color: red">HTML TEXT HERE</h1>
    ) > c:\Users\%username%\Desktop\htm.html
    start iexplore file:\\c:\Users\%username%\Desktop\htm.html
    The problem is, I cannot get it to work. When I load it, CMD opens up for a split second, and disappears. The file isn't made, and Internet Explorer will not open. I have tried to prtsc and get an image so I can see what the error is, but the window sometimes opens immediately, sometime after a few seconds, then goes away too quickly for me to get my bearings and push the button. Human reaction time too slow
    Where has my script gone wrong?
    Last edited by ashley268; 25 Aug 2015 at 05:27. Reason: Forgot a to put [CODE] box in ;p
      My Computer


  2. Posts : 10,485
    W7 Pro SP1 64bit
       #2

    Try:
    Code:
    echo ^<h1 style="color: red"^>HTML TEXT HERE^</h1^> > c:\Users\%username%\Desktop\htm.html
    c:\Users\%username%\Desktop\htm.html
    If this is going to be used by lots of people, then you need different code for where to make the HTML file. Not every user has their desktop folder on the C: drive.
      My Computer


  3. Posts : 2
    Windows 8 Pro x64.
    Thread Starter
       #3

    Thankyou, UsernameIssues!
    Try:
    Code:
    echo ^<h1 style="color: red"^>HTML TEXT HERE^</h1^> > c:\Users\%username%\Desktop\htm.html
    c:\Users\%username%\Desktop\htm.html
    If this is going to be used by lots of people, then you need different code for where to make the HTML file. Not every user has their desktop folder on the C: drive.
    That code worked for me.
    As far as not everyone has desktop on C:\, I am aware of that. I myself have a PC which had %windir% on D:\.
    For what I am doing, though, this will work. C:\ has the Desktop folder on every computer this will be used on.
    Once again, Thanks!
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 21:16.
Find Us