Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 28th, 2007, 01:38 AM
b00gieman's Avatar
b00gieman b00gieman is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Location: Europe
Posts: 232 b00gieman User rank is First Lieutenant (10000 - 20000 Reputation Level)b00gieman User rank is First Lieutenant (10000 - 20000 Reputation Level)b00gieman User rank is First Lieutenant (10000 - 20000 Reputation Level)b00gieman User rank is First Lieutenant (10000 - 20000 Reputation Level)b00gieman User rank is First Lieutenant (10000 - 20000 Reputation Level)b00gieman User rank is First Lieutenant (10000 - 20000 Reputation Level)b00gieman User rank is First Lieutenant (10000 - 20000 Reputation Level)b00gieman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 11 h 41 m 27 sec
Reputation Power: 109
.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!

Reply With Quote
  #2  
Old September 28th, 2007, 01:49 AM
Guddu's Avatar
Guddu Guddu is offline
Contributing User
Click here for more information.
 
Join Date: Jul 2005
Location: Oxford UK
Posts: 3,651 Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 2 Days 12 h 54 m 3 sec
Reputation Power: 787
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 !!!!!!!!

Reply With Quote
  #3  
Old September 28th, 2007, 08:59 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 46th Plane (27500 - 27999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,635 Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)  Folding Points: 373781 Folding Title: Super Ultimate Folder - Level 1Folding Points: 373781 Folding Title: Super Ultimate Folder - Level 1Folding Points: 373781 Folding Title: Super Ultimate Folder - Level 1Folding Points: 373781 Folding Title: Super Ultimate Folder - Level 1Folding Points: 373781 Folding Title: Super Ultimate Folder - Level 1Folding Points: 373781 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 h 55 m 37 sec
Reputation Power: 1902
--moved to the Windows Scripting forum.
VB forum is for full scale VB application code only.

Reply With Quote
  #4  
Old September 28th, 2007, 12:51 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
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.

Reply With Quote
  #5  
Old September 28th, 2007, 09:04 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
Quote:
fs.MoveFile Server.MapPath("upload/tmb2.xls"), "\\tmav035a\Test\AssetDB_test\tmb456.xls"
deja vu again, Response and Server objects are provided by asp, not the vbscript engine.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #6  
Old September 29th, 2007, 02:28 AM
b00gieman's Avatar
b00gieman b00gieman is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Location: Europe
Posts: 232 b00gieman User rank is First Lieutenant (10000 - 20000 Reputation Level)b00gieman User rank is First Lieutenant (10000 - 20000 Reputation Level)b00gieman User rank is First Lieutenant (10000 - 20000 Reputation Level)b00gieman User rank is First Lieutenant (10000 - 20000 Reputation Level)b00gieman User rank is First Lieutenant (10000 - 20000 Reputation Level)b00gieman User rank is First Lieutenant (10000 - 20000 Reputation Level)b00gieman User rank is First Lieutenant (10000 - 20000 Reputation Level)b00gieman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 11 h 41 m 27 sec
Reputation Power: 109
I removed that part from the script and created 2 separate scripts.Thanks,guys!

Reply With Quote
  #7  
Old October 1st, 2007, 08:12 AM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,048 Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Days 12 h 32 m 33 sec
Reputation Power: 555
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo
MySpace
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!


Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > .vbs file help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT