Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rename a file or delete a file

Status
Not open for further replies.
Nov 18, 2005
43
US
Hi new to VB I am trying something simple. To rename a exe if it exists. Eventually I would want to try and delete it. How my if else is not working.
I am getting a Line 2 end of statement expected error at char 57. Can anyone help me out.
Thanks.
Code:
If fso.FolderExists ("C:\Program Files\Winamp\")Then
Set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.MoveFile "C:\Program Files\Winamp\winamp.exe" , "C:\Program Files\Winamp\Winamp_is_prohibited.txt";
		Else
'Do nothing



End If
 
You are trying to put multiple commands on one line:

Code:
If fso.FolderExists ("C:\Program Files\Winamp\")Then
Set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.MoveFile "C:\Program Files\Winamp\winamp.exe" , "C:\Program Files\Winamp\Winamp_is_prohibited.txt";
        Else
'Do nothing



End If

should be

Code:
If fso.FolderExists ("C:\Program Files\Winamp\")Then
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	objFSO.MoveFile "C:\Program Files\Winamp\winamp.exe" , "C:\Program Files\Winamp\Winamp_is_prohibited.txt"
Else	
	'Do nothing
End If


Additionally since this isn't c or pascal etc you don't end lines with ;

Hope this helps.

[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top