I am struggling with how to make the Energy-Reporter program save dates and rename the files. I am new to Batch programing. I started to learn this language when my OEMCreate DELL Latitude E5500 battery died after about a year. I am attempting to make a program that allows me to monitor and save battery statistic reports to my computer. I am hoping to add the ability to graph battery degradation over time. I attached the current code below. I need to figure out how to make a CMD based File manager.
#echo OFF
TITLE Energy-Reporter
set CUR_YYYY=%date:~10,4%
set CUR_MM=%date:~4,2%
set CUR_DD=%date:~7,2%
set CUR_HH=%time:~0,2%
if %CUR_HH% lss 10 (
set CUR_HH=0%time:~1,1%
set CUR_AP="AM"
)
if %CUR_HH% GEQ 12 (
set CUR_HH=CUR_HH-12
set CUR_AP="PM"
)
set CUR_NN=%time:~3,2%
set CUR_SS=%time:~6,2%
set CUR_MS=%time:~9,2%
set SUBFILENAME="%CUR_MM%-%CUR_DD%-%CUR_YYYY%_At_%CUR_HH%-%CUR_NN%-%CUR_SS% %CUR_AP%"
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params= %*
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
IF EXIST "C:\Program Files\Energy-Report\." (
ECHO DIRECTIORY FOUND
) else (
ECHO CREATING "C:\Program Files\Energy-Report\"
mkdir "C:\Program Files\Energy-Report\"
)
COLOR F4
:USER_SELECTER
CLS
ECHO ===============================================================
ECHO Battery logger
ECHO ===============================================================
ECHO Select an option:
Choice /C codq /N /M "[C]reate power log | [O]pen report | [D]elete log | [Q]uit"
If ErrorLevel 4 GoTo :EOF
If ErrorLevel 3 GoTo DELETE_LOG
If ErrorLevel 2 GoTo SAVED_LOGS
If ErrorLevel 1 GOTO REPORT_DATA
PAUSE
GOTO USER_SELECTER
:REPORT_DATA
cd "C:\Program Files\Energy-Report\"
powercfg -energy
REN "Energy-Report.html" "energy-report_%SUBFILENAME%.html"
PAUSE
GOTO USER_SELECTER
:SAVED_LOGS
cd "C:\Program Files\Energy-Report\"
DIR
PAUSE
GOTO USER_SELECTER
:DELETE_LOG
SET /P Entry_name=log to be erased
DELETE "C:\%Program Files%\Energy-Report\%Entry_name%"
PAUSE
GOTO USER_SELECTER
I have uploaded all of the previous versions of the code to my website for those who are interested in the code development.
If I do not get a chance to update the stack overflow version, The latest version is available by running the code snippet.
<embed style="width:100%;height:100%;"src="https://theelectronichandbook.tech/code/downloads/battery-logger-for-windows/latestcode.php?FRAME=iframe"></embed>
Related
I am using this app called Defender Control. It works with command line switches "DefenderControl.exe /D" to disable Windows Defender and "DefenderControl.exe /E" to enable Windows Defender. I tried creating and modifying other toggle scripts but I cannot make one work. I have very little knowledge on scripting. I plan to add it to the right-click context menu to quickly disable Windows Defender without having to launch the app then disable it. Thanks in advance.
DefenderControl.exe /D
DefenderControl.exe /E
This writes the status to an alternate data stream (technically it's a file, but bound to the batch file), so the status survives reboots:
#echo off
REM get current status:
<"%~f0:status" set /p status=
echo Currently: %status%
if "%status%"=="D" (
defendercontrol.exe /E
echo E>"%~f0:status"
) else (
defendercontrol.exe /D
echo D>"%~f0:status"
)
For the very first run, the status is empty and handled the same, as it were E (goes to the else branch)
The solution for making the script work from the context menu was to elevate it.
#echo off
CLS
ECHO.
:init
setlocal DisableDelayedExpansion
set "batchPath=%~0"
for %%k in (%0) do set batchName=%%~nk
set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
setlocal EnableDelayedExpansion
:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
ECHO.
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
ECHO args = "ELEV " >> "%vbsGetPrivileges%"
ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
ECHO args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
ECHO Next >> "%vbsGetPrivileges%"
ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %*
exit /B
:gotPrivileges
setlocal & pushd .
cd /d %~dp0
if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1)
REM get current status:
<"%userprofile%\defendercontrol.status" set /p status=
echo Currently: %status%
if "%status%"=="D" (
defendercontrol.exe /E
echo E>"%userprofile%\defendercontrol.status"
) else (
defendercontrol.exe /D
echo D>"%userprofile%\defendercontrol.status"
)
If you are asking why am I using Batch and not PS or something else, this is the way it was made, and I cannot change it. Please just any help for batches.
Long story short, I have a batch program that runs for our company. It will be used by the Hardware department for post configuration on all computers going out to the users.
I have completed the entire portion, but ran into one issue. I have a section dedicated to checking whether a program exists based on the uninstall section of the registry. Normally, most programs, keep the GUID the same throughout. Apparently Screen Connect decides to change their GUID, as I found on 6 different computers, a different GUID in the uninstall.
I know how to regquery to search within a key for a value, I.E.
Using this example as AnyConnect uses a text key rather than a GUID {XXX}
:reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Cisco AnyConnect Secure Mobility Client
cls
if %ERRORLEVEL% EQU 0 SET AnyConnect=Yes
if %ERRORLEVEL% EQU 1 SET AnyConnect=No
But, I was wondering if there is a way to check for values within keys within a key.
I.E. ....CurrentVersion\Uninstall\{GUID} "Value"
ALMOST AS SOMETHING LIKE:
for /f "tokens=4" %%a in ('reg query "HKEY_LOCAL_MACHINE.......\Uninstall\" /V ******* ^|findstr /ri "ScreenConnect"') do set /a ID=%%a + 0
Or whatever it is, as I do not know which switches to use.
The issue here is it would search Uninstall, which has no values, as it is a parent folder for the GUIDs.
Since I do not know what the GUID is going to be, is there a way for me to search all of the keys under \Uninstall and the values of them in one reg Query command?
If that makes sense.
Let me know if you have any questions.
beta Redacted code.
This is somewhat old, so there are a few errors, but you will get the general idea.
#echo OFF
:check_Permissions
cls
echo Administrative permissions required.
net session >nul 2>&1
if %errorLevel% == 0 (
echo Success: Administrative permissions confirmed. && goto MoveForward
) else (
echo Failure: Please re-run as an Administrator.
pause
exit
)
goto :check_Permissions
pause
:MoveForward
cls
echo Admininstrative Privs Confirmed
pause
cls
echo ---------------------------------------------------------------
echo Current Info
echo ---------------------------------------------------------------
echo.
systeminfo | findstr /B /C:"Domain"
echo User Name: %username%
echo.
echo.
for /f "tokens=9 delims==" %%I in ('WHOAMI /FQDN') do set "Domain=%%I"
set "Line1=Current Domain: %Domain%"
echo.
if "%Domain%"=="XXXXXXXX" goto Name
if NOT "%Domain%"=="XXXXXXXX" echo.
echo Unable to Resolve FQDN. You May need to connect to the domain.
echo.
echo ******************Please see Below*********************
echo.
echo If the top shows you are connected to the domain and the username is XXXX
echo You are all set. The FQDN will NOT show up until logged in as a Domain User.
echo.
echo.
echo.
echo.
pause
echo.
echo Remember, if XXXX and Domain were correct, Please Enter N
echo.
:choice
set /P c=Do you want to open the Name/Domain Dialog Box[Y/N]?
if /I "%c%" EQU "Y" goto :AddDomain
if /I "%c%" EQU "N" goto :Name
:addDomain
Start /wait C:\Windows\System32\SystemPropertiesComputerName.exe
pause
goto Name
REM PE Tools Split PE Explorer and PE Resource Tuner into 2 separate Programs FYI
exit
:ChangeHostname
:: Defunct
REM Legacy, Now Running Powershell see C:\XXXXXXXXXX\Config_Bat\Domain_Add.ps1
:: SET /P PCNAME=Please enter your name:
:: REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v ComputerName /t REG_SZ /d %PCNAME% /f
pause
:ChangeXXXXPassword
cls
echo Command sent to change XXX Password to XXXX
net user XXX XXXXXXX
echo.
pause
goto :MainMenu
:Name
cls
REM WMIC
for /f "tokens=2 delims==" %%I in ('wmic computersystem get model /format:list') do set "SYSMODEL=%%I"
set "Line1= System Model: %SYSMODEL%"
echo %Line1%
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS=32BIT || set OS=64BIT
if %OS%==32BIT echo This is a 32bit operating system
if %OS%==64BIT echo This is a 64bit operating system
echo.
for /f "skip=1 delims=" %%A in (
'wmic bios get smbiosbiosversion'
) do for /f "delims=" %%B in ("%%A") do set "BIOSVer=%%A"
echo Bios Version: %BIOSVer%
for /f "skip=1 delims=" %%A in (
'wmic computersystem get name'
) do for /f "delims=" %%B in ("%%A") do set "compName=%%A"
echo Hostname: %compname%
echo.
echo Current User: %USERNAME%
echo.
echo If FQDN does NOT appear, please check up top for Domain to verify XXXXXXX
echo Fully Qualified Name
whoami /FQDN
echo.
pause
goto :MainMenu
:: Checking if the batch is running with Admin Privs
goto check_Permissions
:MainMenu
Title HWD Depot Thingy
set "Window[1]=Set XXXXPassword"
set "Window[2]=Check MSI Availability"
set "Window[3]=Install Software"
set "Window[4]=Individual Install"
set "Window[5]=Post Config Check"
set "Window[6]=Open XXXXXXXX Folder"
set "Window[7]=Stop and Disable Windows Update Service"
set "Window[8]=Uninstall DDD * Will check for Acrobat XI *"
set "Window[9]=Exit"
set "Message="
cls
echo.%Message%
echo.
echo Current User: %USERNAME%
for /f "skip=1 delims=" %%A in (
'wmic computersystem get name'
) do for /f "delims=" %%B in ("%%A") do set "compName=%%A"
echo Hostname %compname%
echo.
echo.
echo ******Option 1 and 2 Require Batch to be run as an Administrator******
echo.
echo ---Main Menu---
echo.
set "x=0"
:MenuLoop
set /a "X+=1"
if defined Window[%x%] (
call echo %x%. %%Window[%x%]%%
goto MenuLoop
)
echo.
:Prompt
Set "Input="
set /p "Input=HWD Select Which Shell Window: "
:: Validate Input
if not defined Input goto Prompt
set "Input=%Input:"=%"
set "Input=%Input:^=%"
set "Input=%Input:<=%"
set "Input=%Input:>=%"
set "Input=%Input:&=%"
set "Input=%Input:|=%"
set "Input=%Input:(=%"
set "Input=%Input:)=%"
:: No Equals
set "Input=%Input:^==%"
call :Validate %Input%
:: Process
call :Process %Input%
goto End
:Validate
set "Next=%2"
if not defined Window[%1] (
set "Message=Invalid Input: %1"
goto :MainMenu
)
if defined Next shift & goto Validate
goto :eof
:Process
set "Next=%2"
call set "Window=%%Window[%1]%%"
:: Run
if "%Window%" EQU "Set XXXXXX" goto XXXXXXXX
if "%Window%" EQU "Check MSI Availability" goto CheckMSI
if "%Window%" EQU "Install Software" goto Install
if "%Window%" EQU "Individual Install" goto IndividualInstall
if "%Window%" EQU "Post Config Check" goto PCC
if "%Window%" EQU "Open XXXXXXXX Folder" goto IST
if "%Window%" EQU "Stop and Disable Windows Update Service" goto StopWinUpdt
if "%Window%" EQU "Uninstall DDD * Will check for Acrobat XI *" goto :UninstallDDD
if "%Window%" EQU "Exit" goto :eof
:: Dumbass
:: if "%Window%" EQU "All Apps" ( )
:: Need to make this not an option
:: Prevent Double Jeopardy
set "Window[%1]="
if defined Next shift & goto Process
goto :eof
:CheckMSI
cls
if exist "C:\XXXXXXXXXX\SC_ClientSetup_v63134466374.msi" echo SC MSI Exists
if NOT exist "C:\XXXXXXXXXX\SC_ClientSetup_v63134466374.msi" echo SC MSI NULL
if exist "C:\XXXXXXXXXX\ampagent-7.1.62-x86_help.XXXXXXXX.com.msi" echo KACE MSI Exists
if NOT exist "C:\XXXXXXXXXX\ampagent-7.1.62-x86_help.XXXXXXXX.com.msi" echo KACE MSI NULL
if exist "C:\XXXXXXXXXX\anyconnect-win-4.4.03034-core-vpn-webdeploy-k9.exe" echo AnyConnect MSI Exists
if NOT exist "C:\XXXXXXXXXX\anyconnect-win-4.4.03034-core-vpn-webdeploy-k9.exe" echo AnyConnect MSI NULL
if exist "C:\XXXXXXXXXX\McAfee Installers\Agent_EPO2.exe" echo McAfee Agent Exe Exists
if NOT exist "C:\XXXXXXXXXX\McAfee Installers\Agent_EPO2.exe" echo McAfee Agent Exe NULL
if exist "C:\XXXXXXXXXX\McAfee Installers\2 Endpoint_Security_10_5_1\setupEP.exe" echo McAfee EPO Exe Exists
if NOT exist "C:\XXXXXXXXXX\McAfee Installers\2 Endpoint_Security_10_5_1\setupEP.exe" echo McAfee EPO Exe NULL
if exist "C:\XXXXXXXXXX\McAfee Installers\3 Adaptive_Threat_Protection_10_5_1\setupATP.exe" echo McAfee ATP Exe Exists
if NOT exist "C:\XXXXXXXXXX\McAfee Installers\3 Adaptive_Threat_Protection_10_5_1\setupATP.exe" echo McAfee ATP Exe NULL
if exist "C:\XXXXXXXXXX\McAfee Installers\4 DXL_Client_3_1_595\dxlsetup.exe" echo McAfee DXL Exe Exists
if NOT exist "C:\XXXXXXXXXX\McAfee Installers\4 DXL_Client_3_1_595\dxlsetup.exe" echo McAfee DXL Exe NULL
pause
goto :MainMenu
:StopWinUpdt
cls
echo Processing Windows Update Stop and Disable
net stop wuauserv
echo Processing Disable Command
sc config wuauserv start= disabled
echo Windows Update "Wuauserv" has been Disabled
pause
goto MainMenu
:Install
REM Query Screen Connect Exist
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{E8ABFA22-897F-4FCB-902A-4DCD400B53DC}
REM Error level 0 means installed
REM Error Level 1 Means Not Installed
if %ERRORLEVEL% EQU 0 SET SC=Yes
if %ERRORLEVEL% EQU 1 SET SC=No
REM Query KACE Exist
reg query HKLM\Software\WOW6432Node\Dell\KACE
cls
REM Error level 0 means installed
REM Error Level 1 Means Not Installed
if %ERRORLEVEL% EQU 0 SET KACE=Yes
if %ERRORLEVEL% EQU 1 SET KACE=No
REM Query Any Connect
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Cisco AnyConnect Secure Mobility Client
cls
if %ERRORLEVEL% EQU 0 SET AnyConnect=Yes
if %ERRORLEVEL% EQU 1 SET AnyConnect=No
Rem Query McAfee Agent
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{80684F9A-6B01-4F3F-A8C7-C4B7BDF072F1}
cls
if %ERRORLEVEL% EQU 0 SET MAgent=Yes
if %ERRORLEVEL% EQU 1 SET MAgent=No
Rem Query McAfee Endpoint
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{4F574B83-3AE0-419F-8A3B-985C389334B4}
cls
if %ERRORLEVEL% EQU 0 SET Endpoint=Yes
if %ERRORLEVEL% EQU 1 SET Endpoint=No
Rem Query McAfee Adaptive Thread Protection
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{80B1F696-3C8F-4BBC-BD07-86CF0E37FDD2}
cls
if %ERRORLEVEL% EQU 0 SET McAfeeAdaptiveThreatProtection=Yes
if %ERRORLEVEL% EQU 1 SET McAfeeAdaptiveThreatProtection=No
Rem Query McAfee Data Exchange Layer
reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{8f28453c-bec7-4d47-8152-3b8b40238dec}
cls
if %ERRORLEVEL% EQU 0 SET McAfeeDataExchangeLayer=Yes
if %ERRORLEVEL% EQU 1 SET McAfeeDataExchangeLayer=No
REM Query Standard X
reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{AC76BA86-1033-F400-BA7E-000000000005}
cls
if %ERRORLEVEL% EQU 0 SET StandardX=Yes
if %ERRORLEVEL% EQU 1 SET StandardX=No
REM Query Standard XI
reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{AC76BA86-1033-FFFF-7760-000000000006}
cls
if %ERRORLEVEL% EQU 0 SET StandardXI=Yes
if %ERRORLEVEL% EQU 1 SET StandardXI=No
REM We have to Grab the Dword, which is in Hex, and Convert it to Decimal, and store it as a Var
for /f "tokens=4" %%a in ('reg query "HKEY_CURRENT_USER\SOFTWARE\FS StreetSmart\Field Sales Professional" /V "salesperson ID" ^|findstr
/ri "Salesperson ID"') do set /a ID=%%a + 0
REM Output all Results
:ProgramsListed
cls
echo.
echo Program list
echo.
echo SC Installed: %SC%
echo Kace Installed: %Kace%
echo AnyConnect Installed: %AnyConnect%
echo McAfee Agent Installed: %MAgent%
echo Endpoint Installed: %Endpoint%
echo McAfeeAdaptiveThreatProtect: %McAfeeAdaptiveThreatProtection%
echo McAfee Data Exchange Layer: %McAfeeDataExchangeLayer%
echo Adobe Standard X Installed: %StandardX%
echo Adobe Standard XI Installed: %StandardXI%
echo.
echo.
echo User: %USERNAME%
echo XXX Sales Person ID: %ID%
echo.
echo.
echo.
:Installchoice
set /P c=Do you want to add to Install Non-installed Software[Y/N]?
if /I "%c%" EQU "Y" goto :InstallSoft
if /I "%c%" EQU "N" goto :MainMenu
goto :ProgramsListed
:InstallSoft
REM Query Screen Connect
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{E8ABFA22-897F-4FCB-902A-4DCD400B53DC}
cls
if %ERRORLEVEL% EQU 0 Set SC=Yes
if %ERRORLEVEL% EQU 1 Set SC=No
REM Query KACE Exist
reg query HKLM\Software\WOW6432Node\Dell\KACE
cls
REM Error level 0 means installed
REM Error Level 1 Means Not Installed
if %ERRORLEVEL% EQU 0 SET KACE=Yes
if %ERRORLEVEL% EQU 1 SET KACE=No
REM Query Any Connect
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Cisco AnyConnect Secure Mobility Client
cls
if %ERRORLEVEL% EQU 0 SET AnyConnect=Yes
if %ERRORLEVEL% EQU 1 SET AnyConnect=No
Rem Query McAfee Agent
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{80684F9A-6B01-4F3F-A8C7-C4B7BDF072F1}
cls
if %ERRORLEVEL% EQU 0 SET MAgent=Yes
if %ERRORLEVEL% EQU 1 SET MAgent=No
Rem Query McAfee Endpoint
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{4F574B83-3AE0-419F-8A3B-985C389334B4}
cls
if %ERRORLEVEL% EQU 0 SET Endpoint=Yes
if %ERRORLEVEL% EQU 1 SET Endpoint=No
Rem Query McAfee Adaptive Thread Protection
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{80B1F696-3C8F-4BBC-BD07-86CF0E37FDD2}
cls
if %ERRORLEVEL% EQU 0 SET McAfeeAdaptiveThreatProtection=Yes
if %ERRORLEVEL% EQU 1 SET McAfeeAdaptiveThreatProtection=No
Rem Query McAfee Data Exchange Layer
reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{8f28453c-bec7-4d47-8152-3b8b40238dec}
cls
if %ERRORLEVEL% EQU 0 SET McAfeeDataExchangeLayer=Yes
if %ERRORLEVEL% EQU 1 SET McAfeeDataExchangeLayer=No
REM Query Standard X
reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{AC76BA86-1033-F400-BA7E-000000000005}
cls
if %ERRORLEVEL% EQU 0 SET StandardX=Yes
if %ERRORLEVEL% EQU 1 SET StandardX=No
REM Query Standard XI
reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{AC76BA86-1033-FFFF-7760-000000000006}
cls
if %ERRORLEVEL% EQU 0 SET StandardXI=Yes
if %ERRORLEVEL% EQU 1 SET StandardXI=No
if /I "%SC%" EQU "No" goto :InstallSC
if /I "%SC%" EQU "Yes" echo Screen Connect Already Installed
if /I "%Kace%" EQU "No" goto :InstallKace
if /I "%Kace%" EQU "Yes" echo Kace Already Installed
if /I "%AnyConnect%" EQU "No" goto :InstallAnyC
if /I "%AnyConnect%" EQU "YES" echo AnyConnect Already Installed
if /I "%MAgent%" EQU "Yes" echo McAfee Agent Already Installed
if /I "%MAgent%" EQU "No" goto :InstallMAgnt
if /I "%Endpoint%" EQU "Yes" echo Endpoint Already Installed
if /I "%Endpoint%" EQU "No" goto :InstallEPO
if /I "%McAfeeAdaptiveThreatProtection%" EQU "Yes" echo McAfee Adaptive Threat Protection Already Installed
if /I "%McAfeeAdaptiveThreatProtection%" EQU "No" goto :InstallATP
if /I "%McAfeeDataExchangeLayer%" EQU "Yes" echo McAfee Exchange Data Layer Installed
if /I "%McAfeeDataExchangeLayer%" EQU "No" goto :InstallDXL
pause
goto :MainMenu
Pause
Call "C:\XXXXXXXXXX\McAfee Installers\4 DXL_Client_3_1_595\dxlsetup.exe"
pause
:EndInstall
Goto :InstallSoft
goto :eof
:IndividualInstall
Title HWD Depot Thingy
:MainMenuIndiv
set "Window[1]=SC"
set "Window[2]=Kace"
set "Window[3]=Cisco AnyConnect"
set "Window[4]=McAfee Agent"
set "Window[5]=McAfee EPO"
set "Window[6]=McAfee ATP"
set "Window[7]=McAfee DXL"
set "Window[8]=Adobe Standard * PLEASE DO MANUALLY *"
set "Window[9]=Exit"
set "Message="
cls
echo.%Message%
echo.
echo Current User: %USERNAME%
for /f "skip=1 delims=" %%A in (
'wmic computersystem get name'
) do for /f "delims=" %%B in ("%%A") do set "compName=%%A"
echo Hostname %compname%
echo.
echo.
echo.
echo ---Main Menu---
echo.
set "x=0"
:MenuLoopA
set /a "X+=1"
if defined Window[%x%] (
call echo %x%. %%Window[%x%]%%
goto MenuLoopA
)
echo.
:PromptA
Set "Input="
set /p "Input=HWD Select Which Shell Window: "
:: Validate Input
if not defined Input goto Prompt
set "Input=%Input:"=%"
set "Input=%Input:^=%"
set "Input=%Input:<=%"
set "Input=%Input:>=%"
set "Input=%Input:&=%"
set "Input=%Input:|=%"
set "Input=%Input:(=%"
set "Input=%Input:)=%"
:: No Equals
set "Input=%Input:^==%"
call :ValidateA %Input%
:: Process
call :ProcessA %Input%
goto End
:ValidateA
set "Next=%2"
if not defined Window[%1] (
set "Message=Invalid Input: %1"
goto :MainMenuIndiv
)
if defined Next shift & goto ValidateA
goto :eof
:ProcessA
set "Next=%2"
call set "Window=%%Window[%1]%%"
:: Run
if "%Window%" EQU "SC" goto InstallSCb
if "%Window%" EQU "Kace" goto InstallKACEb
if "%Window%" EQU "Cisco AnyConnect" goto InstallAnyCb
if "%Window%" EQU "McAfee Agent" goto InstallMAgntb
if "%Window%" EQU "McAfee EPO" goto InstallEPOb
if "%Window%" EQU "McAfee ATP" goto InstallATPb
if "%Window%" EQU "McAfee DXL" goto InstallDXLb
if "%Window%" EQU "Adobe Standard * PLEASE DO MANUALLY *" goto :IndividualInstall
if "%Window%" EQU "Exit" goto :MainMenu
:InstallSCb
Start /WAIT C:\XXXXXXXXXX\SC_ClientSetup_v63134466374.msi
set /P c=Do you want to Install Screen Connect[Y/N]?
if /I "%c%" EQU "Y" echo Screen Connect Installing
if /I "%c%" EQU "N" goto :InstallKACE
:InstallKACEb
Start /WAIT C:\XXXXXXXXXX\ampagent-7.1.62-x86_help.asmXXXX.com.msi
echo KACE Installing
goto :IndividualInstall
pause
:InstallAnyCb
echo Any Connect Installing
start /WAIT C:\XXXXXXXXXX\anyconnect-win-4.4.03034-core-vpn-webdeploy-k9.exe
Goto :IndividualInstall
REM Installation Function to set up McAfee Agent
:InstallMAgntb
echo Installing McAfee Agent
Start /WAIT "C:\XXXXXXXXXX\McAfee Installers\Agent_EPO2.exe"
Goto :IndividualInstall
:InstallEPOb
echo Installing McAfee Endpoint
Start /WAIT "C:\XXXXXXXXXX\McAfee Installers\2 Endpoint_Security_10_5_1\setupEP.exe"
Goto :IndividualInstall
:InstallATPb
echo Installing McAfee Adaptive Threat Protection
Start /WAIT "C:\XXXXXXXXXX\McAfee Installers\3 Adaptive_Threat_Protection_10_5_1\setupATP.exe"
Goto :IndividualInstall
:InstallDXLb
echo Installing McAfee Data Exchange Layer
Start /WAIT "C:\XXXXXXXXXX\McAfee Installers\4 DXL_Client_3_1_595\dxlsetup.exe"
Goto :IndividualInstall
goto :eof
:: Dumbass
:: if "%Window%" EQU "All Apps" ( )
:: Need to make this not an option
:: Prevent Double Jeopardy
set "Window[%1]="
if defined Next shift & goto Process
goto :eof
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
:PCC
REM Query Screen Connect
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{E8ABFA22-897F-4FCB-902A-4DCD400B53DC}
cls
if %ERRORLEVEL% EQU 0 Set SC=Yes
if %ERRORLEVEL% EQU 1 Set SC=No
REM Query KACE Exist
reg query HKLM\Software\WOW6432Node\Dell\KACE
cls
REM Error level 0 means installed
REM Error Level 1 Means Not Installed
if %ERRORLEVEL% EQU 0 SET KACE=Yes
if %ERRORLEVEL% EQU 1 SET KACE=No
REM Query Any Connect
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Cisco AnyConnect Secure Mobility Client
cls
if %ERRORLEVEL% EQU 0 SET AnyConnect=Yes
if %ERRORLEVEL% EQU 1 SET AnyConnect=No
Rem Query McAfee Agent
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{80684F9A-6B01-4F3F-A8C7-C4B7BDF072F1}
cls
if %ERRORLEVEL% EQU 0 SET MAgent=Yes
if %ERRORLEVEL% EQU 1 SET MAgent=No
Rem Query McAfee Endpoint
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{4F574B83-3AE0-419F-8A3B-985C389334B4}
cls
if %ERRORLEVEL% EQU 0 SET Endpoint=Yes
if %ERRORLEVEL% EQU 1 SET Endpoint=No
Rem Query McAfee Adaptive Thread Protection
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{80B1F696-3C8F-4BBC-BD07-86CF0E37FDD2}
cls
if %ERRORLEVEL% EQU 0 SET McAfeeAdaptiveThreatProtection=Yes
if %ERRORLEVEL% EQU 1 SET McAfeeAdaptiveThreatProtection=No
Rem Query McAfee Data Exchange Layer
reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{8f28453c-bec7-4d47-8152-3b8b40238dec}
cls
if %ERRORLEVEL% EQU 0 SET McAfeeDataExchangeLayer=Yes
if %ERRORLEVEL% EQU 1 SET McAfeeDataExchangeLayer=No
REM Query Standard X
reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{AC76BA86-1033-F400-BA7E-000000000005}
cls
if %ERRORLEVEL% EQU 0 SET StandardX=Yes
if %ERRORLEVEL% EQU 1 SET StandardX=No
REM Query Standard XI
reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{AC76BA86-1033-FFFF-7760-000000000006}
cls
if %ERRORLEVEL% EQU 0 SET StandardXI=Yes
if %ERRORLEVEL% EQU 1 SET StandardXI=No
for /f "tokens=4" %%a in ('reg query "HKEY_CURRENT_USER\SOFTWARE\XXXXXXXX\XXXXXXXXXXXXX" /V "salesperson ID" ^|findstr
/ri "Salesperson ID"') do set /a ID=%%a + 0
if %ERRORLEVEL% EQU 0 goto SkipF
if %ERRORLEVEL% EQU 1 echo XXXXXXXXXXXX is Installed BUT not configured for the user.
:SkipF
echo.
echo.
echo ---------------------------------------------------------------
echo Installed Software
echo ---------------------------------------------------------------
echo.
if /I "%SC%" EQU "Yes" echo SC Installed
if /I "%SC%" EQU "No" goto :InstallSC
if /I "%Kace%" EQU "No" goto :InstallKace
if /I "%Kace%" EQU "Yes" echo Kace Installed
if /I "%AnyConnect%" EQU "No" goto :InstallAnyC
if /I "%AnyConnect%" EQU "YES" echo AnyConnect Installed
if /I "%MAgent%" EQU "Yes" echo McAfee Agent Installed
if /I "%MAgent%" EQU "No" goto :InstallMAgnt
if /I "%Endpoint%" EQU "Yes" echo Endpoint Installed
if /I "%Endpoint%" EQU "No" goto :InstallEPO
if /I "%McAfeeAdaptiveThreatProtection%" EQU "Yes" echo McAfee Adaptive Threat Protection Installed
if /I "%Endpoint%" EQU "No" goto :InstallATP
if /I "%McAfeeDataExchangeLayer%" EQU "Yes" echo McAFee Data Exchange Layer Installed
if /I "%Endpoint%" EQU "No" goto :InstallDX
echo.
echo.
echo User: %USERNAME%
echo XXXXXXXXXXX ID: %ID%
echo.
echo ---------------------------------------------------------------------------
echo ALL SOFTWARE INSTALLED
echo ---------------------------------------------------------------------------
pause
cls
REM Query Dell Digital Delivery
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{693A23FB-F28B-4F7A-A720-4C1263F97F43}
cls
if %ERRORLEVEL% EQU 0 SET DDD=Yes
if %ERRORLEVEL% EQU 1 SET DDD=No
if /I "%DDD%" EQU "Yes" echo NOTICE
echo Dell Digital Delivery is Installed.
set /P c=Would you like to uninstall it[Y/N]?
if /I "%C%" EQU "Y" start /wait C:\Windows\System32\MsiExec.exe /I{693A23FB-F28B-4F7A-A720-4C1263F97F43}
if /I "%c%" EQU "N" goto :MainMenu
pause
goto :MainMenu
goto :eof
:IST
explorer.exe C:\XXXXXXXXXX
pause
goto MainMenu
:UninstallDDD
REM Query Standard X
reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{AC76BA86-1033-F400-BA7E-000000000005}
cls
if %ERRORLEVEL% EQU 0 SET StandardXb=Yes
if %ERRORLEVEL% EQU 1 SET StandardXb=No
REM Query Standard XI
reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{AC76BA86-1033-FFFF-7760-000000000006}
cls
if %ERRORLEVEL% EQU 0 SET StandardXIb=Yes
if %ERRORLEVEL% EQU 1 SET StandardXIb=No
for /f "tokens=4" %%a in ('reg query "HKEY_CURRENT_USER\SOFTWARE\FS StreetSmart\Field Sales Professional" /V "salesperson ID" ^|findstr
/ri "Salesperson ID"') do set /a ID=%%a + 0
:AdobeXCheck
echo Adobe Program Check
echo.
if /I "%Standardxb%" EQU "Yes" echo Adobe Standard X Installed
goto SkipA
if /I "%Standardxb%" EQU "No" goto :AdobeXICheck
pause
:AdobeXICheck
if /I "%StandardXIb%" EQU "Yes" echo Adobe Standard XI Installed
goto SkipA
if /I "%StandardXIb%" EQU "No" goto :NeitherLogic
goto SkipA
:Neitherlogic
if /I "%StandardXIb%" EQU "Yes" echo Adobe Standard X NULL
if /I "%STandardXIb%" EQU "YES" echo Adobe Standard XI Installed
if /I "%StandardXIb%" EQU "No" echo Neither Adobe X nor XI are installed!!!!
echo.
echo Please check above for Adobe Installations
set /P c=Do you still want to uninstall DDD[Y/N]?
if /I "%c%" EQU "Y" goto UninstalDDDnow
if /I "%c%" EQU "N" echo Going back to main menu
Timeout 5
goto MainMenu
:UninstalDDDnow
cls
echo Uninstalling Dell Digital Delivery
echo.
CALL "C:\Windows\System32\MsiExec.exe" /I{693A23FB-F28B-4F7A-A720-4C1263F97F43}
echo.
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{693A23FB-F28B-4F7A-A720-4C1263F97F43}
cls
if %ERRORLEVEL% EQU 0 SET DDDpost=Yes
if %ERRORLEVEL% EQU 1 SET DDDpost=No
if /I "%DDDpost%" EQU "Yes" echo Dell Digital Delivery is STILL showing Installed. Please check manually
if /I "%DDDpost%" EQU "No" echo Dell Digital Delivery has succesfully been uninstalled!
pause
goto MainMenu
pause
I was wondering...
I have a program, and I want to charge money for it.
it runs on Windows, and is written mostly in VB and Batch-files...
how can I force the user to buy a product key for it, and activate it to use the Paid Version?
Thanks in advance!
~ #Cascading-style
This just a little example showing you that you can limit the number of execution of your program , so if the maximum of number of execution is reached the program will Auto delete by him self
#echo off
Setlocal enabledelayedexpansion
Title Count the number of times my BATCH file is run
Mode Con Cols=70 lines=7 & color 0E
Set /a MaxExecution=3
set /a count=1
set "FileCount=%tmp%\%~n0.dll"
If Not exist "%FileCount%" (
echo !count! > "%FileCount%"
) else (
For /F "delims= " %%a in ('Type "%FileCount%"') Do (
set /a count=!count! + %%a
echo !count! > "%FileCount%"
)
)
echo.
echo This Program is running for "!count!" time(s)
Call :SelfDelete
pause>nul & Exit /b
::**************************************************************
:SelfDelete
echo.
If !count! GTR !MaxExecution! (
Color 0C
echo The maximum execution of this "%~nx0" is set to "!MaxExecution!"
echo and it is reached & Timeout /T 5 /Nobreak>nul & Del %~f0
) else (
echo The counting is "!count!" and the max is set to "!MaxExecution!"
)
Goto :EOF
::**************************************************************
I have 2 batch files I want to merge from 2 screens to 1 screen.
currently there is 2 screens:
1 screen is the chat room
1 screen is the message input screen.
I want to merge these into 1 batch file on the screen so it requests users input on the chat room screen
is that possible?
My code I want to merge is here:
----------------------------
chat.bat
----------------------------
#echo off
:StartUp
set rr=2
mode con cols=40 lines=8
if exist tmp.bat del /f /s /q tmp.bat
set hd=%cd%
title Remote Chat
color 0f
cls
echo [Remote Chat]
echo.
echo Made by Jordan Begg
echo 31/12/2013
set t1=%time:~6,2%
set /a t2=%t1%+2
if %t2% geq 60 set /a t2=%t2% - 59
:ExpLoop
if %time:~6,2% geq %t2% goto Go
goto ExpLoop
:Go
set cs=ChatSettings.bat
if exist %cs% (
call %cs%
goto Main
) else (
goto SetUp
)
:SetUp
cls
mkdir "C:\chat"
echo [Setup]
echo.
set /p un=Username:
if not defined un goto SetUp
:SetUp2
cls
echo [Setup]
echo.
echo Use this:
echo C:\chat
if defined sd echo Current: %sd%
echo.
set /p sd=Server folder:
if not defined sd goto SetUp2
set sd=%sd%
if not exist %sd% (
set sd=
echo Folder doesn't exist!
pause >nul
goto SetUp2
)
if exist %cs% del /f /s /q %cs%
echo set un=%un%>>%cs%
echo set sd=%sd%>>%cs%
echo set rr=4>>%cs%
goto Main
:Main
cd %hd%
cls
echo [Remote Chat]
echo.
echo 1 - Join
echo 2 - Create
echo 4 - Exit
echo.
set /p c=
if %c%==1 goto Join
if %c%==2 goto create1
if %c%==4 goto Exit
goto main
:Exit
exit
:create1
cls
echo Please enter a valid asset ID (i.e as0123456)
set /p ass=Asset:
ping -n 1 %ass% > c:\ping.tmp
type c:\ping.tmp | FIND "Approximate round trip" >NUL
IF ERRORLEVEL 1 GOTO NOPING
goto Create
:noping
echo Asset cannot be reached
echo.
goto create1
:Create
cd %sd%
set rn=
cls
echo [Create]
echo.
echo created
echo.
set rn=%ass%
echo %rn%
pause
if not defined rn goto Create
set rf=%sd%\%rn%.crm
if exist %rf% goto Create
cls
echo [Create]
echo.
echo Preparing room, please wait.
set group=Admin
echo [%time:~0,5%] %un% (admin) connected.>>%rf%
title Chat [%rn%]
cd %hd%
echo set rn=%rn%>>tmp.bat
echo set rf=%rf%>>tmp.bat
echo set group=%group%>>tmp.bat
start ChatMessage.bat
start ChatDisconnect.bat
cd %sd%
mode con cols=40 lines=16
:Admin
cls
cd %hd% >nul
if not exist tmp.bat (
set msg=Room closed successfully.
goto End
)
cd %sd% >nul
if not exist %rf% (
set msg=Connection terminated.
goto End
)
type %rf%
ping localhost -n 4 >nul
goto Admin
set t=%time:~7,1%+%rr%
if %t% GEQ 10 set /a t=%t% - 10
:AdminL
if %time:~7,1%==%t% goto Admin
:End
if exist tmp.bat del /f /s /q tmp.bat
mode con cols=40 lines=8
echo [Chat]
echo.
echo %msg%
set msg=
taskkill /f /fi "WINDOWTITLE eq Message" >nul
taskkill /f /fi "WINDOWTITLE eq Disconnect" >nul
title Chat
set group=
set rn=
set t1=%time:~6,2%
set /a t2=%t1%+2
if %t2% geq 60 set /a t2=%t2% - 5
:EndLoop
if %time:~6,2% geq %t2% goto Main
goto EndLoop
:Join
mode con cols=40 lines=16
cd %sd%
set rn=
cls
echo [Join]
echo.
if not exist %sd%\*crm (
echo No rooms available.
pause >nul
mode con cols=40 lines=8
goto Main
)
dir /b /o:n %sd%\*.crm
echo.
echo Format (no .crm at end): Room
set /p rn=Room's name:
if not defined rn goto Join
set rf=%sd%\%rn%.crm
if not exist %rf% goto Join
cls
echo [Join]
echo.
echo Joining room, please wait.
set group=User
echo [%time:~0,5%] %un% connected.>>%rf%
title Chat [%rn%]
cd %hd%
echo set rn=%rn%>>tmp.bat
echo set rf=%rf%>>tmp.bat
echo set group=%group%>>tmp.bat
start ChatMessage.bat
start ChatDisconnect.bat
cd %sd%
:User
cls
cd %hd% >nul
if not exist tmp.bat (
set msg=Disconnected successfully.
goto End
)
cd %sd% >nul
if not exist %rf% (
set msg=Connection terminated.
goto End
)
type %rf%
ping localhost -n 4 >nul
goto User
.
-----------------------
chatmessage.bat
------------------------
#echo off
if not exist tmp.bat (
exit
) else (
call tmp.bat
call ChatSettings.bat
)
title Message
mode con cols=30 lines=2
cd %sd%
:func
cls
set /p msg=Message:
if %msg:~0,3%==/me echo [%time:~0,5%] %un% %msg:~4%>>%rf%&& goto func
if not defined msg goto func
echo [%time:~0,5%] %un%: %msg%>>%rf%
goto func
I'm new to batch files scripting.
All I want is creating a batch file that calling SQL file and store results in text file .
Can anyone help me, your help is highly appreciated,
This is the first time I need to create such files.
using a batch file:
save and run this:
#echo off
sqlplus -s -l user/pass#yourdb #yoursql.sql>your_log.log
p.s. be sure to have the last line of your sql script as exit; or the batch file will hang.
sqlcmd -S sqlservername -i yoursqlfile.sql -U username -P password -o outputfile.txt
I created a more advanced launcher, try it out (you can find the latest version at http://www.unix.com/windows-and-dos-issues-and-discussions/256021-windowss-batch-launcher-oracle-sql-linux-sh-scripts-available-here.html)
Here's the code anyway:
launcher.cmd
#ECHO OFF
rem Script Launcher by Fr3dY v1.4
rem ##############################
rem Version History:
rem 1.4 - Misc. fixes
rem 1.3 - Merged with 'server launcher', now accepts both SQL and SHELL SCRIPTS
rem 1.2 - Interactive prompt to show the file on screen
rem 1.1 - No need to add 'quit;' or 'exit;' in the .sql file anymore
rem Fixed sqlplus waiting for username/password if the first attempt was unsuccessful
rem Log file is generated automatically, including date and time in name
rem Misc. fixes
rem 1.0 - Initial Version
:MAIN
::Path of PLINK
set PLINK="C:\Program Files (x86)\PuTTY\plink.exe"
::List with TNS NAMES
set dbservers=launcher-databases.txt
::List with LINUX SERVERS
set linuxservers=launcher-servers.txt
set dt=%DATE:~6,4%_%DATE:~3,2%_%DATE:~0,2%__%TIME:~0,2%_%TIME:~3,2%_%TIME:~6,2%
set dt=%dt: =0%
echo Choose launcher mode:
echo 1) Database scripts (.sql files)
echo 2) Shell scripts (.sh files)
set /p launchermode="Insert value: "
echo.
if %launchermode%==1 (
set extension=sql
set servers=%dbservers%
set mode=DB
) else (
if %launchermode%==2 (
set extension=sh
set servers=%linuxservers%
set mode=OS
) else (echo "Incorrect value, exiting..." & goto :END)
)
if exist %servers% (
goto :LISTFILES
) else echo FILE %servers% NOT FOUND, ABORTING & goto :END
:LISTFILES
echo Listing *.%extension% files...
echo.
dir /b *.%extension%
echo.
set /p file=Name of the file to be launched (without extension)?
if exist %file%.%extension% (
goto :CONFIRMSHOW
) else echo FILE %file%.%extension% NOT FOUND, ABORTING & goto :END
:CONFIRMSHOW
echo.
set /p confirm=Show the script %file%.%extension% on screen now?
if %confirm%==y (
goto :SHOWSCRIPT
) else goto :CONFIRMEXEC
echo.
:SHOWSCRIPT
echo.
echo Content of %file%.%extension%
echo ######################
type %file%.%extension%
echo.
echo ######################
echo.
:CONFIRMEXEC
set /p confirm=Are you sure you want to execute this script?
if %confirm%==y (
set /p user=%mode% username?
goto :HInput
) else echo ABORTED & goto :END
echo.
echo Output saved to %file%_%dt%.log
echo.
Goto :END
:HInput
::Hidden.cmd
::Tom Lavedas, 02/05/2013, 02/20/2013
::Carlos, 02/22/2013
::https://groups.google.com/forum/#!topic/alt.msdos.batch.nt/f7mb_f99lYI
::Version 3.0
SetLocal DisableDelayedExpansion
echo.
Echo Enter password:
Set "Line="
Rem Save 0x08 character in BS variable
For /F %%# In (
'"Prompt;$H&For %%# in (1) Do Rem"'
) Do Set "BS=%%#"
:HILoop
Set "Key="
For /F "delims=" %%# In (
'Xcopy /L /W "%~f0" "%~f0" 2^>Nul'
) Do If Not Defined Key Set "Key=%%#"
Set "Key=%Key:~-1%"
SetLocal EnableDelayedExpansion
If Not Defined Key echo. & Goto :HIEnd
If %BS%==^%Key% (Set /P "=%BS% %BS%" <Nul
Set "Key="
If Defined Line Set "Line=!Line:~0,-1!"
) Else Set /P "=*" <Nul
If Not Defined Line (EndLocal &Set "Line=%Key%"
) Else For /F delims^=^ eol^= %%# In (
"!Line!") Do EndLocal &Set "Line=%%#%Key%"
Goto :HILoop
:HIEnd
if %launchermode%==1 (
goto :EXECDB
) else goto :EXECLINUX
:EXECDB
FOR /f %%A IN (%servers%) DO CALL ECHO DATABASE: %%A & ECHO DATABASE: %%A >> %file%_%dt%.log & sqlplus -S -L %user%/!Line!#%%A < %file%.%extension% >> %file%_%dt%.log
goto :END
:EXECLINUX
FOR /f %%A IN (%servers%) DO CALL ECHO SERVER: %%A & ECHO SERVER: %%A >> %file%_%dt%.log & echo y | %PLINK% %user%#%%A -pw !Line! "exit" & %PLINK% %user%#%%A -pw !Line! -batch -m %file%.%extension% >> %file%_%dt%.log & echo. >> %file%_%dt%.log
goto :END
:END
pause