• We've upgraded our forums. Please post any issues/requests in this thread.

Batch file to ping network

Joined
Feb 19, 2006
Messages
538
Likes
31
Processor Intel i7 920
Motherboard ASUS RAMPAGE II Extreme
Cooling CM v10
Memory Corsair 3 x 2GB TR3X6G1866C9DF
Video Card(s) Nvidia XFX 8800GT Stock
Storage Seagate ST3500320AS, 2 x Samsung HD103UJ
Display(s) 2408WFP
Case Corsair 800D
Power Supply Corsair HX750W
#1
Hi Guys,

I need some help writing a batch file to test network connectivity for various locations.
Basically we are transitioning to from an existing network provider to a new network provider.

What I would like the script to do

Ping a list of IP address and then output the results into a simple text file of each IP Address.

The text file ideally should just display
something along the lines of

ping www.google.com Successful

or

ping www.google.com Unsuccessful

This is what I have so far but it is a bit broken.
Code:
@echo off
Title Cut over to Telstra Check

set OutputFile=result.txt
cd\
CLS

Echo. Cut over test
Echo. 
Echo. Ping all sites
Pause
Ping www.google.com.au | find "Reply"
	echo ping to google successful >>"C:\nettest\OutputFile.txt"

	IF NOT echo ping to google unsuccessful >>"C:\nettest\OutputFile.txt"

Ping www.techpowerup.com | find "Reply"
	echo ping to TechPowerup successful >>"C:\nettest\OutputFile.txt"

	IF NOT echo ping to Techpowerup unsuccessful >>"C:\nettest\OutputFile.txt"
pause
I'm not sure how to do a IF NOT command and make it jump to the next line.

Thanks!
 
Joined
Dec 27, 2008
Messages
587
Likes
104
System Name New / Breakin' the Lol
Processor i5 2500k / Athlon64 X2 4200+ (65W)
Motherboard P8Z68-V PRO/GEN3 / Asus M2N4-SLI
Cooling / Air (1 x 250mm, 2 x 120mm, 1 x 90mm)
Memory DDR3-1600 (8GB) / Crucial Ballistix Tracer PC2-6400 (2gb)
Video Card(s) / Visiontek 4870
Storage HD103SJ /
Display(s) Viewsonic 22" VX2240W
Case Xigmatek Midgard II / Thermaltake VA8003SWA
Power Supply PC Power & Cooling Silencer 750W
#2
I don't know much about programming, but what about an "Else" statement?

This guy knows more: Batch files branching
 
Joined
Feb 19, 2006
Messages
538
Likes
31
Processor Intel i7 920
Motherboard ASUS RAMPAGE II Extreme
Cooling CM v10
Memory Corsair 3 x 2GB TR3X6G1866C9DF
Video Card(s) Nvidia XFX 8800GT Stock
Storage Seagate ST3500320AS, 2 x Samsung HD103UJ
Display(s) 2408WFP
Case Corsair 800D
Power Supply Corsair HX750W
#3
haha we are on the same boat, I'm clueless when it comes to programming.

I'll give it a go =)
 
Joined
Nov 4, 2005
Messages
9,946
Likes
2,309
System Name MoFo 2
Processor AMD PhenomII 1100T @ 4.2Ghz
Motherboard Asus Crosshair IV
Cooling Swiftec 655 pump, Apogee GT,, MCR360mm Rad, 1/2 loop.
Memory 8GB DDR3-2133 @ 1900 8.9.9.24 1T
Video Card(s) HD7970 1250/1750
Storage Agility 3 SSD 6TB RAID 0 on RAID Card
Display(s) 46" 1080P Toshiba LCD
Case Rosewill R6A34-BK modded (thanks to MKmods)
Audio Device(s) ATI HDMI
Power Supply 750W PC Power & Cooling modded (thanks to MKmods)
Software A lot.
Benchmark Scores Its fast. Enough.
#4
Joined
Feb 19, 2006
Messages
538
Likes
31
Processor Intel i7 920
Motherboard ASUS RAMPAGE II Extreme
Cooling CM v10
Memory Corsair 3 x 2GB TR3X6G1866C9DF
Video Card(s) Nvidia XFX 8800GT Stock
Storage Seagate ST3500320AS, 2 x Samsung HD103UJ
Display(s) 2408WFP
Case Corsair 800D
Power Supply Corsair HX750W
#5
Thats a good idea however could we make the text file name indicate if it was successful or not or is that the complicated bit?

