Search found 5 matches
- 13 May 2023 07:14
- Forum: DOS Batch Forum
- Topic: Ping if unsuccessful disable and enable NIC
- Replies: 1
- Views: 2323
Re: Ping if unsuccessful disable and enable NIC
Here's what I came up with, it's all one line: ping 192.0.2.1 && echo all good || (timeout 180 & ping 192.0.2.1 || (netsh interface set interface "Adapter" disable && netsh interface set interface "Adapter" enable)) To get the name of your network adapter, you can run "netsh interface show interface...
- 29 Apr 2023 06:08
- Forum: DOS Batch Forum
- Topic: Deleting only certain files from specified location and its sub-folders [SOLVED]
- Replies: 5
- Views: 5234
Re: Deleting only certain files from specified location and its sub-folders
Use del /A to delete hidden files, like
Code: Select all
del /A *.xlsm
- 16 Apr 2023 12:25
- Forum: DOS Batch Forum
- Topic: Copy Specific rar file to specific folder on drive
- Replies: 2
- Views: 2677
Re: Copy Specific rar file to specific folder on drive
This should work:
Don't forget: If you're putting this into a batch script, replace each percent sign with two percent signs.
Code: Select all
for %i in (D:\MyRarFiles\*.rar) do (copy %i Y:\%~ni\)
- 16 Apr 2023 12:17
- Forum: DOS Batch Forum
- Topic: Run Powershell from bat as Administrator
- Replies: 7
- Views: 8408
Re: Run Powershell from bat as Administrator
try removing the -noexit maybe? From what i can tell it's starting your script from the *first* powershell, the one you invoke from cmd as non-admin.
- 09 Mar 2023 04:11
- Forum: DOS Batch Forum
- Topic: Generic USB Drive Letter
- Replies: 10
- Views: 10143
Re: Generic USB Drive Letter
You can just find what drive letter matches the USB.
Code: Select all
for %u in (D E F G H I J K L) do (for /F "tokens=3" %a in ('fsutil fsinfo drivetype %u:') do (if "%a"=="Removable" (set _USBDRIVELETTER=%u&echo %u is an USB)))