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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with wshshell.run

Status
Not open for further replies.

NightZEN

Programmer
Apr 29, 2003
142
US
I have the following code to facilitate updating a front-end of a database. It runs fine until it tries to open the file (errors out at line 29) "wshshell.run strOldPath" saying the "System cannot find the file specified". Any ideas as to why?

Thanks!

Code:
'Start
Dim strOldPath
Dim strNewPath
Dim FSO

strOldPath=left(wscript.scriptfullname,len(wscript.scriptfullname)-len(wscript.scriptname)) & "adfe.mdb"
strNewPath ="\\syron-ns-01\Public\Software\Database_Front_Ends\Applications\adfe.mdb"

Set FSO = CreateObject("Scripting.FileSystemObject")

do while FSO.FileExists(Left(strOldPath, len(strOldPath)-3) & "ldb")=True
'As long as an ldb file exists, someone is in the database, so just do nothing until it goes away.
loop
Set WshShell = WScript.CreateObject("WScript.Shell")

FSO.CopyFile strNewpath,strOldPath,True

WScript.Sleep 10000 'wait while file is copied

wshshell.run strOldPath

'End
 
why not stick a little line in that says msgbox strOldPath ... you know, just to see if the file is what you think it is.
 
Since you just overwrote the file at strOldPath with the file at strNewpath ... does it work to .run() strNewpath?
 
Yes, both strOldPath and strNewPath are what I think they are. and NO .run strNewPath does not do anything!? what gives? It is copying the file correctly and pausing correctly.
 
Well put a bogus file at strNewPath ... something very easy to tell if it was copied over the strOldPath.

Also do you have a long file name? Like one with spaces in it? if so then try putting it in triple quotes...
.Run """C:\[red]Program Files[/red]\this\that\[red]the other[/red]\blah.bat"""

 
You may try this:
wshshell.run Chr(34) & strOldPath & Chr(34)

And add a call to the Sleep method in your loop....

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Well, I tried explicitly nameing the path in triple quotes (Sheco) and using Chr(34) & strOldPath & Chr(34) (PHV), and they both got rid of the error method, but niether opened up the database. Is there a problem trying to open a .mdb file using this method?
 
what happens if you try to open up a little text file or something?
 
Is your database secured ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
So I tried to open a small txt file and it worked, and no the daabase is not secured, in so far as anyone can open it (it's just a front-end to a SQL-Server DB). The database is a heafty 30MB. Is it too big to use this a vbScript? This is my first try at scripting with vb. Might I be better off using a batch file? Is there a better way to open this through vb.

Thanks
 
I think I have it:

wshshell.run "MSACCESS.EXE " & Chr(34) & strOldPath & Chr(34)

Thanks for all your insight and idea's PHV and Sheco! Now I have to test it on Win2K and WinXP-SP2!

[pipe] cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top