如何使用VB 2010 Express编写批处理文件代码?

2026-05-06 12:061阅读0评论SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计256个文字,预计阅读时间需要2分钟。

如何使用VB 2010 Express编写批处理文件代码?

为什么批处理文件在我创建记事本时运行,但在VB代码中创建它时却没有?

Dim strStartFile As String=C:\Documents and Settings\All Users\Start Menu\Programs\Startup\Starter.batIf Not File.Exists(strStartFile) Then

为什么批处理文件在我在记事本中创建时会运行,但是当我在VB代码中创建它时却没有?

Dim strStartFile As String = "C:\Documents and Settings\All Users\StartMenu\Programs\Startup\Starter.bat" If Not File.Exists(strStartFile) Then Dim strBatLine1 As String = "cd C:\Progra~1\Applic~1 && start Application.exe" My.Computer.FileSystem.WriteAllText(strStartFile, strBatLine1, False) SetAttr(strStartFile, FileAttribute.Normal) End If

它创建文件就好了.它看起来与手工版本完全相同,双击时它不会启动exe.我试过附加CR LF,vbCrLf,但没有去.

尝试直接从Startup启动exe时存在一个固有的问题,它从该目录运行它并且无法找到相关文件(在Application目录中)所以cd是必要的.

使用VB 2010 Express.在此先感谢您的帮助!

您可能需要传入Systems ANSI CodePage,因为您正在从cmd.exe执行该文件

如何使用VB 2010 Express编写批处理文件代码?

My.Computer.FileSystem.WriteAllText(strStartFile,strBatLine1,False,System.Text.Encoding.Default);

本文共计256个文字,预计阅读时间需要2分钟。

如何使用VB 2010 Express编写批处理文件代码?

为什么批处理文件在我创建记事本时运行,但在VB代码中创建它时却没有?

Dim strStartFile As String=C:\Documents and Settings\All Users\Start Menu\Programs\Startup\Starter.batIf Not File.Exists(strStartFile) Then

为什么批处理文件在我在记事本中创建时会运行,但是当我在VB代码中创建它时却没有?

Dim strStartFile As String = "C:\Documents and Settings\All Users\StartMenu\Programs\Startup\Starter.bat" If Not File.Exists(strStartFile) Then Dim strBatLine1 As String = "cd C:\Progra~1\Applic~1 && start Application.exe" My.Computer.FileSystem.WriteAllText(strStartFile, strBatLine1, False) SetAttr(strStartFile, FileAttribute.Normal) End If

它创建文件就好了.它看起来与手工版本完全相同,双击时它不会启动exe.我试过附加CR LF,vbCrLf,但没有去.

尝试直接从Startup启动exe时存在一个固有的问题,它从该目录运行它并且无法找到相关文件(在Application目录中)所以cd是必要的.

使用VB 2010 Express.在此先感谢您的帮助!

您可能需要传入Systems ANSI CodePage,因为您正在从cmd.exe执行该文件

如何使用VB 2010 Express编写批处理文件代码?

My.Computer.FileSystem.WriteAllText(strStartFile,strBatLine1,False,System.Text.Encoding.Default);