Jump to content

Trying to open up notepad + file


Recommended Posts

This script pulls a PC name from an INI file - works fine.

Then I want it to open up a .TXT file which is in the directory using notepad.

But for some reason I can't figure out how to get notepad to open up the file. I have tried all sorts of combinations on the RUN function but still no luck. All I can get is notepad to open up blank or not at all.

Would appreciate some suggestions.

; AutoIt Version:     3.2.0.1
; Language:         English
; Platform:         WinVISTA
; Author:             Matt 
; Script Function:  Opens up notepad with the relevant choice of PC LOG file
; Version:          1.0
; Date:             June 2009

#include <GuiConstants.au3>

GUICreate("Select PC", 170, 66)

$combo = GUICtrlCreateCombo("", 16, 8, 125, 12)
GUICtrlSetData($combo, "")
$selectbutton = GUICtrlCreateButton("Select", 100, 40, 60, 20)
GUISetState()
$pclist = IniReadSection(@ScriptDir & '\pcs.ini', 'PCS')
If @error Then
    MsgBox(4096, "", "Error occured, probably no INI file.")
Else
    For $i = 1 To $pclist[0][0]
        $tmp = $pclist[$i][1] & "|"
        GUICtrlSetData($combo, $tmp)
    Next
EndIf

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $selectbutton
            $PC = GUICtrlRead($combo)
            Dim $NPC = $PC & '.TXT'
                ;MsgBox(0, "Check Select is:", $NPC)
                Run('Notepad.exe' & $NPC, '',@SW_MAXIMIZE)
            Exit
    EndSelect
WEnd
Exit
Link to comment
Share on other sites

you need to add a space after the program name:

Run('Notepad.exe ' & $NPC, '',@SW_MAXIMIZE)

...and if the file path contains spaces it must be wrapped with " "

Edited by oMBRa
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...