Also on another note would it be easier to do this in vb script?
 
Joined
Nov 4, 2005
Messages
9,946
Likes
2,309
System Name MoFo 2
Processor AMD PhenomII 1100T @ 4.2Ghz
Motherboard Asus Crosshair IV
Cooling Swiftec 655 pump, Apogee GT,, MCR360mm Rad, 1/2 loop.
Memory 8GB DDR3-2133 @ 1900 8.9.9.24 1T
Video Card(s) HD7970 1250/1750
Storage Agility 3 SSD 6TB RAID 0 on RAID Card
Display(s) 46" 1080P Toshiba LCD
Case Rosewill R6A34-BK modded (thanks to MKmods)
Audio Device(s) ATI HDMI
Power Supply 750W PC Power & Cooling modded (thanks to MKmods)
Software A lot.
Benchmark Scores Its fast. Enough.
#6
No, batch files are extremely easy.

A "If" requires three extra steps.

Code is not how much you can put in, but how lite can you make it and still perform the functions.

So

@ echo off


ping 1.4.1.4 >a.txt

findstr /m "Request timed out" a.txt
if %errorlevel%%==0 (
echo Save our nets!!!
)

pause
 

Mindweaver

Moderato®™
Staff member
Joined
Apr 16, 2009
Messages
6,570
Likes
3,904
Location
Charleston, SC
System Name Sechs / EyeSeven
Processor i7 5820k @ 4.5ghz / i7 2600k @ 4.0Ghz
Motherboard X99S GAMING 7 / ASRock Z68 Extreme3 Gen3
Cooling CORSAIR Hydro Series H100i Extreme / Stock cooler... H50 leaked!..
Memory G.Skill DDR4 2800 16GB 4x4GB / G.Skill DDR3 1600 8gb 2x4GB
Video Card(s) PNY Quadro K2000 / MSI GTX 970 GAMING 4Gb
Storage Samsung 850 PRO 256GB SSD /Intel 240gb, corsair 120gb SSD, 3x 1 tb s storage
Display(s) 2x Acer G276HL 27" 1080p / 3x Acer 22" Nvidia surround
Case Phanteks “Enthoo Pro series”/ Cooler Master Storm Scout
Audio Device(s) Azalia Realtek ALC1150 / SB X-Fi Gamer
Power Supply Corsair CXM CX600M / Corsair 600w
Mouse Razer DeathAdder Chroma / Razer DeathAdder
Keyboard Razer BlackWidow Ultimate /
Software Windows 10 Pro x64 / Windows 10 Pro x64
#7
You need to use GOTO :toast:

EDIT: I would write an example.. but I'm off to bed. If you are still having problems tomorrow. I'll chime in. :toast: Steevo is on the right track! :toast:
 
Joined
Feb 19, 2006
Messages
538
Likes
31
Processor Intel i7 920
Motherboard ASUS RAMPAGE II Extreme
Cooling CM v10
Memory Corsair 3 x 2GB TR3X6G1866C9DF
Video Card(s) Nvidia XFX 8800GT Stock
Storage Seagate ST3500320AS, 2 x Samsung HD103UJ
Display(s) 2408WFP
Case Corsair 800D
Power Supply Corsair HX750W
#8
Okay... getting confused, Sorry I'm a noob programmer.

I've copied Steevo code and tried to modify it to suit my requirements and it isn't working. I presume I'm suppose to use the goto command

Code:
@echo off

echo testing 1.4.1.4
ping 1.4.1.4 >a.txt

findstr /m "Request timed out" a.txt
if %errorlevel%%==0 (
echo Save our nets!!!
)

echo testing google
ping www.google.com.au >google.txt

findstr /m "Request timed out" google.txt
if %errorlevel%%==0 (
echo Save our nets!!!
)

