MSFN Forum: VBS set path variable - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

VBS set path variable Rate Topic: -----

#1 User is offline   MioKawaii 

  • Newbie
  • Group: Members
  • Posts: 28
  • Joined: 02-May 05

Posted 29 November 2006 - 12:09 PM

I'm trying to learn VBS by converting a CMD file but.................

How do you search for a file and SET the location as a variable in VBS?

For instance CMD:
FOR %%I IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%I:\WhateverFolder\WhateverFile.txt SET WhateverLoc=%%I:\WhateverFolder



#2 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,020
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 29 November 2006 - 04:34 PM

View PostMioKawaii, on Nov 29 2006, 07:09 PM, said:

I'm trying to learn VBS by converting a CMD file but.................

How do you search for a file and SET the location as a variable in VBS?

For instance CMD:
FOR %%I IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%I:\WhateverFolder\WhateverFile.txt SET WhateverLoc=%%I:\WhateverFolder

Try this it list the first instance of \Windows\System32 then exits the loop

Quote

Const Removable = 1, Fixed = 2, CD_DVD = 4
 Dim Act   : Set Act = CreateObject("Wscript.Shell")
 Dim Fso   : Set Fso = CreateObject("Scripting.FileSystemObject")
 Dim ChkFolder, Drv, StrD
 Set Drv = Fso.Drives 
  For Each StrD In Drv 
   If StrD.DriveType = Fixed Then 
	If Fso.FolderExists(StrD & "\Windows\System32") Then 
	 Act.Popup "Found The System32 Folder On " & StrD ,5,"Confirm",4128
'/-> Set The Only Found Instance Of Windows\System32 As The New Varible
	 ChkFolder = StrD & "\Windows\System32" 
	 Exit For 
	End If 
   End If 
  Next


This will list all instances of Windows\System32 on the local computer

Quote

Const Removable = 1, Fixed = 2, CD_DVD = 4
 Dim Act   : Set Act = CreateObject("Wscript.Shell")
 Dim Fso   : Set Fso = CreateObject("Scripting.FileSystemObject")
 Dim ChkFolder, Drv, StrD
 Set Drv = Fso.Drives 
  For Each StrD In Drv 
   If StrD.DriveType = Fixed Then 
	If Fso.FolderExists(StrD & "\Windows\System32") Then 
	 Act.Popup "Found The System32 Folder On " & StrD ,5,"Confirm",4128
'/-> Set The Last Found Instance Of Windows\System32 As The New Varible
	 ChkFolder = StrD & "\Windows\System32" 
	End If 
   End If 
  Next


This will list the first instance of Widows\System32\Shell32.dll then exits the loop

Quote

Const Removable = 1, Fixed = 2, CD_DVD = 4
 Dim Act   : Set Act = CreateObject("Wscript.Shell")
 Dim Fso   : Set Fso = CreateObject("Scripting.FileSystemObject")
 Dim ChkFile, Drv, StrD
 Set Drv = Fso.Drives 
  For Each StrD In Drv 
   If StrD.DriveType = Fixed Then 
	If Fso.FileExists(StrD & "\Windows\System32\Shell32.dll") Then 
	 Act.Popup "Found The Shell32.dll Folder On " & StrD ,5,"Confirm",4128
'/-> Set The First Found Instance Of Windows\System32\Shell32.dll As The New Varible
	 ChkFile = StrD & "\Windows\System32" 
	 Exit For 
	End If 
   End If 
  Next


This will list all the instances of Widows\System32\Shell32.dll on the local computer

Quote

Const Removable = 1, Fixed = 2, CD_DVD = 4
 Dim Act   : Set Act = CreateObject("Wscript.Shell")
 Dim Fso   : Set Fso = CreateObject("Scripting.FileSystemObject")
 Dim ChkFile, Drv, StrD
 Set Drv = Fso.Drives 
  For Each StrD In Drv 
   If StrD.DriveType = Fixed Then 
	If Fso.FileExists(StrD & "\Windows\System32\Shell32.dll") Then 
	 Act.Popup "Found The Shell32.dll Folder On " & StrD ,5,"Confirm",4128
'/-> Set The Last Found Instance Of Windows\System32\Shell32.dll As The New Varible
	 ChkFile = StrD & "\Windows\System32"
	End If 
   End If 
  Next


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy