How do I inflate a bicycle tire with a potato?
I see this all the time.
People have a problem and have already decided what technology they’re going to use to solve it, and then they hit a roadblock: The technology they picked is unsuited to the problem!
How do I put my laptop into standby mode from VBScript?
How do I change the user’s mouse acceleration from a batch file? I changed the registry values but it doesn’t take effect immediately.
The functionality you seek is implemented in native code via Win32.
At the end of the day, the solution involves calling
since those are the functions that actually do the work.
There’s no law that forbids writing programs in C or C++, particularly since that’s the target language for the native bits of Win32. Go ahead, write that program, and then call it from your batch file.
Now, it’s possible that you can get somebody else to play
middle-man for you.
For example, if you wanted to shut down the computer,
you can get the
shutdown.exe program to help out.
And if you had chosen wisely,
the technology you already decided upon may wrap the Win32
functionality inside a helper function or class,
or it may provide
a way of calling into native Win32 code. For example,
your Visual Basic program could just call
via a platform invoke:
<DllImport("kernel32.dll")> Public Shared Function SetSystemPowerState(_ fSuspend As Boolean, _ fForce As Boolean) As Boolean SetSystemPowerState(True, False)
(Note: I don’t speak Visual Basic, so I may have gotten the details wrong, but I hope you get the idea.)