Block Windows Shutdown with Batch - windows

I wanted to ask if it was possible to block or lengthen the windows shutdown process after starting it through a batch file.
This is my code:
#echo off
start shutdown.exe -s -t 1800
Thanks and excuse me for my bad english but I'm italian :)

Think shutdown /a will do what you ask.
I suggest you to read the man of the commend: just type it in a console and see what option is good for you.
Then to 'delay' the shutdown you can use the /t parameter and set a personalized delay (30" is default)
IT:
Prova con il comando scritto sopra, inoltre ti consiglio di leggere la descrizione di shutdown in cui ti spiega tutte le opzioni: apri un terminale e digiti 'shutdown' per avere la lista dei possibili argomenti. il parametro /t ti consente di specificare un ritardo alla chiamata di shutdown.

Related

'C:\Program' is not recognized as an internal or external command in 'Git Bash Here' terminal - Windows (salesforce sfdx) - SOLVE

I'm here to ask you a very strange problem.
Right now i'm starting to work on Salesforce technology, in windows, and currently i follow the tutorial. When finally arrive to the terminal part, Windows come out to create problem...
I state that I am using the terminal of Git Bash Here (MinTTY)
$ sfdx force:data:record:create -s Account -v "Name='Hilton Union Square' BillingStreet='333 O Farrell St' BillingCity='San Francisco' BillingState='CA' BillingPostalCode='94102' Phone='(415) 771-1400' Website='www.hilton.com'"
"C:\Program" non è riconosciuto come comando interno o esterno,
un programma eseguibile o un file batch.
More in general, the problem comes out every time there are Quote in the argument:
$ sfdx ""
"C:\Program" non è riconosciuto come comando interno o esterno,
un programma eseguibile o un file batch.
opposite to:
$ sfdx
Salesforce CLI
VERSION
sfdx-cli/7.157.0 win32-x64 node-v16.15.1
USAGE
$ sfdx [COMMAND]
TOPICS
alias manage username aliases
auth authorize an org for use with the Salesforce CLI
config configure the Salesforce CLI
......
I try almost every thing: alias, Path, Full Path, Short Path, Quote, ...
this is my current path:
PATH=/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/A409806/bin:/c/Program Files/Common Files/Oracle/Java/javapath:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Program Files (x86)/WindowsPowerShell/Scripts:/cmd:/c/Program Files/nodejs:/c/Users/A409806/AppData/Local/Microsoft/WindowsApps:/c/Program Files/sfdx/bin:/c/Users/A409806/AppData/Roaming/npm:/c/Users/A409806/AppData/Local/Programs/Microsoft VS Code/bin:/c/Users/A409806/AppData/Local/JetBrains/Toolbox/scripts:/usr/bin/vendor_perl:/usr/bin/core_perl
Please, someone help me, i suppose is MinTTY problem, but i can't immage how solve it.
Thanks agane
UPDATE
I expose same problem and find de solution here:
Solution

Behavior of "?" is fishy when trying to rename all the files of current folder(thro' Batch Script) expecting that extension would be unchanged

I have been scripting in Windows(7 64Bit) Batch engine for sometime now.
What I find really disappointing is the rename command when trying to rename all files in a folder and using "?" to keep the file extension unaltered.
Please look at the below set of commands:
#echo off
set /p filename="Desired File Name: "
rename *.* "%filename%.???"
This is supposed to keep the file extension as it is but, on the contrary, if I pass the filename as "MONEY 2016" it unexpectedly renames the files to "MONEY 2016.201", why is that ?
Also, as debugging step, I printed the filename right after getting it inputted from the user, it prints as it is with spaces, so it doesn't seem like space issue at all..
How to make this work as expected with a one-liner as short as possible ?
Here's my comment as an answer.
I'd suggest a For loop as a simple method of performing this task:
#Set /P "filename=Desired File Name: "
#For %%A In (*.*)Do #If Not Exist "%filename%%%~xA" Ren "%%A" "%filename%%%~xA" 2>Nul
Please note that this method does not perform any verification of the user input. They could enter nothing, or they may enter a filename which is invalid. I'll leave it to you to implement a verification process, should you feel it necessary.
You are changing the structure of original and new names. * certainly does not match ??? (this should be obvious). A rename command with the proper structure works well:
C:\Users\Antonio\Tests> dir
El volumen de la unidad C no tiene etiqueta.
El número de serie del volumen es: 0895-160E
Directorio de C:\Users\Antonio\Tests
28/03/2019 10:12 p. m. <DIR> .
28/03/2019 10:12 p. m. <DIR> ..
28/03/2019 10:11 p. m. 7 four.srt
28/03/2019 10:11 p. m. 7 one.mkv
28/03/2019 10:11 p. m. 7 three.avi
28/03/2019 10:11 p. m. 7 two.mp4
4 archivos 28 bytes
2 dirs 391,521,251,328 bytes libres
C:\Users\Antonio\Tests> rename *.* NewName.*
C:\Users\Antonio\Tests> dir
El volumen de la unidad C no tiene etiqueta.
El número de serie del volumen es: 0895-160E
Directorio de C:\Users\Antonio\Tests
28/03/2019 10:12 p. m. <DIR> .
28/03/2019 10:12 p. m. <DIR> ..
28/03/2019 10:11 p. m. 7 NewName.avi
28/03/2019 10:11 p. m. 7 NewName.mkv
28/03/2019 10:11 p. m. 7 NewName.mp4
28/03/2019 10:11 p. m. 7 NewName.srt
4 archivos 28 bytes
2 dirs 391,521,251,328 bytes libres

Invalid key name

In a quick and dirty backup script that's been running fine for years, the registry backup part no longer works. I run the offending code in the command line and get the same result:
C:\>reg export /y HKLM\SOFTWARE\ODBC\ODBC.INI test.reg
ERROR: nombre de clave no válido.
Escriba "REG EXPORT /?" para obtener detalles de uso.
Error translates as "invalid key name". If I lauch regedit and copy the key name to clipboard I get this:
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI
If there is a typo, I'm unable to spot it.
Am I really mistyping the key name? Is there any other reason for the error?
Documentation says this:
Reg export KeyName FileName [/y]
In other words, flags come last:
C:\>reg export HKLM\SOFTWARE\ODBC\ODBC.INI test.reg /y
La operación se ha completado correctamente.
No idea why it's been working before.

problems with CPAN::Tarzip running on a MiniCPAN mirror

I created a local repository with minicpan in a Linux box, and then moved it to a Windows that has no access to online CPAN. But I'm getting this error messages when I try to use it:
cpan> install PowerBuilder::ORCA
Reading 'C:\Perl\minicpan\authors\01mailrc.txt.gz'
Use of uninitialized value $command in concatenation (.) or string at C:\Perl\site\lib/CPAN/Tarzip.pm line 161.
"-qdt" no se reconoce como un comando interno o externo, programa o archivo por lotes ejecutable.
............................................................................DONE
Reading 'C:\Perl\minicpan\modules\02packages.details.txt.gz'
Use of uninitialized value $command in concatenation (.) or string at C:\Perl\site\lib/CPAN/Tarzip.pm line 161.
"-qdt" no se reconoce como un comando interno o externo, programa o archivo por lotes ejecutable.
Warning: Your C:\Perl\minicpan\modules\02packages.details.txt.gz does not contain a Line-Count header.
Please check the validity of the index file by comparing it to more than one CPAN mirror. I'll continue but problems seem likely to
happen.
Caught SIGINT, trying to continue
Warning: Your C:\Perl\minicpan\modules\02packages.details.txt.gz does not contain a Last-Updated header.
Please check the validity of the index file by comparing it to more than one CPAN mirror. I'll continue but problems seem likely to
happen.
Got another SIGINT
Reading 'C:\Perl\minicpan\authors\01mailrc.txt.gz'
Use of uninitialized value $command in concatenation (.) or string at C:\Perl\site\lib/CPAN/Tarzip.pm line 161.
"-qdt" no se reconoce como un comando interno o externo, programa o archivo por lotes ejecutable.
I'm suspecting this could be because of different carriage returns, but if someone has another idea about why this might be, it would be great. Also if it's because of carriage returns, do you have any idea on how to fix this without downloading the whole repository again on a Windows machine?
Delete the CPAN configuration and run its first-time configuration again.
It's still referencing e.g. the Linux path to tar, and using ANSI terminal escapes for colours.

Detect a broken internet connection using windows batch programming

I'm using an internet connection which goes down after some time. If I repair my connection it works fine. I have to do it always manually. I want to do this task automatically.
I.e. I want to create a windows batch file which is constantly running in the background. When my internet connection is down, it will renew and restart the connection again without any interaction
I want to do this task using a windows batch file. I tried this:
runas /user:local\administrator
ipconfig /release
ipconfig /flushdns
ipconfig /renew
However, I don't know how to detect whether Network connection is down or up?
I'm hoping for quick and positive response.
I made this some time ago. I think that will help you. (but in is spanish)
https://github.com/edgardok/Arregla_Internet/blob/master/ARREGLA.INTERNET.bat
:INICIO
IF EXIST respuesta.tmp DEL respuesta.tmp >nul
PING %DIRECCIONREMOTA% > respuesta.tmp
FIND /C /I "perdidos = 0" respuesta.tmp >nul
GOTO CASO%ERRORLEVEL%
:CASO1
REM ***conexion fallida***
ECHO %date% %time%. NO ESTA HABILITADA LA PLACA DE RED O NO FUNCIONA.
GOTO menu
:CASO0
REM ***conexion OK***
ECHO %date% %time%. Conexion ok.
GOTO menu
You could try and ping a widely used service in your country (or ping google like crazy) to detect internet connectivity. it's not bullet proof, but will let you know when your internet is down (probably).
The result of pinging could be checked by batch/script and according to the result, decide whether you want to ipconfig /renew or not.
The problem you must be trying to address is
Why your network connection is breaking after sometime
and not
How to repair your network connection every now and then
because if you are able to identify the root cause for first problem then you are done.
f 'r sng Wndws r bv, cn tr ths:
fcnfg | grp -c "P ddrss"
Ths wll gv th nmbr f mtchng P drsss - n cs r cnnctn s dwn, 'll hv fwr thn nrmll.
'll nd grp fr ths (s t's nt prt f Wndws), bt t cn b btnd frm ths RL: nxtls.srcfrg.nt

Resources