Discussion:
CreateShortcut on cmd.exe - how to set fullscreen mode ? (not WindowStyle)
(too old to reply)
R.Wieser
2019-04-16 08:22:55 UTC
Permalink
Hello all,

I'm creating a shortcut to cmd.exe, and would like to have the "Command
Prompt Properties" -> "Options" -> "Full screen" (radio button) selected .
Is there any way I can do that with the CreateShortcut object ?

I've tried to google the solution, but for some reason "VBScript
CreateShortcut CMD.EXE fullscreen" (or variations on it) doesn't give any
related info back.

I (ofcourse) did find the "WindowStyle" property, but it gets overruled by
the above setting. :-|

The targetted OS is XP pro.

Remark: After starting the command-prompt I'm using the (DOS) MODE command
to make it truly fullscreen (and not some half-assed window).

Regards,
Rudy Wieser

P.s.
An(y )other method to script the the above setting is ofcourse welcome too.
:-)
Mayayana
2019-04-16 12:22:46 UTC
Permalink
"R.Wieser" <***@not.available> wrote
|
| I'm creating a shortcut to cmd.exe, and would like to have the "Command
| Prompt Properties" -> "Options" -> "Full screen" (radio button) selected .
| Is there any way I can do that with the CreateShortcut object ?
|

You can't set program options in a shortcut. WSH is giving you
the options that Windows has for IShellLink.

Interestingly, I set it up, from the Start Menu, to have a
small window, a white background, and brown text. (I figured
if I have to sometimes use command line I could at least have
it readable and not looking like a computer from a 1960 movie.)
The interesting part is that if I use that shortcut I get my
settings but if I double-click cmd.exe I don't. So I'd suggest
making the shortcut, making you adjustments when opened
from there, then using that shortcut. It seems to create
the shortcut differently, as though it were a DOS shortcut.
R.Wieser
2019-04-16 12:53:33 UTC
Permalink
Mayayana,
Post by Mayayana
You can't set program options in a shortcut.
That is what I found too, but hoped that I was wrong and just didn't have
all the info.
Post by Mayayana
The interesting part is that if I use that shortcut I get
my settings but if I double-click cmd.exe I don't.
Thats easy to explain: When the shortcut (with its extra options) is started
it (most likely) uses CreateProcess, supplying it with a STARTUPINFO record
with the preferences filled in (from those program-shortcut settings).
When you start cmd directly you get a STARTUPINFO record with the OS
defaults.
Post by Mayayana
So I'd suggest making the shortcut, making you adjustments
when opened from there,
:-) That last part is what I was trying to circumvent (I'm trying to create
a one-click default setup).
Post by Mayayana
It seems to create the shortcut differently, as though it were
a DOS shortcut.
It is. Most likely in response to the subsystem field in the executables PE
header.

Regards,
Rudy Wieser
Mayayana
2019-04-16 13:11:08 UTC
Permalink
"R.Wieser" <***@not.available> wrote

| > So I'd suggest making the shortcut, making you adjustments
| > when opened from there,
|
| :-) That last part is what I was trying to circumvent (I'm trying to
create
| a one-click default setup).
|

What I meant is that if you open from that shortcut,
then make adjustments, the shortcut itself will remember
them. It seems to be part of these DOS-esque shortcuts.

Likewise, if you right-click -> Properties you'll see all of
those options in the shortcut, which are not in a normal
shortcut. You can then choose your options from there.
In other words, cmd.exe has it's own special kind of shortcut.
R.Wieser
2019-04-16 15:43:10 UTC
Permalink
Mayayana,
Post by Mayayana
What I meant is that if you open from that shortcut,
then make adjustments, the shortcut itself will remember
them.
Yes, I know you ment that. The thing is that I'm trying to be extemely
lazy, and have the 'puter do it for me.
Post by Mayayana
Likewise, if you right-click -> Properties you'll see all of
those options in the shortcut, which are not in a normal
shortcut.
Remember that I, in my initial message, pointed out the exact setting I
wanted to apply ? :-)

