Skip to content

Commit fe2c41c

Browse files
committed
Update AutoRunWithCMD.cmd
Currently HIGHLY unfinished, it doesn't even launch correctly in this state.
1 parent 95d25dc commit fe2c41c

File tree

1 file changed

+68
-16
lines changed

1 file changed

+68
-16
lines changed

AutoRunWithCMD.cmd

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,97 @@
22
:Init
33
@echo off
44
cls
5+
if copy AutoRunWithCMD.cmd %temp%\AutoRunWithCMD.cmd (
6+
rem Do nothing :)
7+
) else (
8+
echo.Something wen't wrong, please give the error code "4".
9+
)
510
cd %appdata%
611
:: Debug stuff, making a place for logs
712
if exist "Sanikdah Software" (
813
cd "Sanikdah Software".
9-
goto SSFolderExists
14+
goto :SSFolderExists
1015
) else (
1116
mkdir "Sanikdah Software".
1217
cd "Sanikdah Software".
13-
goto SSFolderExists
18+
goto :SSFolderExists
1419
)
1520

1621
:SSFolderExists
1722
if exist "Ease of Use Command Prompt Auto Run Script" (
1823
cd "Ease of Use Command Prompt Auto Run Script"
19-
goto EoUCPARS-FolderExists
24+
goto :EoUCPARS-FolderExists
2025
) else (
2126
mkdir "Ease of Use Command Prompt Auto Run Script"
2227
cd "Ease of Use Command Prompt Auto Run Script"
2328
goto :FirstTimeUser
2429
)
2530
:EoUCPARS-FolderExists
31+
@echo off
32+
if move %temp%\AutoRunWithCMD.cmd "%appdata%\Sanikdah Software\Ease of Use Command Prompt Auto Run Script\AutoRunWithCMD.cmd" 2> nul (
33+
rem Do nothing :)
34+
) else (
35+
echo. Something went wrong, please give the developer error code "3".
36+
)
37+
2638
echo.>Launched.txt
2739
goto :ReadBackColor
2840

2941
:ReadBackColor
42+
@echo off
3043
set /p color= < Color.txt
3144
ping techflash.ga -n 1 > nul
3245
color %color%
3346
goto :MainMenu
3447

3548

3649
:: Launches if the previous code detects that this is your first time launching the program
37-
@echo off
3850
:FirstTimeUser
51+
@echo off
52+
move %temp%\AutoRunWithCMD.cmd "%appdata%\Sanikdah Software\Ease of Use Command Prompt Auto Run Script\AutoRunWithCMD.cmd" > nul
53+
cls
54+
echo.Hey! Would you like this program to run whenever you launch the command prompt?
55+
echo.(Please note that this is dangerous and will break any other batch script.)
56+
echo.You can ALSO try a safer method, where calling a command in CMD will launch the script.
57+
echo.Which would you like to do?
58+
echo.N/n: Nothing
59+
echo.D/d: Dangerous but more convinient method.
60+
echo.S/s: Safer method.
61+
set /p doesAutoRun=
62+
if not '%doesAutoRun%'=='' set doesAutoRun=%doesAutoRun:~0,1%
63+
if '%doesAutoRun%'=='D' goto :setAutoRun
64+
if '%doesAutoRun%'=='d' goto :setAutoRun
65+
if '%doesAutoRun%'=='n' goto :FirstTimeUser2
66+
if '%doesAutoRun%'=='N' goto :FirstTimeUser2
67+
if '%doesAutoRun%'=='S' goto :saferSetAutoRun
68+
if '%doesAutoRun%'=='s' goto :saferSetAutoRun
69+
echo "%doesAutoRun%" is not a valid option, please try again.
70+
goto :FirstTimeUser
71+
72+
:: Sets the autoRun value
73+
:setAutoRun
74+
echo. Are you CERTAIN that you want to do this? It is difficult to undo!
75+
set /p isSureOfDangerousAutoRun=
76+
if not '%isSureOfDangerousAutoRun%'=='' set isSureOfDangerousAutoRun=%isSureOfDangerousAutoRun:~0,1%
77+
if '%isSureOfDangerousAutoRun%'=='Y' goto :setAutoRun2
78+
if '%isSureOfDangerousAutoRun%'=='y' goto :setAutoRun2
79+
if '%isSureOfDangerousAutoRun%'=='n' goto :FirstTimeUser
80+
if '%isSureOfDangerousAutoRun%'=='N' goto :FirstTimeUser
81+
echo "%isSureOfDangerousAutoRun%" is not a valid option, please try again.
82+
:setAutoRun2
83+
echo.This will NOT work if you have renamed the file.
84+
reg add "HKCU\Software\Microsoft\Command Processor" /v AutoRun ^
85+
/t REG_EXPAND_SZ /d "%appdata%\Sanikdah Software\AutoRunWithCMD.cmd" /f
86+
pause
87+
88+
89+
90+
@echo off
91+
:FirstTimeUser2
3992
title Do you want a tutorial?
4093
echo.Hey! You seem like you ran this program for the first time! Would you like a tutorial on how to use the program?
4194
set /p wantsTutorial=
42-
if not '%wantsTutorial%'=='' set choice=%wantsTutorial:~0,1%
95+
if not '%wantsTutorial%'=='' set wantsTutorial=%wantsTutorial:~0,1%
4396
if '%wantsTutorial%'=='y' goto :wantsTutorial
4497
if '%wantsTutorial%'=='Y' goto :wantsTutorial
4598
if '%wantsTutorial%'=='n' goto :noTutorial
@@ -52,7 +105,7 @@ ECHO.
52105
echo.Placeholder tutorial.
53106
echo.Do you want to see the tutorial again?
54107
set /p wantsTutorial=
55-
if not '%wantsTutorial%'=='' set choice=%wantsTutorial:~0,1%
108+
if not '%wantsTutorial%'=='' set wantsTutorial=%wantsTutorial:~0,1%
56109
if '%wantsTutorial%'=='y' goto :wantsTutorial
57110
if '%wantsTutorial%'=='Y' goto :wantsTutorial
58111
if '%wantsTutorial%'=='n' goto :noTutorial
@@ -66,7 +119,7 @@ goto :FirstTimeUser
66119
:noTutorial
67120
echo.Are you sure?
68121
set /p isSureofNoTutorial=
69-
if not '%isSureofNoTutorial%'=='' set choice=%isSureofNoTutorial:~0,1%
122+
if not '%isSureofNoTutorial%'=='' set isSureofNoTutorial=%isSureofNoTutorial:~0,1%
70123
if '%isSureofNoTutorial%'=='y' goto :isSureofNoTutorial
71124
if '%isSureofNoTutorial%'=='Y' goto :isSureofNoTutorial
72125
if '%isSureofNoTutorial%'=='n' goto :FirstTimeUser
@@ -214,6 +267,7 @@ echo.
214267
echo.Do you understand this aggreement? The creator takes no responsibilty in what can happen if I, the user, breaks part of the program, by using explictly stated as options for DEBUGGING purposes.
215268
echo.
216269
set /p isSureOfDebugOptions=
270+
if not '%isSureOfDebugOptions%'=='' set isSureOfDebugOptions=%isSureOfDebugOptions:~0,1%
217271
if '%isSureOfDebugOptions%'=='y' goto :realDebug
218272
if '%isSureOfDebugOptions%'=='Y' goto :realDebug
219273
if '%isSureOfDebugOptions%'=='n' goto :noDebug
@@ -243,10 +297,11 @@ echo.Welcome to the settings menu!
243297
echo.Here you can modify some settings!
244298
echo.
245299
echo.1: Modify the default color when you start the script.
246-
echo.2: Not yet created just felt like adding this here. :P
300+
echo.2: Set up if you want the script to run automatically, or bind it to a command, or nothing at all.
247301
set /p SettingsChoice=
302+
if not '%SetttingsChoice%'=='' set SettingsChoice=%SettingsChoice:~0,1%
248303
if '%SettingsChoice%'=='1' goto :color
249-
if '%isSureOfDebugOptions%'=='2' goto :Nothing
304+
if '%SettingsChoice%'=='2' goto :FirstTimeUser
250305

