このコードをVB.Netアプリケーションで使用しています
Protected Sub btnBHNas_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnBHNasBackup.Click
'System.Diagnostics.Process.Start("batch\backupbhnas.bat")
Using writer As StreamWriter = New StreamWriter("C:\backupbhnas.bat", True)
writer.WriteLine("@echo off")
writer.WriteLine(" echo ""Specify username""")
writer.WriteLine("set /p Name=")
writer.WriteLine("net use k: ""\\backups\back-ups""")
writer.WriteLine("mkdir k:\%name%")
writer.WriteLine("set drive=K:\%name%")
writer.WriteLine("set backupcmd=xcopy /s /c /d /e /h /i /r /y")
writer.WriteLine("echo ### Backing up My Documents...")
writer.WriteLine("%backupcmd% ""C:\Documents and Settings\%name%\My Documents"" ""%drive%\My Documents""")
writer.WriteLine("echo ### Backing up Favorites...")
writer.WriteLine("%backupcmd% ""C:\Documents and Settings\%name%\Favorites"" ""%drive%\Favorites""")
writer.WriteLine("echo ### Backing up Desktop...")
writer.WriteLine("%backupcmd% ""C:\Documents and Settings\%name%\desktop"" ""%drive%\desktop""")
writer.WriteLine("net use k: /delete")
writer.WriteLine("echo Backup Complete!")
writer.WriteLine("pause")
End Using
Dim myFile As String
Dim myDir As String = "C:\"
For Each myFile In Directory.GetFiles(myDir, "backupbhnas.bat")
File.Delete(myFile)
Next
End Sub
そしてそれは動作します。ただし、ASP.Netのボタンで使用すると、何も実行されません。私は何かが足りないのですか?