Posted By: Anonymous
Is it possible to create a file and write lines to it in vbscript?
Something similar to echo in bat file (
echo something something >>sometextfile.txt).
On execution of the vbscript depending on the path of the script would create an autorun.inf file to execute a particular program (smartdriverbackupsdb.exe).
Also how can I strip/remove the drive letter from the complete file path?
Set objFSO=CreateObject("Scripting.FileSystemObject") ' How to write file outFile="c:testautorun.inf" Set objFile = objFSO.CreateTextFile(outFile,True) objFile.Write "test string" & vbCrLf objFile.Close 'How to read a file strFile = "c:testfile" Set objFile = objFS.OpenTextFile(strFile) Do Until objFile.AtEndOfStream strLine= objFile.ReadLine Wscript.Echo strLine Loop objFile.Close 'to get file path without drive letter, assuming drive letters are c:, d:, etc strFile="c:testfile" s = Split(strFile,":") WScript.Echo s(1)