so what ur saying is a .bat file is being used to launch the script?
if so, your gonna have to accossiate .vbs with powershell so that the script is ran on powershell, not cmd.
I'm having problems using vbs to connect two computers together. I would like to have one script connect to a remote box to execute a second script and have that second script run on that machine. The outcome I would like is to have one script connect to a series of boxes (one at a time), execute a script on that box while moving on to the next computer to kick off another script.
The problem lies in that the scripts work fine when executed independantly both through a command prompt and when double clicking the first file on my local box, but not when executing them through a .bat file. When executing through the .bat file, it appears that the File 1 objRemoteScript.Execute from the first file isn't being executed even though all the other wscript.echo's are working and no error codes are produced.
Any suggestions? The source codes are below. For your information, I have administrative permissions on each box.
Thanks for your help.
File 1:
'-----------------------
Option Explicit
Dim objFSO, objFolder, objShell, objTextFile, objFile, objWshController, objRemoteScript
Dim strDirectory, strFile, strText, strWorkerScript, strRemoteComputer
strDirectory = "c:\"
strFile = "\asdf.txt"
strText = "Project run at " & Time() & " on " & DATE()
'------------------------
'On Error Resume Next
wscript.echo TIME()
strRemoteComputer = "\\Same Computer"
strWorkerScript = "\file2.vbs"
Set objWshController = WScript.CreateObject("WshController")
Set objRemoteScript = objWshController.CreateScript(strWorkerScript, strRemoteComputer)
wscript.echo "Status is " & objRemoteScript.status
wscript.echo "Next is Execute"
Err.Clear
objRemoteScript.Execute
If Err.Number <> 0 Then
WScript.Echo "Error: " & Err.Number
WScript.Echo "Error (Hex): " & Hex(Err.Number)
WScript.Echo "Source: " & Err.Source
WScript.Echo "Description: " & Err.Description
Err.Clear
End If
Do While objRemoteScript.Status <> 1
WScript.Sleep 1000
Loop
wscript.echo "Should have executed"
'----------------------------------------
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
End If
If objFSO.FileExists(strDirectory & strFile) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
End If
set objFile = nothing
set objFolder = nothing
Const ForAppending = 8
Set objTextFile = objFSO.OpenTextFile (strDirectory & strFile, ForAppending, True)
objTextFile.WriteLine(strText)
objTextFile.Close
'End of File 1
-----------------------------------------------------------
File 2:
Option Explicit
Dim objFSO, objFolder, objShell, objTextFile, objFile
Dim strDirectory, strFile, strText
strDirectory = "c:\"
strFile = "\textFileRun.txt"
strText = "Project run at " & Time() & " on " & DATE()
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
' WScript.Echo "Just created " & strDirectory
End If
If objFSO.FileExists(strDirectory & strFile) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
' Wscript.Echo "Just created " & strDirectory & strFile
End If
set objFile = nothing
set objFolder = nothing
Const ForAppending = 8
Set objTextFile = objFSO.OpenTextFile (strDirectory & strFile, ForAppending, True)
objTextFile.WriteLine(strText)
objTextFile.Close
'WScript.Quit

Chowhound
Comic Vine
GameFAQs
GameSpot
Giant Bomb
TechRepublic