Jump to content

Visual basic errors

Go to solution Solved by Dujith,
If oDrive.DriveType = USBDRIVE And oDrive.DriveLetter "A" Then

Should be

If oDrive.DriveType = USBDRIVE And oDrive.DriveLetter <> "A" Then

Assuming that u want to find the drive letter.

Basically your if statement had no comparison in it 

Heres the error

 

Line: 9

Char: 55

Error: Expected 'Then'

Code 800A0F9

 

Heres the program:

 

Dim oFSO, oDrive,objFolder,oDestination, shell
Const USBDRIVE=1
oDestination ="c:\#"
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set shell=createobject("wscript.shell")
'Get USB drive letter
For Each oDrive In oFSO.Drives

If oDrive.DriveType = USBDRIVE And oDrive.DriveLetter "A" Then
shell.run oDrive.DriveLetter & ":\batch.bat"
set shell=nothing
End If
Next
Sub CopyFiles(oPath, oDst)
Set objFolder = oFSO.GetFolder(oPath)
For Each Files In objFolder.Files
WScript.Echo “Copying File”,Files
newDst=oDst&"\"&Files.Name
oFSO.CopyFile Files,newDst,True
WScript.Echo Err.Description
Next
End Sub

 

Link to comment
https://linustechtips.com/topic/781951-visual-basic-errors/
Share on other sites

Link to post
Share on other sites

1 hour ago, Dujith said:

If oDrive.DriveType = USBDRIVE And oDrive.DriveLetter "A" Then

Should be


If oDrive.DriveType = USBDRIVE And oDrive.DriveLetter <> "A" Then

Assuming that u want to find the drive letter.

Basically your if statement had no comparison in it 

Thank you! this worked, im very new to VBS

Link to comment
https://linustechtips.com/topic/781951-visual-basic-errors/#findComment-9858480
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×