4
为什么批处理文件在记事本中创建时运行,但不是在我的VB代码中创建它时?试图从VB 2010 Express创建批处理文件
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,但没有去。
当试图从启动直接启动EXE,它从该目录运行它,并找不到相关的文件(在应用程序目录中),所以CD是必要的有一个固有的问题。
使用VB 2010 Express。在此先感谢您的帮助!
甜!奇迹般有效。谢谢卢克!我应该在4个小时前问过。 ; ) 再次感谢。 – Dave 2011-03-26 22:30:33