使用输入作为名称的一部分创建文本文件

时间:2014-01-14 10:38:34

标签: c# c++ vb.net vba vbscript

我需要创建一个适用于Windows的应用程序/脚本,具有以下功能:

  • 向用户询问两个输入;

  • 使用其中一个输入(第一个输入)创建一个csv / txt文件作为文件名的一部分,并将其保存到特定文件夹中;

  • 在创建文件后调用应用程序。

我首先关注的是什么是最好的方法?我正在考虑VB或VBS,但我在网上看到了一些c ++演示。我对C#更熟悉,但不想在该位置“安装”任何exe文件,因为该应用程序将在服务器中运行。

1 个答案:

答案 0 :(得分:0)

在VBS中

,使用以下内容:

dim firstInput, secondInput, folderPath, application
dim fso, myFileD
dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )

Set fso = CreateObject("Scripting.FileSystemObject")

folderPath = "C:\dummyFolder"
''extra "" for whitespace in path
application = """c:\Program Files\Mozilla Firefox\firefox.exe"""

firstInput = InputBox("Enter first input")
secondInput = InputBox("Enter second input")

Set myFile = fso.CreateTextFile(folderPath & firstInput & ".txt", True)
myFile.WriteLine(secondInput)
myFile.Close

objShell.Run(application)