251306
:: A label used for when I wanted to add an option but it isn't implemented yet or is in a state where it can't be used. Or if I just haven't though of anything to put in that slot yet.
252307
:Nothing
@@ -266,7 +321,7 @@ set /p ColorCode=
266321
echo.Great! Does this look good?
267322
color %ColorCode%
268323
set /p YesNoColor=
269-
if not '%YesNoColor%'=='' set choice=%YesNoColor%:~0,1%
324+
if not '%YesNoColor%'=='' set choice=%YesNoColor:~0,1%
270325
if '%YesNoColor%'=='y' goto :SetColor
271326
if '%YesNoColor%'=='Y' goto :SetColor
272327
if '%YesNoColor%'=='n' goto :color
@@ -281,7 +336,7 @@ echo.Great! Would you like to save the color code
281336
echo.so that it is applied every time you start the
282337
echo.script?
283338
set /p YesNoColor2=
284-
if not '%YesNoColo2r%'=='' set choice=%YesNoColor2%:~0,1%
339+
if not '%YesNoColo2r%'=='' set choice=%YesNoColor2:~0,1%
285340
if '%YesNoColor2%'=='y' goto :SetColor2
286341
if '%YesNoColor2%'=='Y' goto :SetColor2
287342
if '%YesNoColor2%'=='n' goto :MainMenu
@@ -293,12 +348,9 @@ goto :color
293348
:SetColor2
294349
@echo off
295350
echo %ColorCode% > Color.txt
296-
ping techflash.ga -n 2 > nul
297-
set /p VerifyColorCode= < Color.txt
298-
ping techflash.ga -n 2 > nul
299-
echo. The file now needs some modification, I will open Notepad and show you what you have to do.
351+
echo. The file now needs some modification, I will open your default text editor and show you what you have to do.
300352
echo. (Note that this process is temporary and only needed to fix a strange bug that occurs.)
301-
start %windir%\notepad.exe "%appdata%\Sanikdah Software\Ease of Use Command Prompt Auto Run Script\Color.txt"
353+
start "" "%appdata%\Sanikdah Software\Ease of Use Command Prompt Auto Run Script\Color.txt"
302354
echo. Now, click at the bottom area of the window, your text caret\cursor should be at the line below your color code.
303355
echo. Then press Backspace 2 times, to delete that extra line, and the extra space after the color code.
304356
echo. Now, save and exit the file. And press any key to resume the program with your new color code!

0 commit comments

Comments
 (0)