Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
|
Lista Forumurilor Pe Tematici
|
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login
POZE MRRRR'S FORUM (VIEW ONLY)
Nu sunteti logat.
|
Nou pe simpatie: stephy_22 pe Simpatie.ro
| Femeie 22 ani Prahova cauta Barbat 25 - 53 ani |
|
Mrrrr
AdMiN
Inregistrat: acum 17 ani
Postari: 2228
|
|
Normally, if you set Windows to "Restore previous folder windows at logon" (tutorial HERE [1]), whatever folder you leave open when shutting down Windows will open on startup as well.
So if for example I let Windows Explorer open on the folder D:\Temp\MyFolder, then shutdown / restart my PC, it will open that folder automatically.
A few updates ago Windows 11 messed this up and folders no longer start, even if you did the steps of the tutorial mentioned above.
The solution for this was to either simply adding a shortcut to the folders in shell:startup (tutorial HERE [2]), or creating a .bat file containing command lines to open said folders (tutorial HERE [3]). This can be done even for websites even though the browser has no problem in restarting with Windows if I left it open at shutdown, so it might be pointless. But it can also be done for files, and for example PDF files don't start with Windows unless added specifically (I don't use Adobe Reader, so I dunno if it works for it).
While this might seem complicated and overkill, I assure you it's not. Lemme explain.
I have multiple projects I work on at the same time so I need multiple folders to stay open at the same time for days, and new projects appear almost every day so I must leave them open and close the finished ones and so on. Basically I always have some 3-5 folders open at shutdown with things I haven't yet finished. So I need that each morning Windows opens the folders I left open at shutdown and since Windows 11 won't do that anymore I came first with tutorial [2] above, then since it was annoying to keep deleting shortcuts from shell:startup and adding new ones, I made a .bat file I keep on Desktop and edit in Notepad (tutorial [3] above). But this is not user friendly so I wanted to make a GUI to simplify the process even more.
Next I will post the full code of a HTA file that creates, modifies or empties the Open_Folders.bat file that has a shortcut in the shell:startup folder.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <title>Open folders at startup</title> <HTA:APPLICATION APPLICATIONNAME="Folders at startup" VERSION="1.0" SCROLL="no" BORDER="dialog" SINGLEINSTANCE="yes" WINDOWSTATE="normal" ICON="cmmon32.exe"> <script LANGUAGE="VBScript">
'#### GLOBAL VARIABLES AND CONSTANTS Const Wsmall = 880 Const Hsmall = 520 Const Wbig = 980 Const Hbig = 620 Set fso = CreateObject("Scripting.FileSystemObject") filename = CreateObject("WScript.Shell").ExpandEnvironmentStrings("%USERPROFILE%") & "\Desktop\Open Folders.bat" '#### ON HTA START IT WILL SET SIZE AND READ .BAT FILE Sub Window_onLoad
Set oForm = document.forms("PgTx") Set cElem = oForm.Elements
If Window.Screen.availWidth < 1800 Then window.resizeTo Wsmall,Hsmall 'W x H End If If Window.Screen.availWidth >= 1800 Then window.resizeTo Wbig,Hbig 'W x H End If batLocation.value = filename
If fso.FileExists(filename) Then Set f = fso.OpenTextFile(filename) Else message = MsgBox("File " & filename & " does not exist, do you want to continue and create one?", VbYesNo) If message = vbNo Then MsgBox "This application will close. Answer yes next time." Window.Close Else Exit Sub End If End If If fso.GetFile(filename).Size = 0 Then Set outFile = CreateObject("Scripting.FileSystemObject").CreateTextFile(filename, True) outFile.WriteLine "@echo off" Exit Sub End If
Do Until f.AtEndOfStream On Error Resume Next For i = 0 to cElem.length - 1 cElem(i).Value = f.ReadLine Next Loop
f.Close End Sub
'#### CREATE .BAT FILE FROM LINE FIELDS - IF EMPTY, FILE WILL BE EMPTIED Sub CreateBat
Set outFile = fso.CreateTextFile(filename, True) Set oForm = document.forms("PgTx") Set cElem = oForm.Elements On Error Resume Next For i = 0 to cElem.length - 1 If len(cElem(i).Value) > 10 Then outFile.WriteLine cElem(i).Value End If Next
outFile.Close
MsgBox "Done!"
If fso.GetFile(filename).Size = 0 Then Set outFile = CreateObject("Scripting.FileSystemObject").CreateTextFile(filename, True) outFile.WriteLine "@echo off" outFile.Close Window.Location.Reload() Exit Sub End If
End Sub
'#### CLEAR ALL FIELDS EXCEPT FILE LOCATION Sub Clear Set oForm = document.forms("PgTx") Set cElem = oForm.Elements
For i = 0 to cElem.length - 1 cElem(i).Value = "" Next End Sub
'#### OPEN .BAT FILE Sub RunFile Set objShell = CreateObject("Shell.Application") objShell.ShellExecute filename, , , NORMAL_WINDOW End Sub
</script> </head>
<body> File location <br> <input type="text" id="batLocation" size="150" maxlength="700" title="to change this, open the current HTA file in notepad and edit the filename variable on line 23 of the code"/> <p> <form name="PgTx" id="PgTx" action="etc" method="etcetc"> Examples (<font style="color: blue;">open folder</font>, <font style="color: green;">open file</font>, <font style="color: red;">open site</font>):<br>  <font style="color: blue;">Start %SystemRoot%\explorer.exe "D:\SteamLibrary\steamapps\common\Red Dead Redemption 2"</font><br>  <font style="color: green;">Start "C:\Program Files\Google\Chrome\Application\chrome.exe" "http://mrrrr.3xforum.ro/"</font><br>  <font style="color: red;">Start "C:\Program Files\Tracker Software\PDF Editor\PDFXEdit.exe" "C:\Program Files\Tracker Software\PDF Editor\PDF_VE.pdf"</font> <p> <input type="text" id="0" name="tx" size="150" maxLength="700" style="text-align:left" title="INFORMATION: if .bat file is empty field will be @echo off, so that if you open the .bat file there's no error"/><br> <input type="text" id="1" name="tx" size="150" maxLength="700" style="text-align:left"/><br> <input type="text" id="2" name="tx" size="150" maxLength="700" style="text-align:left"/><br> <input type="text" id="3" name="tx" size="150" maxLength="700" style="text-align:left"/><br> <input type="text" id="4" name="tx" size="150" maxLength="700" style="text-align:left"/><br> <input type="text" id="5" name="tx" size="150" maxLength="700" style="text-align:left"/><br> <input type="text" id="6" name="tx" size="150" maxLength="700" style="text-align:left"/><br> <input type="text" id="7" name="tx" size="150" maxLength="700" style="text-align:left"/><br> <input type="text" id="8" name="tx" size="150" maxLength="700" style="text-align:left"/><br> <input type="text" id="9" name="tx" size="150" maxLength="700" style="text-align:left"/><br> <input type="text" id="10" name="tx" size="150" maxLength="700" style="text-align:left"/><br> <input type="text" id="11" name="tx" size="150" maxLength="700" style="text-align:left"/><br> <input type="text" id="12" name="tx" size="150" maxLength="700" style="text-align:left"/><br> <input type="text" id="13" name="tx" size="150" maxLength="700" style="text-align:left"/><br> </form> <p> <input type="button" onclick="CreateBat" value="Generate" style="background-color: lime; width: 200px;" >   <input type="button" onclick="Clear" value="Clear" style="background-color: yellow; width: 200px;" >   <input type="button" onclick="RunFile" value="Open .BAT" style="background-color: aqua; width: 200px;" > <font style="background-color: aqua";>(opens all files and folders in the .BAT file)</font> </center>
</body> </html> |
_______________________________________
|
|
pus acum 1 an |
|