Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


If statement....

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,61875
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> If statement....
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 If statement.... - 6/25/2008 11:01:11 PM   
  jcarver_14

 

Posts: 31
Score: 0
Joined: 6/4/2008
From: Cincinnati
Status: offline
Hey im back and stuck in a sticky spot.  I have this script I have been working on and currently it is supposed to do the following:

Input box to put computer name in

Then check to see if "\\%computername%\c$\documents and settings\%user account name% or folderobject.name\local settings\temp" exist

Everything looks like it is working right untill you get down to the if statment.  it should be doing.  If it exist then echo the path if it does not then echo that it does not but what i keep running into is the ones that do exist echo back but when it reaches one that does not it just errors out.  I tested it with on error resume next and it will work great,

Any ideas


Thanks...



      
 
 
Post #: 1
 
 RE: If statement.... - 6/26/2008 12:11:46 AM   
  ehvbs

 

Posts: 2201
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi jcarver_14,


I think you must reorder your statements:

...
rootfolder = ("\\" & servicetag & "\C$\Documents and Settings\" & folderobject.name & "\Local Settings\temp\")
If FSO.FolderExists(rootfolder) Then
    Set objFolder = FSO.GetFolder(rootfolder)
    Set colFiles = objFolder.Files
    WScript.Echo objFolder.Path         
  Else
   MsgBox rootfolder & " Folder Does not Exist"
  End if     

(not tested)

Good luck!

ehvbs

(in reply to jcarver_14)
 
 
Post #: 2
 
 RE: If statement.... - 6/26/2008 2:06:38 AM   
  jcarver_14

 

Posts: 31
Score: 0
Joined: 6/4/2008
From: Cincinnati
Status: offline
Hey that worked great and i thank you for your help but I have anohter one now.  What I gave you was basicly the beggining of the code and im adding onto it.  Heres what I have so far:


      

So now what I got it doing is the same as above but now its is writing to a log file. I have commented out the part where it echos objectfolder.path... i dont need that any more so now I have it set to echo the files in objectfolder.path (...\temp) then to call a sub that echos the subfolders and there files and loops back into itself basically forcing it to list all files and folders sub of temp.  But when I run it i get duplicate paths.  Here is the output file i get.

\\c0jmyd1\c$\Documents and Settings\Administrator\Local Settings\Temp\libFNP_events.log
\\c0jmyd1\c$\Documents and Settings\Administrator\Local Settings\Temp\Acrobat Distiller 8
\\c0jmyd1\c$\Documents and Settings\Administrator\Local Settings\Temp\Acrobat Distiller 8\test.txt
\\c0jmyd1\c$\Documents and Settings\Administrator\Local Settings\Temp\avgdiag
\\c0jmyd1\c$\Documents and Settings\Administrator\Local Settings\Temp\tosBtExt
\\c0jmyd1\c$\Documents and Settings\Administrator\Local Settings\Temp\~DF29B7.tmp
\\c0jmyd1\c$\Documents and Settings\Administrator\Local Settings\Temp\Acrobat Distiller 8
\\c0jmyd1\c$\Documents and Settings\Administrator\Local Settings\Temp\Acrobat Distiller 8\test.txt
\\c0jmyd1\c$\Documents and Settings\Administrator\Local Settings\Temp\avgdiag
\\c0jmyd1\c$\Documents and Settings\Administrator\Local Settings\Temp\tosBtExt
\\c0jmyd1\c$\Documents and Settings\Administrator\Local Settings\Temp\~DFDFA0.tmp
\\c0jmyd1\c$\Documents and Settings\Administrator\Local Settings\Temp\Acrobat Distiller 8
\\c0jmyd1\c$\Documents and Settings\Administrator\Local Settings\Temp\Acrobat Distiller 8\test.txt
\\c0jmyd1\c$\Documents and Settings\Administrator\Local Settings\Temp\avgdiag
\\c0jmyd1\c$\Documents and Settings\Administrator\Local Settings\Temp\tosBtExt

dont mind my computer name but notice it didnt read A - Z it read that libFNP_events.log file then started A - Z and repeats a lot of them.

Any ideas on this one?

(in reply to ehvbs)
 
 
Post #: 3
 
 RE: If statement.... - 6/26/2008 4:38:32 AM   
  jcarver_14

 

Posts: 31
Score: 0
Joined: 6/4/2008
From: Cincinnati
Status: offline
Just an update.  Here is the rest of the code but same problem with the if statements.  It duplicates the results several times



      

(in reply to jcarver_14)
 
 
Post #: 4
 
 RE: If statement.... - 6/26/2008 5:31:33 AM   
  ehvbs

 

Posts: 2201
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi jcarver_14,

still only thinking: your loop over the files in a folder

  ...
  For Each objFile In colFiles
      objOutFile.WriteLine objFile.Path
       ShowSubFolders(objFolder)
  Next
  ....

calls the sub for handling the subfolders for each file. Probably:

  ...
   For Each objFile In colFiles
        objOutFile.WriteLine objFile.Path
  Next
  ShowSubFolders objFolder  ' bad () deleted
   ....

Good luck!

ehvbs

(in reply to jcarver_14)
 
 
Post #: 5
 
 RE: If statement.... - 6/27/2008 1:42:09 AM   
  jcarver_14

 

Posts: 31
Score: 0
Joined: 6/4/2008
From: Cincinnati
Status: offline
That worked great as well and I thank you, you have been very helpful to me with this script and now it looks like it is up and running the way it is supposed to be with the exception of one little bug.  I dont know if I have explained to you what it is yet but its is going to be a PC cleaning script that will clean C:\windows\temp,  C:\documents and settings\%username%\local settings\temp and C:\documents and settings\%username%\local settings\tempary internet files.  but instead of just doing it on your machine you can do it on a remote machine.

I know this makes me look really bad but I want to know iif you have any ideas on the bug I looked everywhere and I can not seem to find anything.  I noticed the script will not write the path to the file if the path is to long thus the file does not get deleted.  Also it will not delete a folder if it contains a file thats name is to long.

Thanks again for any advice you may have

O almost forgot here is what I have so far....


      

(in reply to ehvbs)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> If statement.... Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts