So what I am trying to accomplish is to always start. cscript.exe in native os version. SO I have access to the correct system files when my script runs and won't be redirected to the syswow64 regestry/files.
So according the msdn docs i can use the sysnative when running a 32bit application on a 64bit system to get the real system32 folder. But the script cant seam to find the the cscript.exe file. So the question is what am i doing wrong? I mostly a python guy so I might be making a stupid assumption.
This is compiled into a 32bit Service, so it could be deployed on any windows os(in theory)
Running VisualStudio 2010 if it matters
Or am I approaching the problem completely back to front?
Public Class Service1
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
'Prvents windows from redirecting us to the wow64 folder instead of system32.
' Don' run if settings file is gone
If My.Computer.FileSystem.FileExists("C:\Settings.vbs") Then
'If we are running in wow64(32bit windows files) mode switch to native 64 bit vbscript
If My.Computer.FileSystem.DirectoryExists("%systemroot%\sysÂnative") Then
Process.Start("%systemroot%\sysÂnative\cscript.exe", "C:\Main.vbs")
Else
Process.Start("%systemroot%\system32\cscript.exe", "C:\Main.vbs")
End If
End If
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
End Sub
End Class
Basicly to the question is How do I get cscript to run in 64bit mode rather than 32bit, so only really this line.
Process.Start("%systemroot%\system32\cscript.exe", "C:\Main.vbs")
That gets changed to C:\Windows\SysWOW64 when run a on a 64 bit system.
But stays on 32bit system it stays C:\Windows\system32.
I also tried this:http://msdn.microsoft.com/en-us/library/windows/desktop/aa365744%28v=vs.85%29.aspx
But I cant seam to figure out how to make it work. In a vb application