Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reboot Your Computer
#5
On Windows, I feel like you would just go to Task Scheduler and set up a reboot task there. I think something similar exists in Linux, too. "SYSTEM" might also be better than "END" for this, so your program will exit at the end rather than waiting for a keypress. Since this is running console commands, would make sense to make the program "$CONSOLE:ONLY" so it doesn't take up more space and runs faster. Also, "COMMAND$(n)" exists for parsing the command line without needing to use another declaration of the Win32 API. If you want to stay using GetCommandLineA, you don't need to use a 1,000-character string to store the result. You can do a declare library block for strlen and call it on GetCommandLineA and store the result in a LONG variable.
Then you could set your "ms" string variable to the size by using "SPACE$(n)". You would then use the sub version of "_MemGet". This allows you to use a variable length string with _Mem.

Here is a working test of what I proposed:

Code: (Select All)
Declare Library
    Function strlen& (ByVal str As _Offset)
    Function GetCommandLineA%& ()
End Declare

Dim As _MEM m
Dim As _Offset a
Dim As String ms
Dim As Long cmdLen: cmdLen = strlen(GetCommandLineA) 'using "test -r -b" as my command line switches for the test in the below screenshot

ms = Space$(cmdLen)
a = GetCommandLineA
m = _Mem(a, cmdLen)
_MemGet m, m.OFFSET, ms
_MemFree m

Print ms
   
The noticing will continue
Reply


Messages In This Thread
Reboot Your Computer - by eoredson - 10-04-2025, 04:31 AM
RE: Reboot Your Computer - by SierraKen - 10-04-2025, 10:25 PM
RE: Reboot Your Computer - by eoredson - 10-05-2025, 10:23 PM
RE: Reboot Your Computer - by SierraKen - 10-08-2025, 02:37 PM
RE: Reboot Your Computer - by SpriggsySpriggs - 10-08-2025, 03:07 PM
RE: Reboot Your Computer - by eoredson - 10-09-2025, 02:08 AM
RE: Reboot Your Computer - by SpriggsySpriggs - 10-09-2025, 11:38 AM
RE: Reboot Your Computer - by eoredson - 10-09-2025, 09:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trust The Computer James D Jarvis 0 516 11-16-2023, 01:19 PM
Last Post: James D Jarvis
  Is your computer watching you? James D Jarvis 7 1,553 09-06-2022, 03:41 PM
Last Post: JRace

Forum Jump:


Users browsing this thread: 1 Guest(s)