From 9a2987e77d7c0624017ddac81992a4cf51e36660 Mon Sep 17 00:00:00 2001 From: Yudi Date: Sun, 29 Sep 2019 17:55:02 -0300 Subject: [PATCH] Fixed script and added '-WindowStyle Hidden' and '-ExecutionPolicy ByPass' to taskschd command --- Scheduling-exports-on-Windows.md | 43 ++++++++++++++++---------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/Scheduling-exports-on-Windows.md b/Scheduling-exports-on-Windows.md index facb8a3..2dba203 100644 --- a/Scheduling-exports-on-Windows.md +++ b/Scheduling-exports-on-Windows.md @@ -1,55 +1,54 @@ -We'll be using [DiscordChatExporter CLI](https://github.com/Tyrrrz/DiscordChatExporter/releases/latest), Powershell and Task Scheduler. +We'll be using [DiscordChatExporter CLI](https://github.com/Tyrrrz/DiscordChatExporter/releases/latest), PowerShell and Task Scheduler. # **1.** Open a text editor such as Notepad and paste: ```powershell # Info: https://github.com/Tyrrrz/DiscordChatExporter/wiki -$TOKEN = "" -$TOKENTYPE = "" -$CHANNEL = "" -$EXEPATH = "" -$FILENAME = "" -$EXPORTDIRECTORY = "" -$EXPORTFORMAT = "" +$TOKEN = "token" +$TOKENTYPE = "BOT/USER" +$CHANNEL = "channel" +$EXEPATH = "exe" +$FILENAME = "name" +$EXPORTDIRECTORY = "dir" +$EXPORTFORMAT = "format" # Available export formats: PlainText, HtmlDark, HtmlLight, Csv cd $EXEPATH If($TOKENTYPE -match "BOT"){$ISBOTYES = "-b"} Else{$ISBOTYES = ""} -.\DiscordChatExporter.Cli.exe export -t $TOKEN $ISBOTYES -c $CHANNEL -f $EXPORTFORMAT -o exporttmp +.\DiscordChatExporter.Cli.exe export -t $TOKEN $ISBOTYES -c $CHANNEL -f $EXPORTFORMAT -o export.tmp $Date = Get-Date -Format "yyyy-MM-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"} +If($EXPORTFORMAT -match "PlainText"){mv export.tmp -Destination "$EXPORTDIRECTORY\$FILENAME-$Date.txt"} +ElseIf($EXPORTFORMAT -match "HtmlDark"){mv export.tmp -Destination "$EXPORTDIRECTORY\$FILENAME-$Date.html"} +ElseIf($EXPORTFORMAT -match "HtmlLight"){mv export.tmp -Destination "$EXPORTDIRECTORY\$FILENAME-$Date.html"} +ElseIf($EXPORTFORMAT -match "Csv"){mv export.tmp -Destination "$EXPORTDIRECTORY\$FILENAME-$Date.csv"} exit ``` **2.** Replace: - `` with your [Token](https://github.com/Tyrrrz/DiscordChatExporter/wiki/Obtaining-Token-and-Channel-IDs) + `token` with your [Token](https://github.com/Tyrrrz/DiscordChatExporter/wiki/Obtaining-Token-and-Channel-IDs) - `` If the Token is from a bot replace it with `BOT`, if it's from a user, `USER` + `BOT/USER` If the Token is from a bot replace it with `BOT`, if it's from a user, `USER` - `` with a [Channel ID](https://github.com/Tyrrrz/DiscordChatExporter/wiki/Obtaining-Token-and-Channel-IDs) + `channel` with a [Channel ID](https://github.com/Tyrrrz/DiscordChatExporter/wiki/Obtaining-Token-and-Channel-IDs) - `` with the .exe directory path (e.g. C:\Users\User\Desktop\DiscordChatExporter) + `exe` with the .exe **directory's path** (e.g. C:\Users\User\Desktop\DiscordChatExporter) - `` with a filename without spaces + `name` with a filename without spaces - `` with the export directory (e.g. C:\Users\User\Documents\Exports) + `dir` with the export directory (e.g. C:\Users\User\Documents\Exports) - `` with one of the available export formats + `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 @@ -69,7 +68,7 @@ Please notice your computer must be turned on so the exportation can occur. [ ![](https://i.imgur.com/m2DKhA8.png) ](https://i.imgur.com/3gHkF0t.png) -**3.** At 'Start a Program', write `powershell -file "C:\path\to\filename.ps1"` in Program/script text box +**3.** At 'Start a Program', write `powershell -file -ExecutionPolicy ByPass -WindowStyle Hidden "C:\path\to\filename.ps1"` in the Program/script text box ![](https://i.imgur.com/FGtWRod.png)