How to mask input with VBScript? - vbscript

does anyone have an idea how to mask the InputBox in VBScript without using html (work security issues)? I'm using windows 10. Thank you very much, any help is greatly appreciated.

In VBScript you essentially have 2 options for masked input:
Using the console and a ScriptPW.Password object:
Set oInput = CreateObject("ScriptPW.Password")
WScript.StdOut.Write "Enter password: "
pw = oInput.GetPassword
Using a custom HTML dialog.
[Source]
Masking input in the builtin InputBox dialog is not possible.

ES_PASSWORD Displays an asterisk (*) for each character typed into the
edit control. This style is valid only for single-line edit controls.
Windows XP: If the edit control is from user32.dll, the default
password character is an asterisk. However, if the edit control is
from comctl32.dll version 6, the default character is a black circle.
To change the characters that is displayed, or set or clear this
style, use the EM_SETPASSWORDCHAR message.
So set the style for the contained edit box to password.
There is some C source code here
MSDN - How to Create a Single Line Edit Control
Run batch script as admin during Maven build (gives a good example of a wrapped VBScript that can be used for this purpose).

Related

I can't enter text via the command line, is it possible to do this?

When you try to automatically enter the desired content (and there will be a lot of such objects with text content and I would prefer to avoid entering all the necessary data manually), the input field moves from the console to the area highlighted with a red rectangle, which makes it impossible to automatically create signatures.
The question is, is it possible to make the input field of the desired content always remain on the command line?
enter image description here
I tried to find the question on the Internet by entering the corresponding queries in Russian, nothing gave results
I understand that by "automatically" you mean copying and pasting from some editor to the AutoCAD command prompt.
I will never work that way, you must use a programming language and I think the easiest thing is to use AutoLISP.
Try copying and pasting this:
(command "_mtext" "36,0" "42,0" "your text here" "")
and note the empty string at the end "" that finalises the MTEXT command.

How to set default unicode of notepad to UTF8?

Every time I'm saving a file that has some Unicode characters in
notepad, it prompts me that this file is going to be saved in ansi
format and you will losing some data and I should cancel saving
and choose UTF8 as unicode.
How can I set default encoding to UTF8 so it will not prompt me every time?
thanks in advance.
In windows 10, get to
Control Panel > Region > Tab Administrative
Hit button "Change system".
Then choose the language you use from the combobox labeled "Current system locale".
And check the checkbox labeled "Beta: Use Unicode UTF-8 for worldwide language s".
Hit the ok button.
Short answer - Notepad simply does not support what you are asking for. It will always default to ANSI, you have to tell it explicitly not to use ANSI. However, there are alternatives available, see Changing the default ANSI to UTF-8 in Notepad on SuperUser.

.Net standard Print Dialog versus Notepad's Print Dialog

In my C# WinForm application, I use a "PrintDialog" to open a standard Window where the user can "customize" his print request (select the printer, access the properties, select to print all pages or a range, ...)
But in that window, the user cannot enter a list of pages (separated by ,) that he want to print, just as we can do within notepad's Print Dialog.
Any idea how I can get a Print Dialog like the notepad's PrintDialog ?
[EDIT] As suggested by Brian, the solution is to set the property UseEXDialog to true on PrintDialog.
That was not obvious based on the documentation, but it does the trick !
Set PrintDialog.UseEXDialog to true.
http://msdn.microsoft.com/en-us/library/system.windows.forms.printdialog.useexdialog(v=vs.110).aspx
Based on the documentation, it seems that you should set the AllowSomePages property to true.
Gets or sets a value indicating whether the Pages option button is enabled.

Print File(NotePad) Without the name of the file appearing in the printing document

Dim ProcessProperties As New ProcessStartInfo()
ProcessProperties.FileName = "notepad.exe"
ProcessProperties.Arguments = "/p c:/doc.txt" 'command line arguments ''
''ProcessProperties.WindowStyle = ProcessWindowStyle.Maximized
Dim myProcess As Process = Process.Start(ProcessProperties)
when printing using the code above i have "doc.txt" printed. I don't want the file name to appear when printing is over
It is not possible to pass an argument through command line to notepad to hide the header, the only parameter accepted for the /P argument is the file name. (See link)
The only way to hide the header from printing is by opening notepad and going to File->Page Setup, and changing the header command. (See link)
If it is really needed to print using a process, you can try searching for third party editing tools which support printing arguments.
Another way is to implement functionality for printing the text file, see this Stackoverflow article (Link)
You will have to configure the header and footer options of Notepad in order to prevent or override the file name appearing on the print page. This can be done by simulating user input to bring up the Page Setup dialog and clear the header and footer.
There are a number of ways to send user input (mouse and/or keyboard). For starters you could look at these two:
Windows Input Simulator
Application and Global Mouse and Keyboard Hooks .Net Libary in C#

DOS batch file - Display popup message with two choices

Using a DOS batch file I'd like to display a popup window in XP and Windows 7 where I display a message and give the user the choice to press one of two buttons - one would stop the DOS batch file, while the other button would allow it to continue.
Any hint on what dos batch command/pgm I may use?
The following WSH/VBscript snippet prompts the user to click yes/no, after which you can base logic on the response:
'enter this text into ask.vbs
dim input
input = MsgBox ("Do you want to continue?", 4)
'wscript.echo input
If input = 7 Then
'answer was no
End If
If input = 6 Then
'answer was yes
End If
Then in your batch file, call wscript ask.vbs.
However, I recommend staying in pure console for this task if you can, as choice and set can handle this nicely as Anders suggests. pause works very well too, and that's usually what I use for a binary choice like yours because it's the simplest approach.
To display an actual window you would have to call something external, a .exe or a Windows Scripting Host script.
If you want to stay in pure batch, echo the choices and use SET /P to wait for input from the user. (To support DOS and Win9x you would have to use choice and not set on those systems)

Resources