• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

SOLVED output cmd line to a txt file

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

jediobi1

Member
Joined
Apr 27, 2003
hey everyone i found this command that lists all of the shared drive locations in a cmd window with the full path and i want to make it into a batch file that will run and then output the results to a txt file where ever the batch file is, can anyone help?

Code:
wmic path Win32_LogicalDisk Where DriveType="4" get DeviceID, ProviderName
 
Last edited:
I don't have any drives mapped on this box but wouldn't just adding >>c:\results.txt to the command do the trick?

Edited to add that > will create the file and overwrite it each time. >> will append to it if it exists
 
I don't have any drives mapped on this box but wouldn't just adding >>c:\results.txt to the command do the trick?

Edited to add that > will create the file and overwrite it each time. >> will append to it if it exists
tried it and at first it gave me an error of access denied so i ran it as admin and it worked but the txt file was blank, so it needs to work without admin rights and it needs to output to a txt file
 
If I remember my DOS batch file commands, the pipe | is what you use with a filename after to write the resulting screen output to a .txt file.

Of course, if your in Windows 7, you could just right click on My Computer, go-to Management (I think that's what it's called) and in the left hand pane, there is a Shared Folders entry that will allow you to see all the shared folders on your PC, as well as manage them.
 
As mentioned above, the ">" will redirect output to a file, ">>" will append output to a file. WMI commands probably all require elevated permissions to run, and you'll need admin to write to C: most likely.

However, if your output file gets created, but is empty, that means your command didn't return any results. Change drivetype to 3 and see if you get results.
 
As mentioned above, the ">" will redirect output to a file, ">>" will append output to a file. WMI commands probably all require elevated permissions to run, and you'll need admin to write to C: most likely.

However, if your output file gets created, but is empty, that means your command didn't return any results. Change drivetype to 3 and see if you get results.

http://superuser.com/questions/384692/how-do-i-find-where-a-network-drive-is-mapped-to-in-windows-7
 
If I remember my DOS batch file commands, the pipe | is what you use with a filename after to write the resulting screen output to a .txt file.

Of course, if your in Windows 7, you could just right click on My Computer, go-to Management (I think that's what it's called) and in the left hand pane, there is a Shared Folders entry that will allow you to see all the shared folders on your PC, as well as manage them.

i used this command last night and this was alot easier as i copied the cmd window txt to a txt file and put it on a thumb drive and after i got their new machine up and running i just copied it each one into the map network share instead of typing them
 
ok i got it working i was putting the output command in the wrong spot thanks
 
I used the following command and it worked just fine.

C:\>wmic path Win32_LogicalDisk Where DriveType="4" get DeviceID, ProviderName >>c:\outputfiles\testwmic.txt

DeviceID ProviderName
A: \\remoteshare1\SubDir\MyNavy Command_Location_1
B: \\remoteshare1\SubDir\MyNavy Command_Location_2
G: \\remoteshare1\SubDir\MyNavy Command_Location_UIC1
H: \\remoteshare2.FQDN\Me$
I: \\remoteshare1\SubDir\MyNavy Command_Location_UIC2
J: \\remoteshare1\SubDir\MyNavy Command_Location_UIC3
K: \\remoteshare1\SubDir\NPC_Location_3\Directory
L: \\remoteshare1\SubDir\MyNavy Command_Location_4
M: \\remoteshare1\SubDir\NPC_Location_5
O: \\remoteshare1\SubDir\NPC_Location_6
Q: \\remoteshare1\SubDir\MyNavy Command_7
R: \\RemoteShare3.FQDN\MyNavy Command\Location\Folder
S: \\remoteshare1.FQDN\MyNavy Command$
T: \\remoteshare1\MyNavy Command\Location
U: \\remoteshare1\SubDir\MyNavy Command_Location_N55882_16AA\MyNavyCommand-3
V: \\remoteshare1\MyNavy Command\Location\Here\folder\subfolder\subsubfolder
W: \\remoteshare1\MyNavy Command\Location\MyNavyCommand-05
X: \\22.22.22.22\ShareName.$
Y: \\remoteshare1\SubDir\MyNavyCommand_Location_yetanotherlocation
Z: \\remoteshare1\SubDir\MyNavyCommand_Location_evenmorelocation


It also worked to list the local drives with DriveType="3"
 
Last edited:
I used the following command and it worked just fine.

C:\>wmic path Win32_LogicalDisk Where DriveType="4" get DeviceID, ProviderName >>c:\outputfiles\testwmic.txt

DeviceID ProviderName
A: \\remoteshare1\SubDir\MyNavy Command_Location_1
B: \\remoteshare1\SubDir\MyNavy Command_Location_2
G: \\remoteshare1\SubDir\MyNavy Command_Location_UIC1
H: \\remoteshare2.FQDN\Me$
I: \\remoteshare1\SubDir\MyNavy Command_Location_UIC2
J: \\remoteshare1\SubDir\MyNavy Command_Location_UIC3
K: \\remoteshare1\SubDir\NPC_Location_3\Directory
L: \\remoteshare1\SubDir\MyNavy Command_Location_4
M: \\remoteshare1\SubDir\NPC_Location_5
O: \\remoteshare1\SubDir\NPC_Location_6
Q: \\remoteshare1\SubDir\MyNavy Command_7
R: \\RemoteShare3.FQDN\MyNavy Command\Location\Folder
S: \\remoteshare1.FQDN\MyNavy Command$
T: \\remoteshare1\MyNavy Command\Location
U: \\remoteshare1\SubDir\MyNavy Command_Location_N55882_16AA\MyNavyCommand-3
V: \\remoteshare1\MyNavy Command\Location\Here\folder\subfolder\subsubfolder
W: \\remoteshare1\MyNavy Command\Location\MyNavyCommand-05
X: \\22.22.22.22\ShareName.$
Y: \\remoteshare1\SubDir\MyNavyCommand_Location_yetanotherlocation
Z: \\remoteshare1\SubDir\MyNavyCommand_Location_evenmorelocation


It also worked to list the local drives with DriveType="3"

i tried this on a users windows xp machine at work as i was replacing it with a win 7 machine and it asked for a admin to run and i found the command to do it so i need to work on adding those commands into the batch file
 
Back