Regards,
Rudy Wieser
JJ
2019-04-17 06:29:59 UTC
Permalink
Post by R.Wieser
Hello all,
I'm creating a shortcut to cmd.exe, and would like to have the "Command
Prompt Properties" -> "Options" -> "Full screen" (radio button) selected .
Is there any way I can do that with the CreateShortcut object ?
I've tried to google the solution, but for some reason "VBScript
CreateShortcut CMD.EXE fullscreen" (or variations on it) doesn't give any
related info back.
I (ofcourse) did find the "WindowStyle" property, but it gets overruled by
the above setting. :-|
The targetted OS is XP pro.
Remark: After starting the command-prompt I'm using the (DOS) MODE command
to make it truly fullscreen (and not some half-assed window).
Regards,
Rudy Wieser
P.s.
An(y )other method to script the the above setting is ofcourse welcome too.
:-)
Not programmatically possible using VBScript, because the API is a COM
interface IShellLinkDataList. It's not accessible from VBScript. You'll have
to use PowerShell to access it.
R.Wieser
2019-04-17 08:35:02 UTC
Permalink
JJ,
Post by JJ
Not programmatically possible using VBScript, because the API is
a COM interface IShellLinkDataList.
Odd. I can use CreateShortcut to create and alter it, but some of its
attributes remain inaccessible. Oh well.

I just did a google for "VBScript IShellLinkDataList". Don't you just hate
it when even the first page has results which do not even contain the words
you're looking for. I know I do. :-(
Post by JJ
It's not accessible from VBScript. You'll have to use PowerShell to
access it.
??? /what/ powershell ? This is Sparta^wXP ! :-)

Though while doing the above search I came across one which mentioned that
setting a "run as administrator" just needed the flipping of one bit in the
.lnk file, which made me realize I could most likely do the same.

Alas, although I think I found the byte it looks like that its not at a
fixed location (even copying the origional .lnk file to a new location and
changing the setting caused it to change its size), meaning that the file
needs to be parsed. Assuming I can access the file in a binary fashion
that is.

I'll probably take a look at it, just not now. :-)

Regards,
Rudy Wieser
JJ
2019-04-18 02:24:08 UTC
Permalink
Post by R.Wieser
I just did a google for "VBScript IShellLinkDataList". Don't you just hate
it when even the first page has results which do not even contain the words
you're looking for. I know I do. :-(
That would be Google. I'm sure of it. Only Google does that. Try using
verbatim search.
Post by R.Wieser
??? /what/ powershell ? This is Sparta^wXP ! :-)
For XP, PowerShell has to be downloaded separately. And only for the older
version. IIRC, newer versions of PowerShell won't run on XP.
Post by R.Wieser
Though while doing the above search I came across one which mentioned that
setting a "run as administrator" just needed the flipping of one bit in the
..lnk file, which made me realize I could most likely do the same.
Alas, although I think I found the byte it looks like that its not at a
fixed location (even copying the origional .lnk file to a new location and
changing the setting caused it to change its size), meaning that the file
needs to be parsed. Assuming I can access the file in a binary fashion
that is.
I'll probably take a look at it, just not now. :-)
Regards,
Rudy Wieser
You can do that too, but you'll have to at least parse the layout of the
shortcut file data structure, in order to get to the location of the extra
data part. You can use VBScript's ASCII mode (text) stream to do binary file
reading/editing.
R.Wieser
2019-04-18 06:56:30 UTC
Permalink
JJ,
Post by JJ
For XP, PowerShell has to be downloaded separately.
That would be a problem ....

You see, I'm still busy with putting a one-click basic configuration
together - to be used directly after XP has been installed from CD, meaning
with no extras available.

And I'm not even sure if I want to /install/ PowerShell for this one-off
action ...
Post by JJ
You can use VBScript's ASCII mode (text) stream to
do binary file reading/editing.
Are you sure ? Some time ago I tried to use the ReadAll method (trying to
read a double-byte character textfile so I could convert it into ASCII), and
got rather puzzeled by the returned contents. It turned out that although
the method returned a string the size of the file, it only filled it
partially (IIRC it stopped on encountering a certain character) which left
the remainder with whatever was in memory at that time (it didn't even zero
the buffer out!).

Regards,
Rudy Wieser
Mayayana
2019-04-18 12:35:46 UTC
Permalink
"R.Wieser" <***@not.available> wrote

| And I'm not even sure if I want to /install/ PowerShell for this one-off
| action ...
|

Microsoft have pushed it for years now. So far I have
yet to find something I need it for. You'd like it. It's all
command line applets, like DOS, meant to lure Linux
server managers to Windows. Though I think th fan base
is mostly IT people -- corporate admins who can pass
around specialized scripts.

| > You can use VBScript's ASCII mode (text) stream to
| > do binary file reading/editing.
|
| Are you sure ? Some time ago I tried to use the ReadAll method (trying
to
| read a double-byte character textfile so I could convert it into ASCII),
and
| got rather puzzeled by the returned contents. It turned out that
although
| the method returned a string the size of the file, it only filled it
| partially (IIRC it stopped on encountering a certain character) which left
| the remainder with whatever was in memory at that time (it didn't even
zero
| the buffer out!).
|
It stops at nulls. Here's the solution:

https://www.jsware.net/jsware/scrfiles.php5#bints

Things to know: ReadAll stops at the first null, assuming
it's an end-of-file marker. Textstream is intended to only
be used for text. The WSH planners assumed scripters
wouldn't need or know about binary. So the results are pre-
digested. An ANSI string is interpreted according to the
local codepage. (I dont' know why they call it ASCII. It's
ANSI.)

The class above provides workarounds. It will work on
any computer with a non-Asian codepage. (Japan, China
and Korea use a system that doesn't have a character-to-
byte correspondence.) The class can read unicode and leave
in the nulls, as asterisks, or not. It can also handle binary
data. For English, every second byte is a null and every first
byte is the ASCII character, up to 127, so in English the
unicode format is superfluous.

There's also the other option. Is it ADODB.Stream? I'm
not sure. I've rarely used it so I'm not really familiar with
the methods or the Windows version support.
Mayayana
2019-04-18 14:25:48 UTC
Permalink
One follow-up note on that last post:

If you don't need PowerShell it's just as well, for security's
sake. PS has become a favorite exploit.
R.Wieser
2019-04-18 16:50:00 UTC
Permalink
Mayayana,
Post by Mayayana
Microsoft have pushed it for years now.
Which is actually a signal for me to stay away from it. For some strange
reason (WGA, W10 pushing, forced telemetry, forced updates, etc) I do not
trust them too much anymore :-)
Post by Mayayana
It stops at nulls.
Yep, that was it. Funny though, as "read" doesn't have a problem with it.
But that was not even the biggest thing with it. What was was that it
returned /much/ more data than that it actually read /and/ that it didn't
even bother to zero-out the remainder (before, or afterwards). If it would
have been written by a student he would have flunked the assignment.
Yep. He also uses the "how big is the file ? Do a 'read' with that size"
instead (just took a quick peek).
Post by Mayayana
The WSH planners assumed scripters wouldn't need or
know about binary.
Most likely, yes. It seems to be aimed at text-based stuff only.

On the other hand, its makes it rather easy to pull another component into
the script, which than can do whatever you want. I think I've got a bit of
a love-hate relationship with it ...
Post by Mayayana
If you don't need PowerShell it's just as well, for security's
sake. PS has become a favorite exploit.
That might have lingered in the back of my mind too.

Regards,
Rudy Wieser
JJ
2019-04-19 05:32:06 UTC
Permalink
Post by R.Wieser
That would be a problem ....
You see, I'm still busy with putting a one-click basic configuration
together - to be used directly after XP has been installed from CD, meaning
with no extras available.
And I'm not even sure if I want to /install/ PowerShell for this one-off
action ...
I wouldn't use PowerShell either, unless it's absolutely needed. However in
this case, it's the only scripting application by Microsoft which can access
OLE/COM. If third party is fine, then there are AutoHotkey and AutoIt.
Post by R.Wieser
Are you sure ? Some time ago I tried to use the ReadAll method (trying to
read a double-byte character textfile so I could convert it into ASCII), and
got rather puzzeled by the returned contents. It turned out that although
the method returned a string the size of the file, it only filled it
partially (IIRC it stopped on encountering a certain character) which left
the remainder with whatever was in memory at that time (it didn't even zero
the buffer out!).
You'll have to use Read(), Skip(), or Write(), instead of XXXLine() and
XXXAll(). i.e. specify the exact number of bytes you want to
read/skip/write.
R.Wieser
2019-04-19 06:04:58 UTC
Permalink
JJ,
Post by JJ
If third party is fine, then there are AutoHotkey and AutoIt.
I did try AutoIt when the need to actually go thru configuration dialogs
arose (as changing the registry didn't work for QuickLaunch). Alas, when
I tried to click a ... treeview item (IIRC) I noticed it would try to click
the center of the item, even if that item would not be visible, and
sometimes not even within the confines of the dialog. In short: using a
blind click which could hit /anything/. :-(

That was whe I started trying to make my own "clicker" program (non-mouse.
Direct control manipulation) ... and discovered that that is not half as
easy as it looks. :-( :-)

So, currently I use that "clicker" program to activate classic mode and
enable QuickLaunch, and try to do the rest with registry changes (using
VBScript).

In other words, I'm my own "third party" now, with a program that doesn't
need to be installed. :-)
Post by JJ
You'll have to use Read(), Skip(), or Write(), instead of XXXLine()
and XXXAll(). i.e. specify the exact number of bytes you want to
read/skip/write.
Yup. And hope I will not run into another of those "we do not like binary
data" gotcha's ...

Regards,
Rudy Wieser

p.s.
Did you know that when you ask a dictionary object for the data of a
non-existing key it will add that key (without data) ? Funny when you see
such a dictionary grow when all you have been doing is querying it ...
JJ
2019-04-20 15:37:59 UTC
Permalink
Post by R.Wieser
p.s.
Did you know that when you ask a dictionary object for the data of a
non-existing key it will add that key (without data) ? Funny when you see
such a dictionary grow when all you have been doing is querying it ...
I rarely use dictionary, but it does work uncommonly. Even though MSDN
mentioned it clearly that it will create the key if it doesn't yet exist, it
will surely caught some experienced programmers by surprise.

I wonder if this behaviour is the same for VBA's built in dictionary object,
if such thing exist.
Mayayana
2019-04-20 16:22:10 UTC
Permalink
"JJ" <***@vfemail.net> wrote

| > Did you know that when you ask a dictionary object for the data of a
| > non-existing key it will add that key (without data) ? Funny when you
see
| > such a dictionary grow when all you have been doing is querying it ...
|
| I rarely use dictionary, but it does work uncommonly. Even though MSDN
| mentioned it clearly that it will create the key if it doesn't yet exist,
it
| will surely caught some experienced programmers by surprise.
|

I've never noticed that problem. Why would anyone check
the value of a key without knowing it exists? There is an
Exists method, but even that shouldn't normally be necessary.

| I wonder if this behaviour is the same for VBA's built in dictionary
object,
| if such thing exist.

The VB Dictionary is coming from scrrun.dll. I love Dictionaries.
The author of the O'Reilly VB book pointed out that they're much
faster than Collections, which I rarely use. But I stick to VBS for
Dictionary use because the scrrun dependency in VB can be a
problem and it's not designed for native code efficiency. Really,
saying that VB has FileSystemObject and Dictionary is just a
sleight of hand. VB doesn't have those. It's just able to use
scrrun and a lot of people decided to pretend VB and VBS are
the same thing.

When I want something similar in VB I write classes that store
arrays. But in VBS I find Dictionaries a great way to store loads
of complexly related data.
R.Wieser
2019-04-20 18:02:29 UTC
Permalink
Mayayana,
Why would anyone check the value of a key without
knowing it exists?
Because its a two-in-one step: if the result is not-empty I use it, if not I
know I need to do something in relation with the key, store the result and
use it. In short, a cache.

But thats something else thats rather odd: The dictionary doesn't throw an
error when the key doesn't exist. Instead it returns a null. I know that
it does away with having to use "exists" beforehand, but whats the logic in
that ?

In short, what where the people thinking when they purposely wrote the
method that way ?
There is an Exists method, but even that shouldn't normally
be necessary.
:-) How than do you know whats (already) in there ? Normally I do not
exactly know what the file contains my code is trawling thru, and certainly
will not gamble on those contents being perfect.
When I want something similar in VB I write classes that
store arrays.
Static arrays are very costly when you want to add a record. Mind you,
I've used VBScript on a 256 MByte (yes, Mega) Win98 machine. It payed off
to be a bit carefull with what you did memore wise.

Regards,
Rudy Wieser
JJ
2019-04-21 11:33:13 UTC
Permalink
Post by Mayayana
The VB Dictionary is coming from scrrun.dll.
That's the same as VBS, then. :(
R.Wieser
2019-04-20 17:34:19 UTC
Permalink
JJ,
Post by JJ
I rarely use dictionary, but it does work uncommonly.
I'll say! Querying something /never/ should have side effects like this.
I can't even think of a good reason to have it behave that way. And mind
you: the method has specifically written to do it that way (I partially
disassembled the dictionary object), its not some side effect of something
deep-down below.
Post by JJ
Even though MSDN mentioned it clearly that it will create
the key if it doesn't yet exist
I just checked and indeed saw it mentioned quite clearly. Can't remember if
I also did when I first found that quirk (on my W98se machine).
Post by JJ
it will surely caught some experienced programmers by surprise.
:-) It did. (not that I'm /that/ experienced mind you - just a long track
record)

And by the way: due to that "feature" the "exists" method is either a
mockery, or must be used every time you want to do a query - or suffer the
dictionary to grow.

Regards.
Rudy Wieser
JJ
2019-04-21 11:55:27 UTC
Permalink
Post by R.Wieser
:-) It did. (not that I'm /that/ experienced mind you - just a long track
record)
Well, I think any non-beginner programmers would know that a query is a
read-only operation. When the object doesn't exist, the operation shouldn't
write anything to the object being queried. I mean... what object? Right? It
just doesn't make sense.

The Dictionary object's description in MSDN states that "A Dictionary object
is the equivalent of a PERL associative array". So, anyone who's familiar
with PERL can confirm? i.e. Does querying a non existing associative array
element causes the element to be created? I do have PERL reserved in my
system, so I might test this myself. But I'm pretty positive that PERL
doesn't have such oddity.
R.Wieser
2019-04-21 13:13:32 UTC
Permalink
JJ,
Post by JJ
When the object doesn't exist, the operation shouldn't
write anything to the object being queried.
I take it you mean the 'key' there ? In that case, agreed.

Heck, VBScript doesn't even want to know a 'by reference' passing of
(numeric and simple string) arguments (a good indication of the "no side
effects allowed" doctrine).
Post by JJ
It just doesn't make sense.
Indeed.

Although I could imagine a specific goal with what it currently does (being
able to check which queries it received) it 1) does not belong in the object
itself 2) is easy enough to create with the rest of the language(s).

Regards,
Rudy Wieser

Loading...