Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Script Replication

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Script Replication
  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 >>
 Script Replication - 8/30/2006 11:31:22 AM   
  takeda kozo

 

Posts: 83
Score: 0
Joined: 11/9/2005
Status: offline
Hi All,

I am writing a script which will connect to a list of hostnames and then retrieve certain items from the registry etc (hotfix info, pc serial number etc)

The host list is rather large, so I want to split the task among 4 identical scripts, so that they can simultaneously gather this info.

If I use the master script (the engine) to make 3 copies of the scanning script, then how can I edit the script content inside these copies before launching them ? (the scanning scripts are identical except for a single line):

ScriptNo = "1"

(so at the end, every script should look the same, except they will each have a unique line which states their script number

Copying should be ok, but I dont know how to edit the content of a script !!!! Any help would be appreciated :)


Const OverwriteExisting = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
For i = 1 to 4
       objFSO.CopyFile "C:\temp\scanner.vbs" , "C:\temp\working\scanner_" & i & ".vbs", OverwriteExisting
Next


One other thing, is there a way to store the contents (the code) for the scanner script WITHIN the master script ? so that the whole package can be maintained in a single script file ? (for example, copy lines 100 to line 300 into a new script called scanner_1, scanner_2 etc ?


Cheers,
TK


 
 
Post #: 1
 
 RE: Script Replication - 8/30/2006 11:18:08 PM   
  mbouchard


Posts: 1924
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Here is an example for opening a text file and replacing a word from the text.


      

As too having a script in the master script you can do 2 ways.
1) Leave the code the same in all scripts, but have some coding that will determine if a part of the script needs to run or not.  For ex.


      
The above code will only run the copy portion of the script if the name of the script is the original script.

2) Have code in the script used to write the additional scripts.  Here is a snippet from a larger script that I use when setting up PC's at work.  The whole sub that this section is from is about 300 lines.
you can even use if/then and select case in the script if you want different scripts to only perform some functions.

      

Lastly, I would add code to the bottom of the extra scripts so that they will delete themselves once the script has completed running.

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to takeda kozo)
 
 
Post #: 2
 
 RE: Script Replication - 8/31/2006 1:33:19 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: online
Rather than altering the script copies, I would have the script copies accept one command line parameter that is their script number. Then the master script can simply call the same file 4 times and pass a different script number to each one.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to mbouchard)
 
 
Post #: 3
 
 RE: Script Replication - 8/31/2006 5:03:54 AM   
  mbouchard


Posts: 1924
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Alternativly to ebgreens suggestion, you can let the name of the file determine the script number.

ScriptNumber = right(fso.GetBasename(wscript.scriptname),1)

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to ebgreen)
 
 
Post #: 4
 
 
 
  

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 >> Script Replication 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