Page 1 of 1

[SOLVED] Command to open Notepad file

Published: August 28, 2019 - 10:34
by nixxax
Hello,

I've been trying for far too long to create a command that opens a Notepad file containing text and displays instructions to the user...
First, is this even possible? If so, I would be very grateful for your advice.

Thank you in advance.

Re: Command to open a Notepad file

Published: August 30, 2019 - 09:40
by Christophe0110
Hello nixxax,

It's doable! I do it in one of my packages.

During the installation, I copy a text file (containing instructions) into the software's installation directory.
Next, in the session_setup (executed when the user logs in), I use the following command:

Code: Select all

run(r'START /B "notepad" "c:\Program Files\tonprogramme\tonfichier.txt"')
However, if you wish to display the text file without waiting for session_setup (during installation), you must create a scheduled task that will open the text file...

A+
Christophe.

Re: Command to open a Notepad file

Published: September 2, 2019 - 8:44 AM
by nixxax
Thanks Christophe for that precise answer.
I'll test it and get back to you with the report.

Re: Command to open a Notepad file

Published: September 3, 2019 - 4:08 PM
by nixxax
So here's my feedback

I successfully created a folder containing the .txt file

However, I'm getting a syntax error message for the file opening command... :(
"exceptions.IndentationError: expected an indented block (line 10, offset 3): run (r'START /B "notepad" "C:\messages\test.txt"')'

Code: Select all

# -*- coding: utf-8 -*-


from setuphelpers import*

def session_setup():



run (r'START /B "notepad" "C:\messages\test.txt"')
Any leads?

Re: Command to open a Notepad file

Published: September 3, 2019 - 9:24 PM
by vcardon
nixxax wrote: Sep 03, 2019 - 4:08 p.m. "exceptions.IndentationError: expected an indented block (line 10, offset 3): run (r'START /B "notepad" "C:\messages\test.txt"')'
Indent your "run" relative to your "def"?

Sincerely.

Re: [SOLVED] Command to open Notepad file

Published: September 4, 2019 - 9:00 AM
by nixxax
That's very kind of you, thank you. But I don't understand your comment... Excuse my ignorance, but what does "indent your 'run' relative to your 'def'" mean?
I'm not a developer, just an IT manager at a school...

Thank you in advance.

Re: [SOLVED] Command to open Notepad file

Published: October 21, 2019 - 10:41
by Christophe0110
Hello nixxax,

You need to use a tab character for your `run` line so that Python understands that your `run` command is part of the `session_setup` function ;).

So this:

Code: Select all

def session_setup():
	run (r'START /B "notepad" "C:\messages\test.txt"')
and not:

Code: Select all

def session_setup():
run (r'START /B "notepad" "C:\messages\test.txt"')
A+