Jump to content
Sign in to follow this  

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:
; 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)
$pclist = IniReadSection(@ScriptDir & '\pcs.ini', 'PCS')
If @error Then
    MsgBox(4096, "", "Error occured, probably no INI file.")
    For $i = 1 To $pclist[0][0]
        $tmp = $pclist[$i][1] & "|"
        GUICtrlSetData($combo, $tmp)

While 1
    $msg = GUIGetMsg()
        Case $msg = $GUI_EVENT_CLOSE
        Case $msg = $selectbutton
            $PC = GUICtrlRead($combo)
            Dim $NPC = $PC & '.TXT'
                ;MsgBox(0, "Check Select is:", $NPC)
                Run('Notepad.exe' & $NPC, '',@SW_MAXIMIZE)

Share this post

Link to post
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

Share this post

Link to post
Share on other sites

Thanks !! Works now - is it me or why is this not in the help file I'm looking at ??!!!

Share this post

Link to post
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

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.