Search found 5 matches

by bxx
13 May 2023 07:14
Forum: DOS Batch Forum
Topic: Ping if unsuccessful disable and enable NIC
Replies: 1
Views: 2310

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...
by bxx
16 Apr 2023 12:25
Forum: DOS Batch Forum
Topic: Copy Specific rar file to specific folder on drive
Replies: 2
Views: 2652

Re: Copy Specific rar file to specific folder on drive

This should work:

Code: Select all

for %i in (D:\MyRarFiles\*.rar) do (copy %i Y:\%~ni\)
Don't forget: If you're putting this into a batch script, replace each percent sign with two percent signs.
by bxx
16 Apr 2023 12:17
Forum: DOS Batch Forum
Topic: Run Powershell from bat as Administrator
Replies: 7
Views: 8362

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.
by bxx
09 Mar 2023 04:11
Forum: DOS Batch Forum
Topic: Generic USB Drive Letter
Replies: 10
Views: 10076

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)))