Skip to content

Scheduling exports on Windows

Yudi edited this page Apr 20, 2019 · 3 revisions

We'll be using DiscordChatExporter CLI, Powershell and Task Scheduler.

1. Open a text editor such as Notepad and paste:

# Info:

$TOKEN = "<token>"
$CHANNEL = "<channel>"
$EXEPATH = "<exe>"
$FILENAME = "<name>"
$EXPORTFORMAT = "<format>"
# Available export formats: PlainText, HtmlDark, HtmlLight, Csv


If($TOKENTYPE -match "BOT"){$ISBOTYES = "-b"}
Else{$ISBOTYES = ""}
.\DiscordChatExporter.Cli.exe export -t $TOKEN $ISBOTYES -c $CHANNEL -f $EXPORTFORMAT -o exporttmp

$Date = Get-Date -Format "yyyy-MMM-dd HH-mm"

If($EXPORTFORMAT -match "PlainText"){mv exporttmp -Destination "$EXPORTDIRECTORY\$FILENAME-$Date.txt"}
ElseIf($EXPORTFORMAT -match "HtmlDark"){mv exporttmp -Destination "$EXPORTDIRECTORY\$FILENAME-$Date.html"}
ElseIf($EXPORTFORMAT -match "HtmlLight"){mv exporttmp -Destination "$EXPORTDIRECTORY\$FILENAME-$Date.html"}
ElseIf($EXPORTFORMAT -match "Csv"){mv exporttmp -Destination "$EXPORTDIRECTORY\$FILENAME-$Date.csv"}

2. Replace:

<token> with your Token

<BOT/USER> If the Token is from a bot replace it with BOT, if it's from a user, USER

<channel> with a Channel ID

<exe> with the .exe directory path (e.g. C:\Users\User\Desktop\DiscordChatExporter)

<name> with a filename without spaces

<dir> with the export directory (e.g. C:\Users\User\Documents\Exports)

<format> with one of the available export formats

Make sure not to delete the quotes (")

3. Save the file as filename.ps1 not .txt

Export at Startup

1. Press Windows + R, type shell:startup and press ENTER

2. Paste filename.ps1 or a shortcut to this folder

Scheduling with Task Scheduler

Please notice your computer must be turned on so the exportation can occur.

1. Press Windows + R, type taskschd.msc and press ENTER

2. Select Task Scheduler Library, create a Basic Task and follow the instructions on-screen

3. At 'Start a Program', write powershell -file "C:\path\to\filename.ps1" in Program/script text box

4. Click 'Yes'

5. Click 'Finish'

Special thanks to @RenanYudi

You can’t perform that action at this time.