Windows Script File (WSF) to Visual Basic Script (VBS)
npm install wsf2vbsAssuming a simple wsf with below content:
``xml
`
The generated VBS would be:
the responding output jscript file is like :
`vbs
' ======== START ========
' vbs file generated from wsf file using wsf2vbs npm package
' ================================== Job: job1 ==================================
' ================= inline script =================
Dim script
'Read and assess the parameter supplied
If WScript.Arguments.named.exists("script") Then
WScript.Echo "Argument received: " & WScript.Arguments.named("script")
script = WScript.Arguments.named("script")
Else
Wscript.Echo "/script: Enter the Script to exeucte"
Wscript.Echo "/msg: Enter the Msg"
WScript.Quit
End If
' ================= src : scripts\FS.vbs =================
Class FS
Private objFSO
Private Sub Class_Initialize
Set objFSO = CreateObject("Scripting.FileSystemObject")
End Sub
Public Function GetFSO
Set GetFSO = objFSO
End Function
Public Function GetFileDir(ByVal file)
Wscript.Echo "GetFileDir(" + file + ")"
Set objFile = objFSO.GetFile(file)
GetFileDir = objFSO.GetParentFolderName(objFile)
End Function
End Class
' set oFs = new FS
' Wscript.Echo oFs.GetFileDir(WScript.ScriptFullName)
' ================================== Job: job2 ==================================
' ================= inline script =================
Wscript.Echo "We are in Job2"
' ======== END ========
`
`js`
const fs = require('fs');
const wsf2vbs = require('wsf2vbs');
wsf2vbs.extract(wsfPath, debug).then((vbs)=>{
fs.writeFileSync(path.join(__dirname, 'test_out_extract.vbs'), vbs);
}).catch((error)=>{
console.error(error)
})
`js``
const fs = require('fs');
const wsf2vbs = require('wsf2vbs');
// For Demo: Genearate string of wsf file
let xml = await fs.readFileSync(wsfPath).toString();
wsf2vbs.extractFromStr(xml, debug).then((vbs)=>{
fs.writeFileSync(path.join(__dirname, 'test_out_extract.vbs'), vbs);
}).catch((error)=>{
console.error(error)
})