findstr /m "Reply from" google.txt
if %errorlevel%%==0 (
echo yay google working!!!

pause
I understand that the idea is to make it as light as possible but the reason why I'm trying to make it as automated as possible is because we plan on level 1 people to test network connectivity at a few different sites as we are short on resources and we are required to do all of this on a Saturday morning (my usual catch up on sleep time).

I just realized i'm going to need to make the bat files create text files.

edit okay simple fix would be to put del *.txt which would delete all text files and pretty much refresh it all the time at the beginning.
 
Last edited:
Joined
Nov 4, 2005
Messages
9,946
Likes
2,309
System Name MoFo 2
Processor AMD PhenomII 1100T @ 4.2Ghz
Motherboard Asus Crosshair IV
Cooling Swiftec 655 pump, Apogee GT,, MCR360mm Rad, 1/2 loop.
Memory 8GB DDR3-2133 @ 1900 8.9.9.24 1T
Video Card(s) HD7970 1250/1750
Storage Agility 3 SSD 6TB RAID 0 on RAID Card
Display(s) 46" 1080P Toshiba LCD
Case Rosewill R6A34-BK modded (thanks to MKmods)
Audio Device(s) ATI HDMI
Power Supply 750W PC Power & Cooling modded (thanks to MKmods)
Software A lot.
Benchmark Scores Its fast. Enough.
#9
Just reuse the same name and it will overwrite the files each time the batch is run.
 

Aquinus

Resident Wat-man
Joined
Jan 28, 2012
Messages
10,397
Likes
5,474
Location
Concord, NH
System Name Kratos
Processor Intel Core i7 3930k @ 4.2Ghz
Motherboard ASUS P9X79 Deluxe
Cooling Zalman CPNS9900MAX 130mm
Memory G.Skill DDR3-2133, 16gb (4x4gb) @ 9-11-10-28-108-1T 1.65v
Video Card(s) MSI AMD Radeon R9 390 GAMING 8GB @ PCI-E 3.0
Storage 2x120Gb SATA3 Corsair Force GT Raid-0, 4x1Tb RAID-5, 1x500GB
Display(s) 1x LG 27UD69P (4k), 2x Dell S2340M (1080p)
Case Antec 1200
Audio Device(s) Onboard Realtek® ALC898 8-Channel High Definition Audio
Power Supply Seasonic 1000-watt 80 PLUS Platinum
Mouse Logitech G602
Keyboard Rosewill RK-9100
Software Ubuntu 17.10
Benchmark Scores Benchmarks aren't everything.
#11
You could install Cygwin and use BASH which is much more capable of doing what you're describing. I've actually written a script that does something like this using Ruby, where it takes in a list of IPs and returns a list of connected or disconnected users in either easy to read or XML format. Maybe something like that is what you're looking for? This is unmodified but might suit your purposes on a POSIX machine with BASH and Ping.

Code:
#!/usr/bin/ruby1.9.1
require "nokogiri"

ipfile = File.open('/etc/openvpn/ipp.txt')
threads = Array.new
results = Array.new

connected = false
disconnected = false
as_xml = false

ARGV.each do |arg|
  case arg
  when "--xml"
    as_xml = true
  when "--connected"
    connected = true
  when "--disconnected"
    disconnected = true
  end
end

if !connected and !disconnected
  print "Usage: ovpn-stat.rb [--connected] [--disconnected] [--xml]\n"
  print "    --(dis)connected displays users who fit that connection status.\n"
  print "    --xml returns the result as xml.\n"
  exit
end

ipfile.each do |line|
  threads << Thread.new do
    splitted = line.split(',')
    result = `ping -q -c 1 #{splitted[1]}`
    if($?.exitstatus == 0)
      cstr = "Connected"
    else
      cstr = "Disconnected"
    end
    r = Hash.new
    r["user"] = splitted[0]
    r["ip"] = splitted[1].sub(/\n/, '')
    r["status"] = cstr
    if (cstr == "Connected" and connected) or (cstr == "Disconnected" and discon                                                                                                                                   nected)
      results << r
    end
  end
end

threads.each do |i|
  i.join
end

if as_xml
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.vpnclients {
      results.each do |ci|
      xml.client {
        xml.user ci["user"]
        xml.ip ci["ip"]
        xml.status ci["status"]
      }
      end
    }
  end
  print builder.to_xml
  exit
end

results.each do |i|
  print "#{i["user"]}@#{i["ip"]} - #{i["status"]}\n"
end
It's not quite what you need since it reads the OpenVPN ipp.txt file (all users and their ips since ips are persistent between sessions and it overrides the DHCP server.) With a few modifications this could be something you could use.
 

Mindweaver

Moderato®™
Staff member
Joined
Apr 16, 2009
Messages
6,570
Likes
3,904
Location
Charleston, SC
System Name Sechs / EyeSeven
Processor i7 5820k @ 4.5ghz / i7 2600k @ 4.0Ghz
Motherboard X99S GAMING 7 / ASRock Z68 Extreme3 Gen3
Cooling CORSAIR Hydro Series H100i Extreme / Stock cooler... H50 leaked!..
Memory G.Skill DDR4 2800 16GB 4x4GB / G.Skill DDR3 1600 8gb 2x4GB
Video Card(s) PNY Quadro K2000 / MSI GTX 970 GAMING 4Gb
Storage Samsung 850 PRO 256GB SSD /Intel 240gb, corsair 120gb SSD, 3x 1 tb s storage
Display(s) 2x Acer G276HL 27" 1080p / 3x Acer 22" Nvidia surround
Case Phanteks “Enthoo Pro series”/ Cooler Master Storm Scout
Audio Device(s) Azalia Realtek ALC1150 / SB X-Fi Gamer
Power Supply Corsair CXM CX600M / Corsair 600w
Mouse Razer DeathAdder Chroma / Razer DeathAdder
Keyboard Razer BlackWidow Ultimate /
Software Windows 10 Pro x64 / Windows 10 Pro x64
#12
I usually don't like doing all the work for someone.. but I thought this project would be fun! Plus, I wanted to show the power of a batch file! hehehe There's a lot of easier languages out there and we are all quick to say, "Do it in vb or c# or so on". ...But Some times it's good to write a batch file just because.. hehehe

Code:
@ECHO off

::============================================
:: \\\\\\\\\\\\\\   Variables   //////////////
::============================================
SET drive=c:\nettest
SET OutputFile=result.txt
SET tt=%time:~0,2%_%time:~3,2%_result.txt
SET folder=%date:/=-% %tt%
SET site1=www.google.com
SET site2=www.techpowerup.com


::============================================
:: \\\\\\\\\\\\\\   Message   ////////////////
::============================================

COLOR 9F
ECHO. Welcome to Mindweaver's
ECHO. Cut over test
ECHO. 
ECHO. Ping all sites
PAUSE

GOTO Google

::==================================================
:: \\\\\\\\\\\\\\   Pinging Google  ////////////////
::==================================================
:Google
PING -n 2 %site1% | find "Reply from"

::Check to see if ping was successful or unsuccesful
::successful = :found1
::unsuccessful = :nfound1
IF NOT ERRORLEVEL 1 GOTO found1
IF ERRORLEVEL 1 GOTO nfound1


::Check to see if folder exists
:found1
ECHO.
ECHO Google found!
ECHO.
IF EXIST "%drive%\%folder%" GOTO :write1
IF NOT EXIST "%drive%\%folder%\" GOTO :create1

		::Folder found - writes output
		:write1
		ECHO ping to google successful on Date (%date%), Time (%time%). >>"%drive%\%folder%\%tt%" 
		GOTO techpowerup

		::Folder not found - creates folder and writes output
		:create1
		MD "%drive%\%folder%\"
			
		ECHO ping to google successful on Date (%date%), Time (%time%). >>"%drive%\%folder%\%tt%" 
		GOTO techpowerup

:nfound1
ECHO.
ECHO ###Google NOT FOUND!
ECHO.
IF EXIST "%drive%\%folder%" GOTO :write2
IF NOT EXIST "%drive%\%folder%\" GOTO :create2

		:write2
		ECHO ping to google unsuccessful on Date (%date%), Time (%time%). >>"%drive%\%folder%\%tt%" 
		GOTO techpowerup

		:create2
		MD "%drive%\%folder%\"

		ECHO ping to google unsuccessful on Date (%date%), Time (%time%). >>"%drive%\%folder%\%tt%" 
		GOTO techpowerup

::========================================================
:: \\\\\\\\\\\\\\   Pinging Techpowerup!  ////////////////
::========================================================
:techpowerup
PING -n 2 %site2% | find "Reply from"
IF NOT ERRORLEVEL 1 GOTO found2
IF ERRORLEVEL 1 GOTO nfound2
:found2
ECHO.
ECHO Techpowerup! found!
ECHO ping to Techpowerup! successful on Date (%date%), Time (%time%). >>"%drive%\%folder%\%tt%" 
GOTO Finished

:nfound2
ECHO.
ECHO ###Techpowerup! NOT FOUND!
ECHO ping to Techpowerup! unsuccessful on Date (%date%), Time (%time%). >>"%drive%\%folder%\%tt%" 
GOTO Finished


::==========================================================
:: \\\\\\\\\\\\\\   Cut over test finished  ////////////////
::==========================================================
:Finished
ECHO.
ECHO Cut over test Completed!
ECHO.

@PAUSE

::========================================================================
:: \\\\\\\\\\\\\\   Created by Mindweaver @ Techpowerup!  ////////////////
::========================================================================
EDIT: Added file to download. :toast:
 

Attachments

Last edited:
Joined
Feb 6, 2007
Messages
2,576
Likes
510
Processor Mysterious Engineering Prototype
Motherboard Intel 865
Cooling Custom block made in workshop
Memory Corsair XMS 2GB
Video Card(s) FireGL X3-256
Display(s) 1600x1200 SyncMaster x 2 = 3200x1200
Software Windows 2003
#13
Man deserves credit
 

Mindweaver

Moderato®™
Staff member
Joined
Apr 16, 2009
Messages
6,570
Likes
3,904
Location
Charleston, SC
System Name Sechs / EyeSeven
Processor i7 5820k @ 4.5ghz / i7 2600k @ 4.0Ghz
Motherboard X99S GAMING 7 / ASRock Z68 Extreme3 Gen3
Cooling CORSAIR Hydro Series H100i Extreme / Stock cooler... H50 leaked!..
Memory G.Skill DDR4 2800 16GB 4x4GB / G.Skill DDR3 1600 8gb 2x4GB
Video Card(s) PNY Quadro K2000 / MSI GTX 970 GAMING 4Gb
Storage Samsung 850 PRO 256GB SSD /Intel 240gb, corsair 120gb SSD, 3x 1 tb s storage
Display(s) 2x Acer G276HL 27" 1080p / 3x Acer 22" Nvidia surround
Case Phanteks “Enthoo Pro series”/ Cooler Master Storm Scout
Audio Device(s) Azalia Realtek ALC1150 / SB X-Fi Gamer
Power Supply Corsair CXM CX600M / Corsair 600w
Mouse Razer DeathAdder Chroma / Razer DeathAdder
Keyboard Razer BlackWidow Ultimate /
Software Windows 10 Pro x64 / Windows 10 Pro x64
#14
Joined
Feb 19, 2006
Messages
538
Likes
31
Processor Intel i7 920
Motherboard ASUS RAMPAGE II Extreme
Cooling CM v10
Memory Corsair 3 x 2GB TR3X6G1866C9DF
Video Card(s) Nvidia XFX 8800GT Stock
Storage Seagate ST3500320AS, 2 x Samsung HD103UJ
Display(s) 2408WFP
Case Corsair 800D
Power Supply Corsair HX750W
#15
I really appreciate it, your 50x better than mine.
I never mean't for someone to write the entire code just point me in the right direction.

May I ask for me to add more sites do I just add more set like below?

SET site3=www.hotmail.com
SET site4=www.awesomer.com

edit: sorry just read the code carefully, need to lots of copy paste. Thanks all!
 
Last edited:

Mindweaver

Moderato®™
Staff member
Joined
Apr 16, 2009
Messages
6,570
Likes
3,904
Location
Charleston, SC
System Name Sechs / EyeSeven
Processor i7 5820k @ 4.5ghz / i7 2600k @ 4.0Ghz
Motherboard X99S GAMING 7 / ASRock Z68 Extreme3 Gen3
Cooling CORSAIR Hydro Series H100i Extreme / Stock cooler... H50 leaked!..
Memory G.Skill DDR4 2800 16GB 4x4GB / G.Skill DDR3 1600 8gb 2x4GB
Video Card(s) PNY Quadro K2000 / MSI GTX 970 GAMING 4Gb
Storage Samsung 850 PRO 256GB SSD /Intel 240gb, corsair 120gb SSD, 3x 1 tb s storage
Display(s) 2x Acer G276HL 27" 1080p / 3x Acer 22" Nvidia surround
Case Phanteks “Enthoo Pro series”/ Cooler Master Storm Scout
Audio Device(s) Azalia Realtek ALC1150 / SB X-Fi Gamer
Power Supply Corsair CXM CX600M / Corsair 600w
Mouse Razer DeathAdder Chroma / Razer DeathAdder
Keyboard Razer BlackWidow Ultimate /
Software Windows 10 Pro x64 / Windows 10 Pro x64
#16
I really appreciate it, your 50x better than mine.
I never mean't for someone to write the entire code just point me in the right direction.

May I ask for me to add more sites do I just add more set like below?

SET site3=www.hotmail.com
SET site4=www.awesomer.com

edit: sorry just read the code carefully, need to lots of copy paste. Thanks all!
No problem Yin. Like I said it sparked my interest.. hehehe Plus, I started out pointing you in the right direction with GOTO. ;) But about adding more sites. Just copy
Code:
::========================================================
:: \\\\\\\\\\\\\\   Pinging Techpowerup!  ////////////////
::========================================================
:techpowerup
PING -n 2 %site2% | find "Reply from"
IF NOT ERRORLEVEL 1 GOTO found2
IF ERRORLEVEL 1 GOTO nfound2
:found2
ECHO.
ECHO Techpowerup! found!
ECHO ping to Techpowerup! successful on Date (%date%), Time (%time%). >>"%drive%\%folder%\%tt%" 
GOTO Finished

:nfound2
ECHO.
ECHO ###Techpowerup! NOT FOUND!
ECHO ping to Techpowerup! unsuccessful on Date (%date%), Time (%time%). >>"%drive%\%folder%\%tt%" 
GOTO Finished
down and then paste it below. Then change where it says, "Techpowerup!" and "site2". You will need to create a new "site3" Variable and your done. :toast:
 
Joined
Feb 19, 2006
Messages
538
Likes
31
Processor Intel i7 920
Motherboard ASUS RAMPAGE II Extreme
Cooling CM v10
Memory Corsair 3 x 2GB TR3X6G1866C9DF
Video Card(s) Nvidia XFX 8800GT Stock
Storage Seagate ST3500320AS, 2 x Samsung HD103UJ
Display(s) 2408WFP
Case Corsair 800D
Power Supply Corsair HX750W
#17
Ok... Noob question

How do I make Mindweaver's script create a folder where the bat file is.

eg. we have the bat file on a usb g:\nettest.bat. So the logs save on g:\ instead of c:\.

I tried changing SET drive to = \

but that just breaks the entire script.
 
Joined
Feb 19, 2006
Messages
538
Likes
31
Processor Intel i7 920
Motherboard ASUS RAMPAGE II Extreme
Cooling CM v10
Memory Corsair 3 x 2GB TR3X6G1866C9DF
Video Card(s) Nvidia XFX 8800GT Stock
Storage Seagate ST3500320AS, 2 x Samsung HD103UJ
Display(s) 2408WFP
Case Corsair 800D
Power Supply Corsair HX750W
#19
Sorry, I must of not made that clear.

