I am desperately trying to run a script on my website by using WScript.Shell.
.................
set fs = CreateObject ("Scripting.FileSystemObject")
sourceScriptPath = "C:\Program Files\Batch Jobs\"
destScriptPath = "C:\Program Files\Temp\"
sourceScript = "testload.wsf"
destScript = = "temp_testload.wsf"
Batch1 = "True"
Batch2 = "False"
Response.write "<br>Creating script file.</br>"
fs.CopyFile sourceScriptPath&sourceScript,destScriptPath&destScript
Set f = fs.OpenTextFile(destScriptPath&destScript, 1, True)
sContents=f.ReadAll
f.close
sContents=Replace(sContents,Batch1,Batch2)
Set f = fs.OpenTextFile(destScriptPath&destScript, 2, True)
f.write sContents
f.close
'response.write "<br>" & destScriptPath&destScript & "</br>"
end if
<script language="vbscript">
Dim shell, strCommand
strCommand = destScriptPath & destScript
Set shell = CreateObject("WScript.Shell")
shell.Run strCommand
</script>
The asp page copies a script into another folder, replace some string inside the script, saves and run it.
I keep getting an error: System cannot find file specified, although the new script file is created.
I tried destScript = "hello.vbs" , with no avail
It might have something to do with the space in the strCommnad string (Program Files),I had google'd this and tried every trick suggested.
.................
set fs = CreateObject ("Scripting.FileSystemObject")
sourceScriptPath = "C:\Program Files\Batch Jobs\"
destScriptPath = "C:\Program Files\Temp\"
sourceScript = "testload.wsf"
destScript = = "temp_testload.wsf"
Batch1 = "True"
Batch2 = "False"
Response.write "<br>Creating script file.</br>"
fs.CopyFile sourceScriptPath&sourceScript,destScriptPath&destScript
Set f = fs.OpenTextFile(destScriptPath&destScript, 1, True)
sContents=f.ReadAll
f.close
sContents=Replace(sContents,Batch1,Batch2)
Set f = fs.OpenTextFile(destScriptPath&destScript, 2, True)
f.write sContents
f.close
'response.write "<br>" & destScriptPath&destScript & "</br>"
end if
<script language="vbscript">
Dim shell, strCommand
strCommand = destScriptPath & destScript
Set shell = CreateObject("WScript.Shell")
shell.Run strCommand
</script>
The asp page copies a script into another folder, replace some string inside the script, saves and run it.
I keep getting an error: System cannot find file specified, although the new script file is created.
I tried destScript = "hello.vbs" , with no avail
It might have something to do with the space in the strCommnad string (Program Files),I had google'd this and tried every trick suggested.