vb.net – 尝试从VB 2010 Express创建批处理文件
发布时间:2020-12-17 07:14:40 所属栏目:百科 来源:网络整理
导读:为什么批处理文件在我在记事本中创建时会运行,但是当我在VB代码中创建它时却没有? Dim strStartFile As String = "C:Documents and SettingsAll UsersStartMenuProgramsStartupStarter.bat" If Not File.Exists(strStartFile) Then Dim strBatLine1 A
为什么批处理文件在我在记事本中创建时会运行,但是当我在VB代码中创建它时却没有?
Dim strStartFile As String = "C:Documents and SettingsAll UsersStartMenuProgramsStartupStarter.bat" If Not File.Exists(strStartFile) Then Dim strBatLine1 As String = "cd C:Progra~1Applic~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执行该文件
My.Computer.FileSystem.WriteAllText(strStartFile,False,System.Text.Encoding.Default); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |