需要代码通过VBScript更新应用程序的日期 [英] Need code to update date on application via VBScript

查看:53
本文介绍了需要代码通过VBScript更新应用程序的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我要在申请时更新'日期'。但是这件事必须通过DOS提示不在Visual Studio中完成。那么我需要创建哪些文件?应该是什么代码?



请帮忙!





干杯,

Rishu Mehra

Hi Everyone,

I've to update 'date' on application. But this thing has to be done by DOS prompt not in Visual Studio. So what files I need to create? what should be the code?

Please help!


Cheers,
Rishu Mehra

推荐答案

TechNet [ ^ ]

更多信息。



这个链接 [< a href =http://www.visualbasicscript.com/VBA-script-to-change-some-lines-in-text-file-m88293.aspxtarget =_ blanktitle =New Window> ^ ]提供了一个脚本,用于使用VBScript更新文件中的文本。该网站上有一个恼人的弹出窗口,所以我将在这里重现帖子...注意我没有亲自测试过。



See this article on TechNet[^]
Further information available.

This link[^] provides a script for updating text within a file using VBScript. There is an annoying pop-up on that site so I will reproduce the post here...Note I have not tested this personally.

waitely写道:
waitely wrote:

如果你想通过VBScript编辑文件中的特定行,你可以使用类似下面的内容。这将逐行读取原始文件并将其写入临时文件。如果原始行符合您所需的条件,请进行所需的更改。最后,关闭两个文件,删除原始文件并移动临时文件。

If you want to edit a specific line in a file through VBScript you can use something like below. This reads the original file line by line and writes it out to a temporary file. If the original line meets the condition you want, make the changes required. At the end, close both files, delete the original and move the temp file.




Const ForReading=1  
Const ForWriting=2  
Set objFSO = CreateObject("Scripting.FileSystemObject")  
folder = "C:\Program Files\Vendor\"  'change this to your folder
filePath = folder & "file.txt"  'change this to your filename
Set myFile = objFSO.OpenTextFile(filePath, ForReading, True)  
Set myTemp= objFSO.OpenTextFile(filePath & ".tmp", ForWriting, True)  
Do While Not myFile.AtEndofStream   
    myLine = myFile.ReadLine   
    If InStr(myLine, "Variable=") Then      'Change this to how you know where the date is
        myLine = "Variable="&whatever   'Change this to your [date]
    End If     
    myTemp.WriteLine myLine  
Loop  
myFile.Close  
myTemp.Close  
objFSO.DeleteFile(filePath)  
objFSO.MoveFile filePath&".tmp", filePath


这篇关于需要代码通过VBScript更新应用程序的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