Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Check if file exists then launch

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Check if file exists then launch
  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 >>
 Check if file exists then launch - 12/17/2006 4:20:38 PM   
  goofs

 

Posts: 4
Score: 0
Joined: 12/17/2006
Status: offline
I'm new to scripting and I need to write a script that will do the following.
1. Check to see if a mdb file exists in a users profile.
2. If it doesn't exist. Copy the mdb file to the users profile. Then launch database program.
3. If it does exist. Then launch database program.

I think found out how to copy a file.

Dim objFso
Set objFso = WScript.CreateObject("Scripting.FileSystemObject")
objFso.CopyFile "\\network\program\place.mdb", "C:\documents and settings\%profile%", "False"

Most of the If Then Else examples that I have seen have to do with numbers.

Thanks in Advance
 
 
Post #: 1
 
 RE: Check if file exists then launch - 12/17/2006 5:19:54 PM   
  dm_4ever


Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
You're on the right track. You can use the same FileSystemObject to check for the existence of the file. 
FileSystemObject:  http://msdn.microsoft.com/library/en-us/script56/html/af4423b2-4ee8-41d6-a704-49926cd4d2e8.asp
FileExists Method:  http://msdn.microsoft.com/library/en-us/script56/html/0f2bdb53-5821-45d7-9044-ef1abc4ddc89.asp

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to goofs)
 
 
Post #: 2
 
 RE: Check if file exists then launch - 12/17/2006 11:29:14 PM   
  mbouchard


Posts: 1922
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Make sure you download the WSH help docs.  These are a very good reference and can help you with your code.


Along with what dm_4ever posted, take a look at the WSHnetwork object, you can use this to get the username.

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to dm_4ever)
 
 
Post #: 3
 
 
 
  

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 >> Check if file exists then launch 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