Tuesday, July 16, 2024

2024-07-16 - Prank Scripts

     One day in class several months ago, I left my laptop logged in and went to the bathroom. No one had ever touched my stuff before in an objectionable way so I didn't worry about it. Unbeknownst to me, this is a thing Doug takes advantage of at his job at BYU all the time as an administrator. He likes to teach people lessons so they learn to be better. So he wrote a bunch of scripts which he keeps on a jump drive, handy and ready at a moments notice so he can go onto someone's computer and plug in his thumb drive and activate any of like fifty scripts he has written to make life difficult for the person when they get back to their computer,. The one he activated on me was the one that locked my screen every ten seconds when logged in. So ten seconds after I logged in, it logged me back out, and this process would repeat until the problem was solved. 

    Ultimately the fix was actually pretty simple, you just go into task manager and end a background process using the command prompt and the shenanigans end abruptly. 

    A note about this, no CMD was open while it was doing this, it did it 'silently'. So to the uninitiated, this just looks like some sudden Windows error that requires a reboot. And I don't know, I never tried this, but a reboot would probably fix it. But it would be funny if Doug somehow found a way to keep it activated through a reboot. I wouldn't put it past him. 

    After he did this I asked him if I could have a copy of that script and he said no. I asked why not and he said because I want you to learn how to write them yourself. I asked him what he did to write his and he told me he wanted me to figure it out myself. But, he said, even though usually he discourages using ChatGPT when troubleshooting, he said that actually in this case, ChatGPT would be fine. 

    So I did set out to try and start doing this. 

    I started by straight up asking ChatGPT to write a script in Bash that does what I want. And it did, but it wasn't perfect. This does happen to be one of ChatGPT's selling points, that you can tell it what program or script you want it to write in and it'll do it. And supposedly, it'll work, it just won't be super clean. Well, I will amend that. It will look like it should. But it will likely add stuff that doesn't need to be added, things that seem like they should work won't because of an update or because the OS has changed and doesn't do things that way anymore, or it'll use a method that isn't used much anymore because there's a better one because it thinks that you meant this when you didn't think that it mattered and so you thought it would assume that instead or whatever. This is why you need to know how to code yourself if using it. But this doesn't mean that you're a lost cause if you don't know how to code. This can help. But Doug has recommended to me that he just wants me to use it and then look at everything ChatGPT is doing, go through the code it created for me, and make sure I understand what it's doing. You can even ask it about each part. 

    I wrote several iterations. Unfortunately it didn't occur to me several months ago when doing this to write about what I did, so I can't actually say for sure what I did. Okay. I did this in early May apparently. I will append what conversations I had with ChatGPT about two scripts I created. 

    Now, I did ask Doug what scripts I could create, and he told me he didn't want to tell me anything I would find too challenging, he wanted me to have a fighting chance of figuring out how to do it myself so he suggested I start with an annoying capslock auto-activation and deactivation every ten seconds. So I did. Here's the ChatGPT conversation from that, which includes the code it gave me and things I said to ask it to change. 

I'd like to create a batch script that toggles caps lock every five seconds.
ChatGPT

Sure, you can create a batch script to toggle Caps Lock every five seconds. Here's how you can do it:

batch

@echo off
:loop
echo Toggling Caps Lock
powershell -command "[console]::CapsLock.toggle()"
timeout /t 5 /nobreak >nul
goto loop

Save this script with a .bat extension (e.g., toggle_capslock.bat) and run it. It will toggle Caps Lock every five seconds. You can stop the script by closing the command prompt window or pressing Ctrl+C.

 

Powershell said: Method invocation failed because [System.Boolean] does not contain a method named 'toggle'.
ChatGPT

Apologies for that oversight. Let's use a different approach. Here's an updated version of the script:

batch

@echo off
set "Toggle=0"
:loop
if %Toggle%==0 (
echo Turning Caps Lock on
set "Toggle=1"
) else (
echo Turning Caps Lock off
set "Toggle=0"
)
powershell -command "[console]::CapsLock = %Toggle%"
timeout /t 5 /nobreak >nul
goto loop

This script toggles Caps Lock by changing its state between on and off every five seconds. Save it as a .bat file and run it.

 

does this script stop running just by closing the shell?
ChatGPT

No, this script will continue running even if you close the command prompt window. To make it stop when the window is closed, you can catch the CTRL_CLOSE_EVENT and exit gracefully. Here's the updated script:

batch

 

@echo off
setlocal EnableDelayedExpansion
REM Register a CTRL_CLOSE_EVENT handler
set "handler=toggle_capslock_handler"
powershell -Command "Register-EngineEvent -SourceIdentifier ([Microsoft.PowerShell.ConsoleHost]::Closing) -Action { & '%handler%' }"
REM Initialize toggle state
set "Toggle=0"
:loop
if !Toggle! == 0 (
echo Turning Caps Lock on
set "Toggle=1"
) else (
echo Turning Caps Lock off
set "Toggle=0"
)
powershell -command "[console]::CapsLock = $(!Toggle!)"
timeout /t 5 /nobreak >nul
goto loop
:toggle_capslock_handler
REM Unregister the event handler and exit
powershell -Command "Unregister-Event -SourceIdentifier ([Microsoft.PowerShell.ConsoleHost]::Closing)"
exit /b

This script registers a handler for the CTRL_CLOSE_EVENT, so when you close the command prompt window, it will gracefully unregister the event handler and exit the script. Save it as a .bat file and run it.

 

how do I make it stop step by step in layman terms
ChatGPT

To make the script stop step by step, we'll add a way to stop it when you want. Let's add a simple mechanism: Pressing any key will stop the script.

Here's the modified script:

batch

@echo off
setlocal EnableDelayedExpansion
REM Register a CTRL_CLOSE_EVENT handler
set "handler=toggle_capslock_handler"
powershell -Command "Register-EngineEvent -SourceIdentifier ([Microsoft.PowerShell.ConsoleHost]::Closing) -Action { & '%handler%' }"
REM Initialize toggle state
set "Toggle=0"
REM Show a message indicating how to stop the script
echo Press any key to stop the script.
:loop
if !Toggle! == 0 (
echo Turning Caps Lock on
set "Toggle=1"
) else (
echo Turning Caps Lock off
set "Toggle=0"
)
powershell -command "[console]::CapsLock = $(!Toggle!)"
timeout /t 5 /nobreak >nul
REM Check if a key has been pressed, if so, exit the loop
if defined stop (
goto :toggle_capslock_handler
) else (
goto :loop
)
:toggle_capslock_handler
REM Unregister the event handler and exit
powershell -Command "Unregister-Event -SourceIdentifier ([Microsoft.PowerShell.ConsoleHost]::Closing)"
exit /b

Now, when you run the script, it will display a message saying "Press any key to stop the script." Once you press any key, the script will stop.

 

I don't want it to be that easy to stop the script. I want it to run without the prompt open, and to stop by killing it in the task manager, located next to system tasks.
ChatGPT

Got it. We'll modify the script to run silently in the background without any visible prompt, and it will only stop when you manually end it through the Task Manager.

Here's the updated script:

batch

@echo off
REM Register a CTRL_CLOSE_EVENT handler
set "handler=toggle_capslock_handler"
powershell -Command "Register-EngineEvent -SourceIdentifier ([Microsoft.PowerShell.ConsoleHost]::Closing) -Action { & '%handler%' }"
REM Initialize toggle state
set "Toggle=0"
:loop
if %Toggle%==0 (
powershell -command "[console]::CapsLock = $true"
set "Toggle=1"
) else (
powershell -command "[console]::CapsLock = $false"
set "Toggle=0"
)
timeout /t 5 /nobreak >nul
goto :loop
:toggle_capslock_handler
REM Unregister the event handler and exit
powershell -Command "Unregister-Event -SourceIdentifier ([Microsoft.PowerShell.ConsoleHost]::Closing)"
exit /b

With this script, there will be no visible prompt or indication that the script is running. It will continue toggling the Caps Lock state every 5 seconds until you manually end it through the Task Manager.

 

Why is it using powershell in the script? this is a .bat file running in cmd.
ChatGPT

You're correct. We don't need PowerShell commands within a batch script to toggle Caps Lock. Here's a revised version of the script that only uses native batch commands:

batch

@echo off
REM Register a CTRL_CLOSE_EVENT handler
set "handler=toggle_capslock_handler"
powershell -Command "Register-EngineEvent -SourceIdentifier ([Microsoft.PowerShell.ConsoleHost]::Closing) -Action { & '%handler%' }"
REM Initialize toggle state
set "Toggle=0"
:loop
if %Toggle%==0 (
echo Turning Caps Lock on
set "Toggle=1"
) else (
echo Turning Caps Lock off
set "Toggle=0"
)
rem Simulating Caps Lock key press
powershell -command "$wsh = New-Object -ComObject WScript.Shell; $wsh.SendKeys('{CAPSLOCK}')"
timeout /t 5 /nobreak >nul
goto :loop
:toggle_capslock_handler
REM Unregister the event handler and exit
powershell -Command "Unregister-Event -SourceIdentifier ([Microsoft.PowerShell.ConsoleHost]::Closing)"
exit /b

This script uses the SendKeys method from Windows Script Host (via PowerShell) to simulate pressing the Caps Lock key. The rest of the functionality remains the same as in the previous script. This version will work within a batch script without relying on PowerShell commands.

 

This script worked however it is running in an open window. What command makes it run silently and can you give me that altered script?
ChatGPT

To make the script run silently without displaying any window, you can use a utility called nircmd along with a technique called "self-deleting batch files". Here's the altered script:

batch

@echo off
REM Register a CTRL_CLOSE_EVENT handler
set "handler=toggle_capslock_handler"
powershell -Command "Register-EngineEvent -SourceIdentifier ([Microsoft.PowerShell.ConsoleHost]::Closing) -Action { & '%handler%' }"
REM Initialize toggle state
set "Toggle=0"
:loop
if %Toggle%==0 (
echo Turning Caps Lock on
set "Toggle=1"
) else (
echo Turning Caps Lock off
set "Toggle=0"
)
rem Simulating Caps Lock key press
powershell -command "$wsh = New-Object -ComObject WScript.Shell; $wsh.SendKeys('{CAPSLOCK}')"
timeout /t 5 /nobreak >nul
goto :loop
:toggle_capslock_handler
REM Unregister the event handler and exit
powershell -Command "Unregister-Event -SourceIdentifier ([Microsoft.PowerShell.ConsoleHost]::Closing)"
REM Deleting the batch file
del "%~f0"
exit /b

And here's how you run it silently:

Download nircmd from NirSoft and place the executable (nircmd.exe) in the same directory as your batch script.
Create a shortcut for your batch script.
Right-click on the shortcut, choose "Properties", and in the "Target" field, add cmd /c start /min before the path to your batch script. For example:
bash

 

cmd /c start /min "Path\to\your\batch\script.lnk"

This will launch the batch script minimized without any window visible. When the script finishes executing, it will automatically delete itself.

the cmd is still coming up. Is there a way to do this using %SystemRoot%\System32\cmd.exe for which is defined by Windows default the environment variable ComSpec with that file name as value. cmd.exe?
ChatGPT

Yes, you can utilize %ComSpec% to execute the batch script silently. Here's the updated script:

batch

@echo off
REM Register a CTRL_CLOSE_EVENT handler
set "handler=toggle_capslock_handler"
powershell -Command "Register-EngineEvent -SourceIdentifier ([Microsoft.PowerShell.ConsoleHost]::Closing) -Action { & '%handler%' }"
REM Initialize toggle state
set "Toggle=0"
:loop
if %Toggle%==0 (
echo Turning Caps Lock on
set "Toggle=1"
) else (
echo Turning Caps Lock off
set "Toggle=0"
)
rem Simulating Caps Lock key press
powershell -command "$wsh = New-Object -ComObject WScript.Shell; $wsh.SendKeys('{CAPSLOCK}')"
timeout /t 5 /nobreak >nul
goto :loop
:toggle_capslock_handler
REM Unregister the event handler and exit
powershell -Command "Unregister-Event -SourceIdentifier ([Microsoft.PowerShell.ConsoleHost]::Closing)"
REM Deleting the batch file
del "%~f0"
exit /b

And here's how you can execute it silently using %ComSpec%:

batch

%ComSpec% /c start /min "Title" "Path\to\your\batch\script.bat"

Replace "Title" with any title you want for the window (can be empty), and "Path\to\your\batch\script.bat" with the path to your batch script. This command will run the batch script silently without displaying any window.

 

It said this: Unable to find type [Microsoft.PowerShell.ConsoleHost]. At line:1 char:41 + ... neEvent -SourceIdentifier ([Microsoft.PowerShell.ConsoleHost]::Closin ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (Microsoft.PowerShell.ConsoleHost:TypeName) [], RuntimeException + FullyQualifiedErrorId : TypeNotFound
ChatGPT

It seems there's an issue with the PowerShell command in the script. Let's simplify it to unregister the event handler and remove the dependency on PowerShell's console host. Here's the updated script:

batch

@echo off
REM Initialize toggle state
set "Toggle=0"
:loop
if %Toggle%==0 (
echo Turning Caps Lock on
set "Toggle=1"
) else (
echo Turning Caps Lock off
set "Toggle=0"
)
rem Simulating Caps Lock key press
powershell -command "$wsh = New-Object -ComObject WScript.Shell; $wsh.SendKeys('{CAPSLOCK}')"
timeout /t 5 /nobreak >nul
goto :loop
:cleanup
REM Deleting the batch file
del "%~f0"
exit /b

Then, you can run it silently using %ComSpec% like this:

batch

 

%ComSpec% /c start /min "Title" "Path\to\your\batch\script.bat"

Replace "Title" with any title you want for the window (can be empty), and "Path\to\your\batch\script.bat" with the path to your batch script. This command will run the batch script silently without displaying any window.

 

OKAY BUT i CANT USE ANY COLINS OR SLASHES IN FILE NAMES
ChatGPT

I see, let's simplify the script and make sure it can run without colons or slashes in the file names:

batch

@echo off
REM Initialize toggle state
set "Toggle=0"
:loop
if %Toggle%==0 (
echo Turning Caps Lock on
set "Toggle=1"
) else (
echo Turning Caps Lock off
set "Toggle=0"
)
rem Simulating Caps Lock key press
powershell -command "$wsh = New-Object -ComObject WScript.Shell; $wsh.SendKeys('{CAPSLOCK}')"
timeout /t 5 /nobreak >nul
goto :loop
:cleanup
REM Deleting the batch file
del "%~f0"
exit /b

You can run this script silently using %ComSpec% as before:

batch

 

%ComSpec% /c start /min "" "Path_to_your_batch_script.bat"

Replace "Path_to_your_batch_script.bat" with the actual path to your batch script. This command will run the batch script silently without displaying any window.

 

I want the script to activate immediately and then continue every ten seconds
ChatGPT

Got it. Here's the modified script to activate Caps Lock immediately and then toggle it every ten seconds:

batch

@echo off
REM Turn on Caps Lock initially
powershell -command "$wsh = New-Object -ComObject WScript.Shell; $wsh.SendKeys('{CAPSLOCK}')"
REM Infinite loop to toggle Caps Lock every ten seconds
:loop
timeout /t 10 /nobreak >nul
REM Simulating Caps Lock key press to toggle
powershell -command "$wsh = New-Object -ComObject WScript.Shell; $wsh.SendKeys('{CAPSLOCK}')"
goto :loop

This script will turn on Caps Lock immediately upon execution and then toggle it every ten seconds. There is no need for a separate cleanup section as the script will keep running until you manually stop it."


    Now, ultimately, the code I did end up with looked like this i Batch:

@echo off


REM Initialize toggle state

set "Toggle=0"


:loop

if %Toggle%==0 (

    echo Turning Caps Lock on

    set "Toggle=1"

) else (

    echo Turning Caps Lock off

    set "Toggle=0"

)

rem Simulating Caps Lock key press

powershell -command "$wsh = New-Object -ComObject WScript.Shell; $wsh.SendKeys('{CAPSLOCK}')"

timeout /t 5 /nobreak >nul

goto :loop

    And this code did work. There was a problem, it displayed the CMD, which we wanted to be silent and in the background. This is where Doug sggested that I write a second script to go with it' which will tell the computer to run it in the background. 

    This second scr4ipt was in VBS:

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

     That was the whole script. And the to activate both scripts, Doug helped me write a third script to go with it which would activate both of those scripts. This was in Batch. 

copy capslock_every_5_seconds.bat %temp%\capslock.bat

start invis.vbs "%temp%\capslock.bat"

 This worked. But then there was a new problem. We tried it on multiple computers and it worked great, we were about to open bottles of wine and all that crap when I went and grabbed my thumb drive from the computer running the script at that tine and made a terrible discovery. The script deactivates the second you pull the drive hosting it. So since everything is running of the thumb drive and now it's gone, the whole point of the script is null and void. I am supposed to be able to go up to a computer, quickly plug this in and run any of the scripts I wish, and pull the drive and walk away with no evidence I did anything, except that now the computer is misbehaving until you cancel the process. So that's not happening. 

    I ended up not resolving this issue for the past few months because I got all the parts I needed for my weather display project and we got to work on that. And it took so much work and ideas and so many pieces and planning were involved that this whole prank script fell out of my head. I did remember that was a thing but I just completely forgot about it due to all the other many things I had to worry about, such as passing CompTIA A+ Core II at the time. So all extra time then only went to the weather display and all serious classwork went to passing the certification. 

    However, getting the Flipper Zero reinvigorated my desire to continue this on a more immediate basis because I want prank scripts to load into it and have it inject. 

    However I did work on a second script the next day that also technically did work but also suffered from the same problem of deactivating the second the thumb drive containing it was removed. Doug and I worked on trying to write into code to get it to plant itself in a temp file on windows computers even once the drive is pulled so it continues, but this seemed to do nothing. 

    So here's the ChatGPT conversation for the second script:

I want to create another script. This one will log your computer user off every ten seconds once logged in. It needs to run silently, on other wirds, no command prompt, using a seperate vbs script that simply comtains "CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False", then a .bat script that actually activates the log off.ChatGP

 

Certainly! Here's how you can achieve that:
  1. First, create a VBScript file (let's name it silent.vbs) with the content:
vbs

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

This script will run another script silently without displaying any command prompt.

  1. Then, create a batch file (let's name it logoff.bat) with the content:
batch

 

 
@echo off :loop timeout /t 10 /nobreak >nul cscript //nologo silent.vbs "shutdown.exe /l" goto loop

This batch file will run the VBScript silently every 10 seconds, which in turn will execute the command to log off the user (shutdown.exe /l).

Place both files (silent.vbs and logoff.bat) in the same directory. When you run logoff.bat, it will continuously log off the user every 10 seconds silently.

 

how is this process going to show up in task manager? I can just cancel this by ending it in task manager right?

ChatGPThe process will indeed show up in Task Manager, typically as cscript.exe (for the VBScript execution) and cmd.exe

Yes, you can end the process from Task Manager to stop the logoff script. In Task Manager, you can find the processes under the "Processes" tab, typically listed as cscript.exe and cmd.exe. However, if someone is actively monitoring Task Manager, they could potentially identify and terminate the process.

I tried running this. my computer did a security warning prompt every time it was about to activate so it wouldn't do it automatically and then once I clicked run, it would then open the cmd which is unacceptable, and showed in cmd the file path where I am storing the script, and then: wscript.exe "invis.vbs" "logoff.bat"

 

ChatGPT

Got it, it seems like the security settings on your system are causing the issue. To work around this, you can try a different approach by using PowerShell, which might bypass the security warnings.

First, let's create a PowerShell script to run the logoff command silently. Here's how you can do it:

  1. Create a PowerShell script file (let's name it logoff.ps1) with the following content:
powershell

$logoffCommand = "shutdown.exe /l" $shell = New-Object -ComObject "WScript.Shell" $shell.Run($logoffCommand, 0, $false)

This script will log off the current user silently when executed.

Next, create a batch file to continuously run the PowerShell script every 10 seconds without showing any command prompt. Here's how:

  1. Create a batch file (let's name it logoff.bat) with the following content:
batch

@echo off :loop powershell.exe -WindowStyle Hidden -File "logoff.ps1" timeout /t 10 >nul goto loop

This batch file will continuously run the PowerShell script every 10 seconds without displaying any command prompt.

Place both files (logoff.ps1 and logoff.bat) in the same directory. When you run logoff.bat, it will start logging off the user every 10 seconds without displaying any visible prompts or windows.

 

forget the silent.vbs thing, just make me a .bat script that locks the screen every ten seconds after someone re-enters their login.

ChatGPT

Sure, here's a batch script that will lock the screen every ten seconds after someone logs in:

batch

 

@echo off :loop timeout /t 10 /nobreak >nul rundll32.exe user32.dll,LockWorkStation goto loop

Save this code in a file named lockscreen.bat.

When someone logs in and runs this script, it will wait for ten seconds and then lock the screen. It will repeat this process indefinitely.


    Now I did start working on this last Wednesday or Thursday again for the first time in months, but Doug was busy helping other students who had to take their certification exams. And otherwise he didn't wa t to help me because he wanted me to try. However, I was very tired from the gym. I am in Ketosis and I haven't resolved how to get enough electrolytes without sugar or carbs or artificial flavoring which does sometimes spike your insulin which would kick you out of ketosis. I tried pickle juice and was dissatisfied with this because it has to stay refrigerated and otherwise I didn't know if it was actually helping since I wasn't exactly drinking a whole jar of juice. So when I did my usual workout, I started to get sluggish and feel like I was about to slightly lose my balance and was really tired. And when I got to class, I couldn't think hardly at all. I ended up leaving class early which is very unusual for me. I think Doug must have taken from this that I did my best and couldn't figure it out. 

    However, I want to say that I did ask Doug a few days earlier why his scripts kept running even with the thumb drive pulled. He said, well, you're writing these scripts in batch, batch doesn't keep running by default in temp memory unless you pull a lot of strings to get it to do so. I asked him what he did to solve this problem and he said that he wrote his scripts in VBS. I asked why. I was surprised he told me because until now he was unwilling to divulge any of his secrets. I even asked him if he could furnish me with a list of the kinds of scripts he wrote and he said no because he wanted me to build up to more complicated ones and some he may never tell me. So he told me that he used VBS because it stays in memory even after the source is pulled. 

    I asked ChatGPT about this and found out that actually there's a number of languages that do this, not just VBS. I found that Python was one of them. Since my weather display is all in Python, I thought I would just go with that. I tried to convert everything in batch to python, this turned out to be quite a mess. I was already aware of the concept that spoken languages have words other languages don't. Likewise, things don't translate the same. In Brazilian Portuguese for example, back in the 1970s when my dad was there, guys would call attractive girls 'airplanes' in that language. This is sort of like the equivalent to calling an attractive girl a fox here in American English. You get why attractive girls would be called airplanes, but it's weird and if you translate it directly, it makes no sense because you're missing all of that context. 

    We have a similar problem when converting a batch script to python. First of all, python had to import utilities from the OS, it had it import time because of the ten second delay for caps lock and locking the screen, it had it import all sorts of things. Batch didn't have to do this. I asked Doug why. He said because a lot of those packages are pre-loaded into the system for Batch. 


    Monday 2024-07-15


    When I told Doug about my efforts trying to convert batch to python, and how there was a translation problem because direct translation causes problems, there's unnecessary code in the python version that actually doesn't apply in python but ChatGPT doesn't know this. So Doug asked me why I picked Python and I said well, I have been doing a lot of python stuff with the weather display, might as well stick with it and keep learning it. He told me he had bad news. What? Python doesn't come pre-installed in Windows. He asked me, do you remember when we started working on your weather display, we had to install it? Sort of I guess. Yeah. 

    The problem sank in slowly. Oh dear! Okay, so what can I do instead? Wait, ChatGPT said that there were a number of languages that do this thing where once activated, the scripts just run from memory and don't need the source script anymore. Doug then said, yeah but Windows only comes with batch and VBS pre-installed. Oh, so I have to do VBS. He said no, not necessarily. You can have the script load itself into memory. I said yeah but we already tried that and it didn't work. Why not just do VBS. He said well, the reason why I don't recommend you do VBS is because for all of these other languages such as batch, there's lots of documentation on how to use it. And VBS? There is not that much documentation on VBS. I said, yeah, but you were able to do it...without thinking about who I was talking to. Doug of all people. Guy can figure out anything! Tss. He said yeah, I did, but it was very, very, very hard. And it took a lot of time and tons of experimentation. I realized, yeah, so VBS is not a likely solution for me. But then he said he thought maybe he knew what was wrong with loading it into memory and how to fix it. 

    Doug and I were looking at the code. This is when Doug suddenly had a thought. He went to Stack Overflow and tried something from there that didn't work and then we ended up on another site https://ss64.com/nt/start.html, 'Start a program, command or batch script, opens in a new/separate command prompt window.' 

Syntax
      START "title" [/D path] [options] "command" [parameters]

Key:
   title       Text for the CMD window title bar (required.)
   path        Starting directory.
   command     The command, batch file or executable program to run.
   parameters  The parameters passed to the command.

Options:
   /MIN         Start window Minimized.
   /MAX         Start window Maximized.
   /W or /WAIT  Start application and wait for it to terminate.
                (see below)

   /LOW         Use IDLE priority class.
   /NORMAL      Use NORMAL priority class.
   /ABOVENORMAL Use ABOVENORMAL priority class.
   /BELOWNORMAL Use BELOWNORMAL priority class.
   /HIGH        Use HIGH priority class.
   /REALTIME    Use REALTIME priority class.
/B Start application without creating a new window. In this case Ctrl-C will be ignored - leaving Ctrl-Break as the only way to interrupt the application. /I Ignore any changes to the current environment, typically made with SET. Use the original environment passed to cmd.exe /NODE The preferred Non-Uniform Memory Architecture (NUMA) node as a decimal integer. /AFFINITY The processor affinity mask as a hexadecimal number. The process will be restricted to running on these processors. Options for running 16-bit Windows programs, on Windows 10 only: /SEPARATE Start in separate memory space. (more robust) 32 bit only. /SHARED Start in shared memory space. (default) 32 bit only.

Always include a TITLE this can be a simple string like "My Script" or just a pair of empty quotes ""
According to the Microsoft documentation, the title is optional, but depending on the other options chosen you can have problems if it is omitted.

If command is an internal cmd command or a batch file then the command processor CMD.exe is run with the /K switch. This means that the window will remain after the command has been run.

In a batch script, a START command without /wait will run the program and just continue, so a script containing nothing but a START command will close the CMD console and leave the new program running.

Document files can be invoked through their file association just by typing the name of the file as a command.
e.g. START "" MarchReport.DOC will launch the application associated with the .DOC file extension and load the document.

To minimise any chance of the wrong exectuable being run, specify the full path to command or at a minimum include the file extension: START "" notepad.exe

If you START an application without a file extension (for example WinWord instead of WinWord.exe)then the PATHEXT environment variable will be read to determine which file extensions to search for and in what order.
The default value for the PATHEXT variable is: .COM;.EXE;.BAT;.CMD

Start - run in parallel

The default behaviour of START is to instantiate a new process that runs in parallel with the main process. For arcane technical reasons, this does not work for some types of executable, in those cases the process will act as a blocker, pausing the main script until it’s complete.

In practice you just need to test it and see how it behaves.

Often you can work around this issue by creating a one line batch script (runme.cmd ) to launch the executable, and then call that script with START runme.cmd

Start /Wait

The /WAIT option should reverse the default 'run in parallel' behaviour of START but again your results will vary depending on the item being started, for example:

Echo Starting
START /wait "job1" calc.exe
Echo Done

The above will start the calculator and wait before continuing. However if you replace calc.exe with Winword.exe, to run Word instead, then the /wait will stop working, this is because Winword.exe is a stub which launches the main Word application and then exits.

A similar problem will occur when starting a batch file, by default START will run the equivalent of CMD /K which opens a second command window and leaves it open. In most cases you will want the batch script to complete and then just close its CMD console to resume the initial batch script. This can be done by explicitly running CMD /C ...

Echo Starting
START /wait "demojob" CMD /c demoscript.cmd
Echo Done

Add /B to have everything run in a single window.

In a batch file, an alternative is to use TIMEOUT to delay processing of individual commands.

START vs CALL

Starting a new process with CALL, is very similar to running START /wait, in both cases the calling script will (usually) pause until the second script has completed.

Starting a new process with CALL, will run in the same shell environment as the calling script. For a GUI application this makes no difference, but a second 'called' batch file will be able to change variables and pass those changes back to the caller.

In comparison START will instantiate a new CMD.exe shell for the called batch. This will inherit variables from the calling shell, but any variable changes will be discarded when the second script ends.

Run a program

To start a new program (not a batch script), you don’t have to use CALL or START, just enter the path/file to be executed, either on the command line or within a batch script. This will behave as follows:

  • On the command line, CMD.EXE does not wait for the application to terminate and control immediately returns to the command prompt.
  • Running a program from within a batch script, CMD.EXE will pause the initial script and wait for the application to terminate before continuing.
  • If you run one batch script from another without using either CALL or START, then the first script is terminated and the second one takes over.

Search order:

  • Running a program from CMD will search first in the current directory and then in the PATH.
  • Running a program from PowerShell will search first in the PATH and then in the current directory.
  • The Windows Run Line (win+r) will search first in App Paths [defined in HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths] and then the PATH

Multiprocessor systems

Processor affinity is assigned as a hex number but calculated from the binary positions (similar to NODRIVES)

Hex Binary        Processors
 1 00000001 Proc 1 
 3 00000011 Proc 1+2
 7 00000111 Proc 1+2+3
 C 00001100 Proc 3+4 etc

Specifying /NODE allows processes to be created in a way that leverages memory locality on NUMA systems. For example, two processes that communicate with each other heavily through shared memory can be created to share the same preferred NUMA node in order to minimize memory latencies. They allocate memory from the same NUMA node when possible, and they are free to run on processors outside the specified node.

start /NODE 1 app1.exe
start /NODE 1 app2.exe

These two processes can be further constrained to run on specific processors within the same NUMA node.

In the following example, app1 runs on the low-order two processors of the node, while app2 runs on the next two processors of the node. This example assumes the specified node has at least four logical processors. Note that the node number can be changed to any valid node number for that computer without having to change the affinity mask.

start /NODE 1 /AFFINITY 0x3 app1.exe
start /NODE 1 /AFFINITY 0xc app2.exe

Running executable (.EXE) files

When a file that contains a .exe header, is invoked from a CMD prompt or batch file (with or without START), it will be opened as an executable file. The filename extension does not have to be .EXE. The file header of executable files start with the 'magic sequence' of ASCII characters 'MZ' (0x4D, 0x5A) The 'MZ' being the initials of Mark Zibowski, a Microsoft employee at the time the file format was designed.

Command Extensions

If Command Extensions are enabled, external command invocation through the command line or the START command changes as follows:

Non-executable files can be invoked through their file association just by typing the name of the file as a command. (e.g. WORD.DOC would launch the application associated with the .DOC file extension). This is based on the setting in HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ext\OpenWithList, or if that is not specified, then the file associations - see ASSOC and FTYPE.

When executing a command line whose first token is the string CMD without an extension or path qualifier, then CMD is replaced with the value of the COMSPEC variable. This prevents picking up CMD.EXE from the current directory.

When executing a command line whose first token does NOT contain an extension, then CMD.EXE uses the value of the COMSPEC environment variable. This prevents picking up CMD.EXE from the current directory.

When executing a command line whose first token does NOT contain an extension, then CMD.EXE uses the value of the PATHEXT environment variable to determine which extensions to look for and in what order. The default value for the PATHEXT variable is: .COM;.EXE;.BAT;.CMD Notice the syntax is the same as the PATH variable, with semicolons separating the different elements.

When searching for an executable, if there is no match on any extension, then looks to see if the name matches a directory name. If it does, the START command launches the Explorer on that path. If done from the command line, it is the equivalent to doing a CD /D to that path.

Errorlevels

If the command is successfully started ERRORLEVEL =unchanged, typically this will be 0 but if a previous command set an errorlevel, that will be preserved (this is a bug).
If the command fails to start then ERRORLEVEL = 9059
START /WAIT batch_file - will return the ERRORLEVEL specified by EXIT

START is an internal command.

Examples

Start a program and wait for it to complete before continuing:

START "" /wait autocad.exe

Open a file with a particular program:

START "job1" "C:\Program Files\Microsoft Office\Winword.exe" "D:\Docs\demo.txt"

Run a minimised Login script:

CMD.exe /C START "Login Script" /Min CMD.exe /C Login.cmd

In this example the first CMD session will terminate almost immediately and the second will run minimised.

Open Windows Explorer and list the files in the current folder (.) :

C:\any\old\directory> START .

Open a webpage in the default browser, note the protocol is required (https://):

START https://ss64.com

Open a webpage in Microsoft Edge:

%windir%\explorer.exe microsoft-edge:https://ss64.com
or with a hard-coded path:
"C:\Program Files (x86)\Microsoft Edge\Application\msedge.exe" https://ss64.com

"%windir%\explorer.exe shell:Appsfolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge" https://ss64.com

Connect to a new printer: (this will setup the print connection/driver):

START \\print_server\printer_name

Start an application and specify where files will be saved (Working Directory):

START /D C:\Documents\ /MAX "Maximised Notes" notepad.exe

“Do not run; scorn running with thy heels” ~ Shakespeare, The Merchant of Venice

     Doug took from this one thing, which was that he needed to change the activation script from this:

start invis.vbs "%temp%\capslock.bat

    to

 start /D C:\ invis.vbs "%temp%\capslock.bat

     It now works like a charm. We activated it, we watched first to make sure it was working properly and that something wasn't broken, and then after caps lock had activated and deactivated once, then we pulled the drive and it kept going! 











This has been Truncat3d 00000000111100010100110______________end of line

Wednesday, July 3, 2024

2024-07-03 - Bluetooth audio quality deteriorates when a game starts

    Bluetooth audio quality deteriorates when a game starts

    I was opening a game abd listening to iTunes while doing so, and all of the sudden the audio switched and the audio was terrible. It took some time, lots of  closing and reopening things and changing sound settings in iTunes and messing with sound settings and almost rebooting the system when I happened to google the right thing finally and a guy explained that this was because of opening a game and the headphones, if they have a microphone, go from being regular headphones to then being a headset since it's assumed that you're playing with others and talking to them. 
    This guy explained that in windows 11 go SYSTEM > SOUND > scroll past the OUTPUT section to the INPUT section. 


    So to regain the audio quality, the guy explained not to disable your headphones, and instead, particularly if not using the MICROPHONE, switch the input device bullet-mark pictured here at the HEADSET setting back to MICROPHONE above it for the desired INPUT device.  This will probably take a few seconds to change back to normal audio quality.
    Of course be mindful that sometimes Windows doesn't want to cooperate and the proper setting will already be selected. I found at least once that when I switched it back and fourth between HEADSET and MICROPHONE for the INPUT device, it would eventually switch back to good audio quality regardless of which setting was selected. Like as I write this, it is set to use the headset but the audio is good. Tss!
    He explained "They virtually work like 2 inputs, one is just audio out to you, the other is audio in and out, meaning they drop quality so that you can use the microphone on your headset over Bluetooth. 

This has been Truncat3d 00000000111100010100110______________end of line

Wednesday, May 8, 2024

2024-05-08 - Creating a batch script to turn the trackpad on my Win11 GPD Pocket 3 laptop on/off

     I have had this problem with my GPD Pocket 3 laptop for a year now where anytime I am typing, which I do a fair amount of, every few minutes, one of my finger inadvertently and unwittingly touches the trackpad, which selects the document I am typing in a different spot and I don't notice for a few seconds that it's typing in a different spot. Then I have to find where it has been typing and select just that text that was relocated from the middle of other words that make no sense now, and make sure I get out of it and make sure that what I am selecting matches what I was trying to say and what I had already typed in the part of the document that I was intending to type it. This is a thing that always takes at least a minute to fix and it happens real frequently. 

    This has annoyed me so much that I tried to find a way to turn the trackpad on or off but the GPD Pocket 3 has a sort of custom layout for the outermost keys like the Function keys which share functionality with the number keys, the shift keys, there's only one command key, the tab, caps lock and both shift keys are smaller and the right shift key is especially small, the up and down arrow keys are half the size of the left and right arrow keys, and the function keys and number keys at the top of the keyboard are all half sized keys. Some buttons are missing altogether. And there are common laptop keys that are missing from this layout. There's a display on/off key and a trackpad on/off key on many laptops, which I do not have. 

    So I tried the next nest thing and looked in settings for these options to turn it on or off. But because this is a niche product and some changes had to be made to the common settings in order to get the tablet touch screen this laptop uses to work like a windows laptop screen with a little forward facing camera built in to be used as a webcam, even though it cannot be used with Windows Hello to unlock my laptop, this has caused that the trackpad is actually treated like a regular HID-compliant mouse. So there's no way to turn the trackpad off through settings because of that. 

    I eventually found that I could turn the trackpad off through Device Manager, but it was labelled as an HID-compliant mouse. So I turned it off and the typing problem has stopped but there is now the rare occasion that I could use a mouse and don't have one. So I have to use the touch screen to do things, which can be a little complicated. 

    So I realized that scripts are very useful for things like this. I already use scripts to manage certain things on my server which I need done regularly, so I looked up if I could use a batch script to turn devices on or off in Device Manager. The answer that I found was yes. 

    So here we go. Since I have no clue what I am doing I did some research and found some stuff that says I need to do this:

"@echo off

set /p choice="Enter 'enable' to enable the trackpad or 'disable' to disable it: "


if /i "%choice%"=="enable" (

    powershell -Command "Get-PnpDevice -FriendlyName '*trackpad*' | Enable-PnpDevice -Confirm:$false"

    echo Trackpad has been enabled.

) else if /i "%choice%"=="disable" (

    powershell -Command "Get-PnpDevice -FriendlyName '*trackpad*' | Disable-PnpDevice -Confirm:$false"

    echo Trackpad has been disabled.

) else (

    echo Invalid choice. Please enter 'enable' or 'disable'.

)


pause"

    I have no idea if this is going to work and I thought it prudent to check stuff beforehand because where I found these parts, I can't actually be sure that they work the way I want to. For all I know I just grabbed a command that turns off a crucial process in the Registry like the display so nothing will display anymore and I have to reinstall windows or something. 

    I had asked Doug, my instructor about this and intended that he tell me what he thought before I proceeded incase I was doing something I didn't want to do. After all, I use this laptop for everything, more than I use my desktop at home now. 

    He came up with the idea to write a PowerShell script that would search whether the device was enabled or disabled, and would use an "if" statement in the code of the script to have it respond accordingly: if enabled, disable it, if disabled, enable it. So he then went to the Microsoft documentation the command "Get-PnpDevice" and all of the flags he would need to use with it to make it work. 

    So then he wrote this:

   if ((Get-PnpDevice -InstanceId "HID\VID_258A&PID_000C&MI_01&COL01\7&23463051&0&0000").Status -eq "OK")

{

    Get-PnpDevice -InstanceId "HID\VID_258A&PID_000C&MI_01&COL01\7&23463051&0&0000" | Disable-PnpDevice -Confirm:$false

}

else

{

    Get-PnpDevice -InstanceId "HID\VID_258A&PID_000C&MI_01&COL01\7&23463051&0&0000" | Enable-PnpDevice -Confirm:$false

}


He had me open PowerShell ISE and paste this code which he emailed me. And unfortunately while he was troubleshooting how to get it wo work because there were a few hurtles, I had to go to a SCRUM meeting and discuss what I was working on and what research assignment we should do over the weekend with a bunch of classmates and listen to what they were doing. 

    So when I got back he had already solved everything. But he told me what he did. PowerShell ISE stands for Integrated Scripting Environment, which is basically an IDE for PowerShell. IDE stands for Integrated Development Environment. It has features to make writing, testing and debugging easier. 


    Alright, so first hurtle, on my particular laptop, you cannot have the script search the trackpad to disable and enable it. On the GPD Pocket 3, because of the way it is built and the way the drivers work, it treats the trackpad as a mouse. So it is actually under "Mice and other pointing devices" in Device Manager. And it is called HID-Compliant Mouse. So firstly, having the script search for the trackpad to change its status won't work. And if you have it search for all mouses, on my particular device, for reasons that are unknown to me, I have like ten mouse devices on my laptop. So how do we get the script to search the right one every time. 

    Status     Class           FriendlyName                                                InstanceId     

------            -----           ------------                                                        ----------     

Unknown    HIDClass  USB Optical Mouse                                        USB\VID_046D...

Unknown    Mouse        HID-compliant mouse                                    HID\VID_222A...                    

OK               Mouse       Logitech HID-compliant Unifying Mouse     HID\VID_046D...                    

Error             Mouse      HID-compliant mouse                                     HID\VID_258A...

OK                Mouse      Logitech HID-compliant Unifying Mouse      HID\VID_046D...                   

OK                Mouse      HID-compliant mouse                                     HID\VID_046D...                 

Unknown      Mouse      HID-compliant Optical Mouse                        HID\VID_046D...

OK                Mouse      Logitech HID-compliant Unifying Mouse      HID\VID_046D...

OK                Mouse      Logitech HID-compliant Unifying Mouse      HID\VID_046D...

Unknown      Mouse      Logitech HID-compliant Cordless Mouse       HID\VID_046D...

So the device with the error status is the trackpad that has already been disabled. So that makes it easy to find. However, every single one of these devices has an individual Instance ID. So Doug ran the command "(Get-PnpDevice -FriendlyName "*Mouse*" -Status ERROR).InstanceId". Putting parenthesis around the initial command to check the status of the device tells the shell to treat the whole thing like an object, so that he can then ask it at the end to tell him the Instance ID. It gave us the full ID. The Instance ID is the part of the whole script inserted earlier that starts with HID/VID. 

    Next hurtle. There's an annoying problem with PowerShell scripts. You can't just double-click on the script to make it run. If you double-click any normal batch script for instance, it simply runs. However, with a PS1 (PowerShell script), it simply opens the code for the script in notepad--just in case you wanted to look at it for some reason. Nice, real helpful! So he moved the icon to my documents folder I think, and then created a shortcut from that on the desktop. The nice thing about shortcuts, is that they always activate the script, even if it is a PowerShell Script. 

    Next hurtle, when the script is activated, it will then open a big, annoying window, and it will just sit there until the script finishes running. This can be a bit annoying and get in the way. The nice thing about shortcuts however, is that if you go Properties tab>Run dropdown menu (halfway down the window), which lets you run it minimized, maximized or windowed, you can select minimized and then it will not get in the way and be annoying. 



    Next Hurtle! Anytime you want to run a script to make a change in Device Manager, yo need admin privileges. But you cannot set the script to run PowerShell in administrator mode. However, you can for a shortcut! So, go Advanced button>Run as Administrator. Refer to the Image above for this as well!

    The only thing that I have to put up with is that every time I activate the script, it will ask me if I am sure I want to do this. But I don't want to rely on my touchscreen for this, I just feel like that could be a bad idea just to get this script working. However, I can toggle between yes and no with the arrow keys on the keyboard. So I am fine with that. 


This has been Truncat3d 00000000111100010100110______________end of line

Monday, March 25, 2024

2024-03-23 - File Server Samba (SMB) Login Script

 I was talking to my instructor, Doug,  about how I want to give access to my file server to various computers around my apartment so roommates can watch things downstairs, my mom can use it at her apartment, and so on. But people often accidentally delete things. I know I do this on occasion. I find every once in a while that files are missing and so either I deleted them or there is something happening in file transfers that I cannot nail down. So I would like a way to write protect and or remove write privileges except for when I decide and I can just make sure that nothing happens that I am not intending. 

    Doug talked about different user accounts, one for my mom and one for me so when we built my file server, I created two accounts, one for me with write privileges and one for her without. And if she wants a change, I can just do it for her since she doesn't know how to do it anyway. She can use the files but copy and paste are sorcery as far as she is concerned. Since I care about what happens to the contents I go through the trouble to put on there, I am fine with just being the one that takes care of all that myself. 

    I talked to Doug about other solutions too but Linux is different from how Windows works, and I don't even remember what those conversations were about except that I was surprised that Linux didn't do this or that thing that I am so used to doing on Windows, or at least knew Windows could do. No need to defend Linux, I am sure Linux has features that Windows does not, I am just totally unaware of what they are. 

    I suppose this is a good time to also mention that unlike Windows, Linux has no Recycle Bin. If you delete a file, there is only one protection to stop this action if you catch yourself in time. There is just a dialogue box asking if you are sure you want to delete the file. In Windows this used to be a thing but since Windows 10 I think, it has been optional and I always turn it off with the peace of mind that it is simply moved to the Recycle Bin and if I realize my mistake later, I can recover it. 

    But Linux has no such protection. There is just that dialogue box. I don't remember this conversation with Doug all that well either when he revealed this shocking news to me, but I asked him why every time I delete a file from Windows, even though I have that "Are you sure" dialogue box disabled, I need to sift through files and delete them quickly because I am sifting through thousands of files manually, so the dialogue box really slows me down and plus I am thinking like, what is going on, this option is turned off on my desktop? 

    Doug informed me that because of the way I was deleting the files, this was actually Linux doing this, and I don't remember what way that was, but this was the protection from Linux. And I was like yeah, but why aren't the files then also moving to my Recycle Bin? And he was like, because this is Linux. 

    And I was like, yeah, I know the file server is running Linux, thanks Doug, now back to why the pictures aren't moving to the Recycle Bin. 

    And he starts to subtly smile at this point every time while sort of jokingly being condescending while explaining again, that because this is Linux, there is no Recycle Bin. 

    Huh? This makes no sense! 

    He says sure it does, you're doing this through a method where Linux's safeguards take effect, and these files are located on Linux, so when you delete something, there will be just that dialogue box and once deleted, they will not be moved to the Recycle Bin. 

    Wait, what? Why not?

    Because this is Linux, and Linux does not have a Recycle Bin?

    What manner of barbarism is this? Linux has no Recycle Bin? Well, what happens if you accidentally delete a file?

    That is why there is the dialogue box. 

    That's it?! That is all the protection you get? You mean I was deleting files because I had a trigger finger and that is why when I went to my Windows Recycle bin, there was nothing there? 

    Yes. 

    Long face, jaw on the floor. Dude, seriously... ... ...

    Okay so I will just continue with the lesson for the Fundamentals students. He starts to turn and does something like explaining how the print command puts the code you just created onto the screen in a shell like this is some incredible magic trick. 

    Wait Doug...

    He ignored me. My mind was blown. To be honest, this conversation didn't actually completely go down this way, it was the beginning of class and people were still arriving. But this is the sort of thing that happens with some regularity. I let the newer students think I am stupid and then somehow they get this idea I actually know a lot. C'mon guys, I just unearthed a major discovery that apparently most of the planet already knows...Linux has no Recycle Bin!

    I am sure I inserted some sort of comment in there somewhere in my conversation with Doug saying, and this is the OS that you insisted we should use for my file server?!

    Yes, Windows Server would have costed a thousand dollars and Linux was free. 

    Yeah, anyway, so that conversation was like six months ago or something like that. But about a month ago, I told him yeah okay, lets create more users. I want a read only user so I can put that on the computer downstairs in my living room where my roommates can do whatever they want except delete files. Hey, wait, is there a way to limit what files they have access to? 

    This was another conversation that we had which ended in my being stunned because there's no way to just have one iteration of files in a place where access is limited. Either I need to just have those files by themselves separated from the others for just that user I guess, or something like that, or I need to have two iterations of the same files, which I don't really want to do. I wonder if I can do file shortcuts? Oh wait, no I think that is also something Doug might have said we cannot do. Because if I could create another directory so to speak, just another file tree right next to the file tree with the actual file and then made shortcuts of all those things in the second tree, then I could partition off those for that user and have read only access and all that crap, and also, not have to have multiple iterations or files in different places. 

    I have to ask Doug. He will probably tell me to just do research. Well, he might just answer in the interest of time. 

    Okay, so a month ago we had the idea that we could create multiple users that access all the same files but one would be read only and one would be normal access. And I told him, the only thing I don't like about this is that it would be tedious to log into one to use it, log out and then in again to another to change something, even one small thing, log out again, log back into the other just to use the file without the risk of accidentally deleting it and so on. You could see how this might get tedious at the speed of light. 

    Doug was like, well, there is a way to make that process simpler, it just involves a solution that you might not like, but knowing you, you may be fine with it. We could create a script that logs out of one and into the other, and another script that logs out of that one again and into the first one again. So one to go from 1 to 2, and then one to go from 2 back to 1. That way I get write protections but it's not tedious to the nth degree. The catch is that you have to insert the passwords into the scripts so that it works if you don't want to have to retype the password every few seconds. Done, lets do it Doug! I just have to make sure that no one ever finds these files. That's all! 

    We went through a few iterations of trying to get these scripts to work. We got them to a strange point where they seemed to work if we copied the scripts into the CLI directly, but if we ran the same exact commands as a script, they absolutely would not work. 

    We inserted a delay command for a few seconds in the beginning of the script because Doug thought that perhaps it needed time to log out of the server and wasn't getting enough of a buffer between that and logging into it with another user. 

    Then we tried pausing at the end of the script, and then also adding the exit command. Neither of us remembers why we tried these things. I personally recall that we tried like twenty different things, working on this after class had ended for like a half hour to forty five minuets because Doug just needed to know why this wasn't working and finally ran out of time to solve it. 

    We pasted it in several times and we can't remember what was going on here because it only worked when we pasted it in. It worked that way for both scripts but if you ran the scripts, neither of them worked. 

    Now a few weeks later, I had a scenario at home where I actually needed to use the scripts to log in and out of SAMBA and since pasting the scripts into the Shell worked fine but not running the script, I tried pasting. But now, pasting didn't work either. What is going on. I brought it back in to Doug to see if we could resolve the new added problem. This strikes me as strange because all of the sudden, the actual problem stopping the scripts from working revealed itself but not the reason pasting the script into the Shell was working before and not now. 

    So I grabbed Doug at the end of class to see if he could resolve this issue because I couldn't figure it out. I am not proficient at writing scripts in the first place, let alone writing any code. So this was completely beyond me why this wasn't working. And I was explaining to Doug that pasting was working before when we were trying to troubleshoot the two script files and then that stopped too when I got home so I opened both scripts to edit them in notepad and opened a Shell, whichever one I am not sure, CMD Admin, PowerShell (PS), no idea what I had opened each of these different times, but according to Doug this doesn't matter because "net use" is a CMD command, and will run in PS but because it is a CMD command and not a PS command, it's sort of like PS will use CMD to run the command. So it follows the CMD rules so-to-speak. 

    We pasted the two scripts into the Shell and all of the sudden, Doug realized something he didn't realize last time. The emoji that Jack in class told me like six or so months ago to include in the file path for my server, the skull and crossbones emoji, which was added initially as a joke, I was trying to be cool and said yeah sure lets keep it. And it has caused problems ever since because anytime I need to type it in I have to go online and fine the emoji and depending on what OS you're on, emojis display different, so my iPhone would display the same one a slightly different way that confused me and caused me to think it was the wrong emoji for a while six months ago when connecting my phone to the server, and then now, with the log-in and log-out scripts, turns out CMD does not recognize emoji characters because it runs using Ascii, while PowerShell runs on Unicode. 

    Just for a refresher or whatever, Ascii is an older standard and only has like 128 characters or something. But Unicode is newer, and there are many types too, and it has new characters added to it all the time. It has hundreds of thousands. 

    In talking about this, Zack and Doug started debating how many characters there were. I swear we're not geeks!

    The finalized versions of the two scripts are as follows, for the script to delete the READONLY log-in and log into the regular user with all privileges:


"net use /delete S:

net use S: "\\192.168.XXX.XXX\KeepOut" /USER:biff (password here)"


Then the script for logging out of the regular user with privileges and back into the READONLY user:


"@echo off

net use /delete S:

net use S: \\192.168.XXX.XXX\KeepOut /USER:readonly (password here)

exit"


    We had forgotten to delete the exit command at the end of the second script before I wrote this blog. Both scripts now run great! 

This has been Truncat3d 00000000111100010100110______________end of line

Friday, March 22, 2024

2024-03-22 - GPD Pocket 3 laptop touchpad typing issues

    I have had the GPD Pocket 3 laptop for a year. It's been a great laptop. Can fit in my pocket literally, but would cause my sweat pants to fall right down. There is one problem with it that I have been struggling with for this whole past year and finally, while in a phase where I am typing quite a bit lately, it has started to drive me nuts. Apparently this problem plagues all Pocket 3 users, I looked it up. 

    If you observe, the touchpad is above the keyboard and to the right. This seems like a great placement for such a small laptop designed to be able to be used with two hands, and it does work quite well that way. But if you type with it, you will quickly discover that every few minutes while typing, the cursor gets clicked somewhere else on your document and without you're noticing until it's too late, you have been typing everything in the wrong place and it's frustrating to find where you were, where it's typing now, and how far back to cut the text to reapply it where it was meant to be typed. And it always chops off a few of the first characters of text when this happens too, so you have to make sure to retype that word that you were typing when it happened. To me, this happens every five minutes. 



    It's always funny when you take on an assignment to get better at something like troubleshooting, to then need your instructors help because you're stumped, just to have him say, well...troubleshoot it! 

    I have searched this problem a number of times. I I didn't find the answer any of those times because the option they refer to isn't on my Windows 11 Home edition laptop. This option that is referred to by countless people online is firstly, to just press the function key with the button meant to turn the touchpad off, which the Pocket 3 doesn't have. And then they refer you to an option in Settings > Devices > Touchpad > and look for an option that says "Turn off touchpad when USB mouse is plugged in". Well, it ain't there! I have checked. About twenty times. I keep thinking I must have navigated to the wrong place or something, but there is no selection on my laptop for the touchpad. And the devices menu in Win11 isn't Devices anymore, it's Bluetooth and Devices. So this caused me to do a lot of extra searching just in case every time I looked. 

    Then I finally found an option online to disable the touchpad in Device management and a couple other places too, where access to managing devices is available. But I didn't see anything for a touchpad in Device Management. I looked at the drivers for a while and checked a video online of how someone else did it, and I finally thought okay, it has to be this HID-Compliant Mouse option under the mouse tree within Device Manager. 

    I thought, well, if I screw something up, I can always use my USB mouse to try and restore it, and the screen is a touch screen too, so I think I will be okay if I test this. So I right clicked and selected disable device. It disabled. The touchpad was no more. I was satisfied that the main problem is resolved but I would far prefer to keep it enabled and only disable it if I have a mouse plugged in. There will be times when I don't have a mouse. 

    I looked and looked and looked some more. I found instructions that troubleshooted the problem, said firstly to check to make sure the OS is updated, there may be something that would be fixed by an update. I didn't actually think this would solve it. 

    I am not exactly a huge advocate of updating fixing everything. People just always turn to that so you have to update to the latest thing regardless of what you want just so that can be eliminated even though I have seldom actually found that to be the solution. In fact, I don't think that has ever been the solution in y case. Yes yes yes, you need to do it for X, Y and Z reasons. Okay I covered myself, now you know the reasons why you should update whenever there's an update available. 

    seems the only reason everyone insists that you update is because it's the next thing on the list. And people are sooooo sure that will fix it. Just happened with Wells Fargo last week, had a problem with the app and they insisted updating my phone OS would solve it. I told them it would take a few days to make sure everything is backed up to my satisfaction, so the call ended and the next day the problem just went away. I never updated the OS. Seems to me each next update uses more battery life. I don't often find the updates are anything to write home about anyway. 

    Write home about...unless I'm in a serious relationship with the OS on my phone, I probably shouldn't be writing home about it at all. No wonder why people think I'm weird, they think I'm...yeah anyway. 

    I turned to Doug after looking through this for a while and he took one look at the menu with Bluetooth and Devices, then through the devices in the list and there was a section for the touch screen and a section for the mouse, and another for the keyboard but not one for the touchpad.  He immediately suspected no drivers were installed. We went to Device Manager and he was like yeah, HID-Compliant Mouse, it's not a mouse, it thinks it's a mouse. He then went looking for drivers and asked if I had installed any drivers from GPD. No. It never occurred to e to do such a thing. I've never bought a new laptop before, or a desktop built by a company. Every computer I have used was either twenty years old or I built it myself. Never went to Dell to install drivers for example. I sort of just thought that stuff just comes pre-installed on the device, you know, like bloatware. 

    Reminds me of the scene in Odd Couple, the 1968 movie, where people are coming for dinner and the meatloaf came out early so Oscar asks Felix if he can keep it warm by pouring gravy on it and Felix is like "Gravy? What gravy?" 
   "Don't you have any gravy?"
    "Where the hell am I gonna get gravy at eight o'clock?"
    "I dunno, I though it comes when you cook the meat."
    "Comes when you cook the meat. You don't know what you're talking about, Oscar. You just don't know, because you have to MAKE gravy, it doesn't just come when you cook the meat!" 

    Great movie. Anyway, we found a site for GPD Pocket 3 firmware and it led to a Google Drive with a bunch of zipped files, and Doug was like, man these guys are a small company. I think he asked if I trusted this and I was like, wait, is there any reason I shouldn't? 

    We downloaded them and I was able to unzip one of them and the other just kept erroring out. That was tge one for the touchpad, which was the one we really wanted. So, I am happy to say that this is now unresolved. Good luck everybody!

This has been Truncat3d 00000000111100010100110______________end of line

Tuesday, March 5, 2024

2023-11-02 - File Server / Pi Hole / Pi VPN All-In-One

  •  Showed my mom who I intend to share file server with this really cool thing that's replacing all of our free, low memory, only-3-device-per-account Dropbox accounts. I parked in her apartment's parking lot because her computer set up is messed up. I used my iPhone as a wireless hotspot, loaded up my laptop, turned on my VPN, accessed my file server, showed her her user folder and then showed her mine, I started playing a video off of it to show her how cool this was that I did not have this on my laptop but was grabbing it from home and playing it here in her parking lot. But it buffered. 
  • decided I wanted to start thinking about how to improve the bandwidth of my network set up through my VPN, which currently uses a Pi Zero Wireless without an ethernet adapter to get the most out of it. I have a USB 2.0 to ethernet adapter for my Pi Zero, but its not going to give me that much bandwidth over USB 2.0. I've never seen speeds above about 30 Mbps and Doug said basically half that for both the up and down speeds together at the same time and its roughly the 13 Mbps down that I was already getting. 
  • I thought about buying a Pi4 for an upgrade. Was going to install it on my old laptop which would surely be able to handle the load and although its an old ten plus year old laptop, it has 1Gbps ethernet. But I didn't want to lose my windows install because every once in a while it is useful to have a separate device other than my desktop or laptop. I thought about doing a VirtualBox with Linux installed with Pi Hole running on that and Doug recommended against it. Better to have it running directly on the metal than a number of layers away from it. And I think he might have said something on another topic about my server, and I had already found that basic Linux can run Pi Hole, it doesn't have to be Raspbian. It just has to be most versions of Linux. And then my eyes widened. Can my server do the pi hole and pi VPN? He said yes. So here we are. File server part two except its not file server its really just all in one now. 
  • I fugure I've done this already so this shouldn't be very hard. Turns out because Doug has been having me focus more on what the commands I type in Linux mean, rather than just looking them up because I have particular ideas about how I want my set up to work, so I should know what commands to use. So now that I am putting a more granular focus on each thing im doing, its like I have done this already but if you were working with me tonight on project day in class, you would probably ask, have you done this before? I would say yes and you would be like, then why don't you know what to do here, and there, and in this thing over here? And I would say, well because last time I just ran through it. I can do it but it would be like installing windows on a new machine and not changing your wallpaper, or setting times for virus protection to scan that bothers you the least like at night or something, and not setting power settings like when to sleep, hibernate, turen the screen off, so on, not setting screen savers, not installing the particular picture viewing, video or audio file playing or internet browsing applications you would prefer to install. So the route im taking this time guarantees i know how to get the particulars that I want without help this time. 
  • I actually started the process without talking to my instructor at all. I started with updating linux, then upgrading linux. Then I installed curl, which I do not remember doing last time at all. I would have eventually learned that most likely. I installed curl, then I used the pi hole curl command again, and I only stopped and restarted like eight times because I wanted to record every screen that asked me a question so I could know every detail this time. 
  • Then a classmate named Ronald was looking at class project tickets and saw mine that I had juts posted and was thinking about doing it. But then I told him hey yeah thats mine. So he joined me and I explained everything. He eventually had to go back to doing his own thing. 
  • When at the end of asking a bunch of questions, it gave me that password that you need to log into the Pi Hole web interface, which you must record if you want to access it at all and maintain it or anything, I recorded it and then Doug was like, oh yeah hey, lets change that password now. So we typed "Pi Hole -a -p". he recommended I just use the same password for the web server Pi Hole interface as last time so I just grabbed the same password for less confusion since after all, there is a lot of encryption before this password already, and I'm literally just replacing my Pi zero with this new configuration. 
  • I entered my servers IP address into my web browser and it gave me a placeholder page for my query.
  • Doug got passed this instantly however, by adding "/admin/" to the end of it. and we got the Pi Hole web interface page. 
  • i logged into the new Pi Hole web interface and added the blocklist project stuff to it, i changed the DNS server address in my router to my servers IP address. then i installed PiVPN.
  • I had lots of questions for Doug in this process because this part was sort of expedited for me last time. Just say yes and click default a lot, doug said. 
  • PiVPN is isntalled. All my devices are now using my Pi Hole as the DNS server. But I am not using the VPN I installed yet. 
  • I need to go pivpn -a to add devices and I need to reconfigure my router, not my roommates router, to point the port forward towards my server instead of my raspberry pi Zero. 
  • then I need to configure the two different kinds of vpn tunnels for different purposes (half tunnel and full tunnel)
  • So I've been needing to ask Doug about this for a while and even on multiple blod posts and finally we got to it now. So, here's the deal. When you use WireGuard, you can set what the sllowed IP addresses are. What this means is if you have it set to default which is just a bunch of 0's and colins and a couoke of slashes and another 0, this is CIDR notation, which is shorthand for sayong all IP addresses are allowed, because /0 means none of the bits in the IP address are locked down. If you have all allowed IP addresses like in the case of entering a /0, this means that everything, every single query from the device will be put through the VPN tunnel, which means you have a full tunnel. All of the data will go out from my devices to the internet through the VPN, to my server that's hosting the VPN, and say it's a google query, then it will then travel out of my server and network back to the internet ot do the actual query, the results will then be sent to my server, and then those results will be sent back through the VPN from my server to my devices that performed the query in the first place. So if you have a half tunnel, you will then specify the private network that your VPN server is on, so the whole range for that subnet that your server is on, and then the whole subnet range that the VPN will be using to route traffic over the virtual network it is creating for your remote devices. The VPN acts like another router in your network that then has all the remote devices connected to it. 


This has been Truncat3d 00000000111100010100110______________end of line

2026-05-10 - MWB constant reconnect fix and all other ultimate fixes until now for my whole home computer setup

     Now I was fixing a problem with a couple things that annoy me on my laptop. Every once in a while I manage to fix another little thing ...