Running a VBScript from a batch file

5 pts.
Tags:
Batch files
VB script
Visual Basic
Visual Basic Script
Hi, I have a VB script that I want ran from a batch file. How do I go about this? See the VBscript below:
Dim oFS : Set oFS = CreateObject( "Scripting.FileSystemObject" ) Dim sSrcDir : sSrcDir = "//serverNameFBSurvey"    ' Source directory (remote server) Dim sDstDir : sDstDir = "c:SampleDir" & ""     ' Destination directory WScript.Echo "sSrcDir:", sSrcDir WScript.Echo "sDstDir:", sDstDir If Not oFS.FolderExists( sDstDir ) Then oFS.CreateFolder sDstDir   ' Creates the destination directory if it doesnt already exist Else WScript.Echo "Deleting folder ...", sFSpec Set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.DeleteFolder("C:SampleDir") oFS.CreateFolder sDstDir   ' reCreates the destination directory if it doesnt already exist End If Dim oSrcFiles : Set oSrcFiles = oFS.GetFolder( sSrcDir ).Files Dim oFile, sFSpec For Each oFile In oSrcFiles WScript.Echo "Src ", oFile.Path sFSpec = sDstDir & oFile.Name If oFS.FileExists( sFSpec ) Then Set objFSO = CreateObject("Scripting.FileSystemObject") WScript.Echo "File already exists", sFSpec If oFile.DateLastModified > oFS.GetFile( sFSpec ).DateLastModified Then WScript.Echo "Cpy (D)", sFSpec oFile.Copy sFSpec End If Else WScript.Echo "Cpy (N)", sFSpec oFile.Copy sFSpec End If Next Set WshShell = WScript.CreateObject("WScript.Shell") WScript.Echo "Initializing the survey application...." WshShell.Run "C:SampleDirFB_Survey.exe"


I want this script to be attached to all staff's profile on the domain from the domain's controller and called during logon by staff.

Answer Wiki

Thanks. We'll let you know when a new response is added.
cscript //b //nologo script

C:\>cscript /?
Usage: CScript scriptname.extension [option...] [arguments...]

Options:

//B Batch mode: Suppresses script errors and prompts from displaying
//D Enable Active Debugging
//E:engine Use engine for executing script
//H:CScript Changes the default script host to CScript.exe
//H:WScript Changes the default script host to WScript.exe (default)
//I Interactive mode (default, opposite of //B)
//Job:xxxx Execute a WSF job
//Logo Display logo (default)
//Nologo Prevent logo display: No banner will be shown at execution time
//S Save current command line options for this user
//T:nn Time out in seconds: Maximum time a script is permitted to run
//X Execute script in debugger
//U Use Unicode for redirected I/O from the console

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    Do you need help on how to assign it as a logon script ?
    69,175 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following