I meant that the value would be a variable depending on where you run the bat file from.

the usb or the file may not be on g: it could be e: or f:.

I don't know if that made any sense.....
 

Mindweaver

Moderato®™
Staff member
Joined
Apr 16, 2009
Messages
6,570
Likes
3,904
Location
Charleston, SC
System Name Sechs / EyeSeven
Processor i7 5820k @ 4.5ghz / i7 2600k @ 4.0Ghz
Motherboard X99S GAMING 7 / ASRock Z68 Extreme3 Gen3
Cooling CORSAIR Hydro Series H100i Extreme / Stock cooler... H50 leaked!..
Memory G.Skill DDR4 2800 16GB 4x4GB / G.Skill DDR3 1600 8gb 2x4GB
Video Card(s) PNY Quadro K2000 / MSI GTX 970 GAMING 4Gb
Storage Samsung 850 PRO 256GB SSD /Intel 240gb, corsair 120gb SSD, 3x 1 tb s storage
Display(s) 2x Acer G276HL 27" 1080p / 3x Acer 22" Nvidia surround
Case Phanteks “Enthoo Pro series”/ Cooler Master Storm Scout
Audio Device(s) Azalia Realtek ALC1150 / SB X-Fi Gamer
Power Supply Corsair CXM CX600M / Corsair 600w
Mouse Razer DeathAdder Chroma / Razer DeathAdder
Keyboard Razer BlackWidow Ultimate /
Software Windows 10 Pro x64 / Windows 10 Pro x64
#20
Sorry, I must of not made that clear.

I meant that the value would be a variable depending on where you run the bat file from.

the usb or the file may not be on g: it could be e: or f:.

I don't know if that made any sense.....
Use "%~dp0" to find out where the file lives. Change "SET drive=c:\nettest" to "SET drive=%~dp0". You will also need to change "%drive%\" to "%drive%" because "%~dp0" will put the "\" for you. After changing "SET drive=c:\nettest" to "SET drive=%~dp0", I would do a search and replace all "%drive%\" with "%drive%". :toast:
 

ondove

New Member
Joined
Sep 10, 2014
Messages
1
Likes
0
#21
thanks a bunch for this , made my job a whole lot easier, got a network of keyboardless computers and onscreen keybord sucks after computer #10.