Search found 178 matches

by atfon
04 Apr 2023 07:11
Forum: DOS Batch Forum
Topic: How to check if a wired connection is present in a batch file?
Replies: 2
Views: 3407

Re: How to check if a wired connection is present in a batch file?

You can check the NdisMedium property of MSFT_NetAdapter if you have WMIC installed. Something like this will get you information about the type of connection you have: %__APPDIR__%wbem\WMIC.exe /NameSpace:\\root\StandardCimv2 path MSFT_NetAdapter where "InterfaceOperationalStatus='1' and Virtual='F...
by atfon
16 Mar 2023 13:43
Forum: DOS Batch Forum
Topic: fixed the problem myself
Replies: 1
Views: 2793

Re: echo special characters

Certain special characters like | require escaping. See the comments and the 1 answer in this post: https://stackoverflow.com/questions/688 ... 1#75099921
by atfon
09 Mar 2023 09:10
Forum: DOS Batch Forum
Topic: Generic USB Drive Letter
Replies: 10
Views: 10075

Re: Generic USB Drive Letter

If your system has access to WMIC, you can define the USB drive letter as a variable rather easily like this: for /f "skip=2 tokens=2 delims=," %%g in ('%__APPDIR__%wbem\WMIC.exe logicaldisk where "drivetype=2" get DeviceID 2^>nul /format:csv') do set "usbDrive=%%g" Subsequently, you can use 'if def...
by atfon
11 Jan 2023 07:21
Forum: DOS Batch Forum
Topic: COPY FILES TO SYSTEM DATE CREATED FILENAME FOLDER
Replies: 5
Views: 11852

Re: COPY FILES TO SYSTEM DATE CREATED FILENAME FOLDER

Since WMIC has been deprecated in Windows 10 and is expected to be removed in Windows 11, a more robust way to capture the date would be something like the following:

Code: Select all

for /f "tokens=1-3 delims=/: " %%a in ('%__APPDIR__%Robocopy.exe "|" . /njh ^| find ":"') do set "foldername=LOG-%%b-%%c-%%a"
by atfon
03 Jan 2023 15:03
Forum: DOS Batch Forum
Topic: How to [automatically] rename a file within a non-specified subfolder? [AKA stopping Opera from autoupdating]
Replies: 6
Views: 14862

Re: How to [automatically] rename a file within a non-specified subfolder? [AKA stopping Opera from autoupdating]

OK, so to educate myself I read what forfiles /? and ren /? spat out and: #1] I could not find a reference to 2>nul - what does it do / where does it come from? For this question, I would suggest reading up on Redirection: https://ss64.com/nt/syntax-redirection.html This is to hide STDERR (error me...
by atfon
15 Dec 2022 13:58
Forum: DOS Batch Forum
Topic: Increasing text size in a batch file
Replies: 7
Views: 16535

Re: Increasing text size in a batch file

Once again, see this post for how to set the font size and name in the Console: https://www.dostips.com/forum/viewtopic.php?t=10156 There are multiple posts out there on how to change the font color of individual words. For example, see this one to change the font color: https://stackoverflow.com/qu...
by atfon
15 Dec 2022 08:41
Forum: DOS Batch Forum
Topic: Increasing text size in a batch file
Replies: 7
Views: 16535

Re: Increasing text size in a batch file

This topic may be of interest:

viewtopic.php?t=10156
by atfon
05 Dec 2022 09:27
Forum: DOS Batch Forum
Topic: copy
Replies: 12
Views: 10560

Re: copy

key wrote:
05 Dec 2022 05:32
not working
"not working" is not a helpful response. What isn't working? What message do you receive when you issue the commands Saso suggested?
by atfon
23 Nov 2022 12:24
Forum: DOS Batch Forum
Topic: findstr default gateway
Replies: 6
Views: 6634

Re: findstr default gateway

expect only three lines containing pattern, but got more lines netstat -rn | findstr /C:"0.0.0.0" 0.0.0.0 0.0.0.0 10.12.70.65 10.12.70.66 281 0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.236 50 224.0.0.0 240.0.0.0 On-link 127.0.0.1 331 224.0.0.0 240.0.0.0 On-link 169.254.71.163 281 224.0.0.0 240.0.0.0 On-...
by atfon
04 Aug 2022 12:55
Forum: DOS Batch Forum
Topic: Is batch script able to tell the rest of BAT file to run As Administrator?
Replies: 4
Views: 4949

Re: Is batch script able to tell the rest of BAT file to run As Administrator?

There are several examples out there of how to auto-check for privileges and elevate as needed. Here is a simple example: ( >nul 2>&1 %__APPDIR__%net.exe session ) || ( echo Set UAC = CreateObject^("Shell.Application"^) > "%tmp%\uac.vbs" echo UAC.ShellExecute "%~snx0", "%*", "%~sdp0", "runas", 1 >> ...
by atfon
09 Jun 2022 06:11
Forum: DOS Batch Forum
Topic: Run Dialog Box
Replies: 2
Views: 4384

Re: Run Dialog Box

This is untested from a non-Admin account, but you could try this:

1. Create a Shortcut to the Run dialog. For the location, use the following: explorer shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}
2. From the Properties of this Shortcut, go to Advanced and select Run as Administrator.
by atfon
26 May 2022 06:14
Forum: DOS Batch Forum
Topic: How to determine privileges?
Replies: 6
Views: 9018

Re: How to determine privileges?

Depending on the level of privileges you want to determine, could you search by the Security Identifier? For example, the INFO.BAT script on this site https://www.dostips.com/forum/viewtopic.php?f=3&t=6108&p=49091#p49091 uses the following to check for Admin privileges: whoami /groups |findstr /i "\...
by atfon
29 Apr 2022 08:39
Forum: DOS Batch Forum
Topic: Scripts to get hour not always correct
Replies: 4
Views: 7796

Re: Scripts to get hour not always correct

Have a look at this post from aGerman where he explains how to set a clock to AM/PM: viewtopic.php?f=3&t=2051#p64840
by atfon
28 Apr 2022 06:15
Forum: DOS Batch Forum
Topic: How to define screen buffer size for "Mode 120,60" command?
Replies: 8
Views: 10297

Re: How to define screen buffer size for "Mode 120,60" command?

If you are open to powershell, I've done this from a batch script:

Code: Select all

powershell.exe -noprofile -command "&{$w=(get-host).ui.rawui;$w.buffersize=@{width=120;height=9001};$w.windowsize=@{width=120;height=60};}"
by atfon
08 Apr 2022 20:32
Forum: DOS Batch Forum
Topic: First Post: Set file name full date subtract 1 day
Replies: 7
Views: 8529

Re: First Post: Set file name full date subtract 1 day

What happen if current day is the 1st one? One day before would be the last day of previous month... If the current day is January/1st, then one day before would be December/31 of previous year... If current day is March/1st the day before would be February/28, excepting if the year is a leap year....