Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Oct 2007
    Location
    Wirral, UK
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a VBScript which does some calculations and writes the results to a text file. The last thing it does is pops up a message saying 'Now open C:\Text2.txt' What I would really like it to do is open Notepad itself and display the file on screen. I have Windows XP Annoyances by David Karp (my favourite technical author alongside John Walkenbach!) which gives some code for doing this:

    Call Runprogram("notepad c:/temp2.txt", False)
    .
    .
    .
    Sub RunProgram(filename, Wait)
    Set WshShell = WScript.CreateObject("WScript.Shell")
    RetVal = WshShell.Run(filename, Wait)
    End Sub

    ...but it doesn't work. It doesn't crash but nothing happens. I have noticed, however, that after the script has run Task Manager shows Notepad running as a process. Does this mean that all that is required is to make the Notepad execution visible?

    TC

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    That is correct. You can accomplish this by changing the line

    RetVal = WshShell.Run(filename, Wait)

    to

    RetVal = WshShell.Run(filename, 1, Wait)

    1 = "Activates and displays a window". See Run Method (Windows Script Host).

  3. #3
    Lounger
    Join Date
    Oct 2007
    Location
    Wirral, UK
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='771831' date='22-Apr-2009 21:00']That is correct. You can accomplish this by changing the line

    RetVal = WshShell.Run(filename, Wait)

    to

    RetVal = WshShell.Run(filename, 1, Wait)

    1 = "Activates and displays a window". See Run Method (Windows Script Host).[/quote]

    Thanks Hans, just tested it and it works as desired!

    TC

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •