|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
.vbs file help
Hi!
I want to have a vbs file to perform several actions.The vbs file should be run as a (scheduled) task and should perform the following actions: -copy a file between 2 servers -import the information from one file into a ms sql table My .vbs file looks like this: Code:
dim fs
dim ADOrs
set fs=Server.CreateObject("Scripting.FileSystemObject")
set AdoRS = New ADODB.Recordset
If fs.FileExists(Server.MapPath("upload\tmb2.xls"))Then
Response.Write"File exists!"
Else
Response.Write"File doesn't exist!"
End If
If fs.FileExists("\\tmav035a\Test\AssetDB_test\tmb22.xls") Then
Response.Write "File exists!"
Else
Response.Write "File doesn't exist!"
End If
Response.Write"<br>"
Response.Write(Server.MapPath("upload\tmb2.xls"))
fs.MoveFile Server.MapPath("upload/tmb2.xls"), "\\tmav035a\Test\AssetDB_test\tmb456.xls"
set fs=nothing
savestr2="//tmav035a/Test/AssetDB_Test/tmb2.xls"
SQLstr = "INSERT INTO dbo.shopping_TSR SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database="+savestr2+";hdr=yes;imex=1', 'SELECT * FROM [Sheet1$]')"
ADOrs.Execute(SQLstr)
set fs=nothing
Do you think this .vbs file will perform the actions needed or should I do 2 .vbs files : one to copy the file between the servers and the other one to import the file into the sql server? Thanks! |
|
#2
|
||||
|
||||
|
this are 2 seprate tasks..
i think create 2 seprate vbs file for this.
__________________
Nothing is Impossible bcoz IMPOSSIBLE itself says.. I M POSSIBLE........................ Be cool !!!!!!!!
|
|
#3
|
||||
|
||||
|
--moved to the Windows Scripting forum.
VB forum is for full scale VB application code only. |
|
#4
|
||||
|
||||
|
If the tasks are dependent upon each other, as in file needs to be copied first before importing it into the database, then have both task in a single .vbs file that includes error handling to end the process if any step in the process fails.
|
|
#5
|
|||
|
|||
|
Quote:
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#6
|
||||
|
||||
|
I removed that part from the script and created 2 separate scripts.Thanks,guys!
|
|
#7
|
||||
|
||||
|
This may generate a bit of argument, but I would tend to lump this all into one file regardless of how many tasks it performs.
I tend to create one file for each solution. So, if the need arises to performs both of these tasks, I'd do it in a single file. Separate tasks should be in separate procedures. But I'd say it's mostly a matter of preference.
__________________
Click the image if at any point you don't like my decision.Scripting problems? Windows questions? Ask the Windows Guru! |
![]() |
| Viewing: ASP Free Forums > System Administration > Windows Scripting > .vbs file help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|