Windows – Remotely Install App and Mask Password

email me

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
@echo off
Cls
Title Remote Installer 1.0
SetLocal EnableExtensions EnableDelayedExpansion
 
cd "%~dp0"
 
Set /p user=User: 
 
Set /P "=Password: " < Nul
Call :PW
 
set /p machine=Machine name: 
Echo.
 
copy /y D:\tools\go.cmd \\%machine%\c$\Windows\system32\go.cmd
copy /y D:\tools\setup.msi \\%machine%\c$\setup\setup.msi
psexec.exe \\%machine% -u %user% -p !Mask! -i go.cmd
 
Pause
exit /b 0
 
:PW
For /F skip^=1^ delims^=^ eol^= %%# in (
'"Echo(|Replace.exe "%~f0" . /U /W"') Do Set "Input=%%#"
For /F %%# In (
'"Prompt $H &For %%_ In (_) Do Rem"') Do Set "Back=%%#"
Set "Mask="
 
:_PW_KB
Set "Char=" & For /F skip^=1^ delims^=^ eol^= %%# in (
'Replace.exe "%~f0" . /U /W') Do Set "Char=%%#"
If !Char!==!Input! Echo(&Goto :Eof
If !Char!==!Back! (If Defined Mask (Set /P "=!Back! !Back!" <Nul
Set "Mask=!Mask:~0,-1!"
)
) Else (Set /P "=*" <Nul
If !Char!==! (Set "Mask=!Mask!^!"
) Else Set "Mask=!Mask!!Char!"
)
Goto :_PW_KB