Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Want to find a folder through DOS


  • Please log in to reply
6 replies to this topic

#1
gendouhydeist

gendouhydeist

    Member

  • Member
  • PipPip
  • 106 posts
ok what i need to do is to find a certain folder in all drives so that I could set it as variable... like
set INSTALL=D:\Installer
but I don't know how to find it or set it, if that Folder does not exist on that drive..., just for curiosity also to install apps easily...


How to remove advertisement from MSFN

#2
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,527 posts
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

@ECHO OFF & SETLOCAL ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION

FOR /F "TOKENS=1" %%# IN ('MOUNTVOL^|FINDSTR [C-Z]:\\') DO (

	IF EXIST %%#INSTALLER SET "INSTALL=%%#Installer")

IF NOT DEFINED INSTALL GOTO :EOF

:: REST OF CODE BELOW HERE

::EXAMPLE COMMAND USING %INSTALL% VARIABLE

ECHO=[%INSTALL%]


#3
gendouhydeist

gendouhydeist

    Member

  • Member
  • PipPip
  • 106 posts
wow awesome way of using commands...
btw does :EOF works without using exit command for it??

what "TOKENS=1" stands for??
Thanks for your batch :D

#4
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,527 posts
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

does :EOF works without using exit command for it??

Yes!

what "TOKENS=1" stands for??

TBH, it's not needed, I just failed to remove it from the code I copy/pasted it off!
@ECHO OFF & SETLOCAL ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION
FOR /F %%# IN ('MOUNTVOL^|FINDSTR [C-Z]:\\') DO (
	IF EXIST %%#INSTALLER SET "INSTALL=%%#Installer")
IF NOT DEFINED INSTALL GOTO :EOF
:: REST OF CODE BELOW HERE
::EXAMPLE COMMAND USING %INSTALL% VARIABLE
ECHO=[%INSTALL%]


#5
jaclaz

jaclaz

    The Finder

  • Developer
  • 13,987 posts
  • OS:none specified
  • Country: Country Flag
For the record, this is Windows 7 "Batch language" or "Command interpreter" or "Command line" or "Command console", NOT DOS.

jaclaz

#6
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,418 posts
  • OS:none specified
  • Country: Country Flag
Here is how you would do it using VBS scripting.

Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
Dim Drv, Loc
'-> Search All Drives For Installer Folder
    For Each Drv In Fso.Drives
     If Fso.FolderExists(Drv & "\Installer") Then Loc = Drv & "\Installer"
    Next
'-> Check The Resuts Of Searching The Drives
    If Len(Loc) > 2 Then 
     MsgBox Loc,4128,"Confirm Folder"
    Else
     MsgBox "Can Not Find The Installer Folder",4128,"Missing Folder"
    End If 




GunSmokingMan



#7
gendouhydeist

gendouhydeist

    Member

  • Member
  • PipPip
  • 106 posts
@jaclaz
well I got used to call it DOS :D, since it was originally called DOS program but thanks for correcting...

well thanks guys!!! hope that I can study programming also xD




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN