PDA

View Full Version : Can't use Wscript.Shell when moved to Win7 x64


makotech222
10-09-2013, 09:50 AM
Hello, I have a problem with this script i have ported.

We recently updated from winxp x32 to win7 x64, and my vbscript command is having problems running cmd commands. If i manually copy and paste the command, it works fine in cmd, but if i run it through vbscript wshell, it fails.

I'm using VB 7.7a, do i need to upgrade? Thats the only thing i can think of that might cause it.

Here's what a snip of the code looks like:
Function ExecuteCommand(command)

Dim oShell
Set oShell = WScript.CreateObject("WSCript.shell")

Builder.LogMessage "Executing command: " & command
Builder.LogMessage "---------------------------------"
Set result = oShell.Exec(command)

Builder.LogMessage "---Console Output:"

With result
Do While .Status = 0
WScript.Sleep 10
Do While Not .StdOut.AtEndOfStream
Builder.LogMessage "| " & .StdOut.ReadLine
Loop
Loop
End With
Builder.LogMessage "---------------------------------"

End Function

kinook
10-09-2013, 10:06 AM
Without more information I can only guess, but it's probably a 32- vs 64-bit difference.
http://www.kinook.com/VisBuildPro/Manual/6432bit.htm

Visual Build v7 is a 32-bit application, so to compare with running outside of Visual Build, you would need to run the 32-bit cmd.exe or wscript.exe/cscript.exe (in C:\Windows\SysWOW64).

If that doesn't help, please send the information requested at http://www.kinook.com/Forum/showthread.php?t=3044.

makotech222
10-09-2013, 10:11 AM
I'm very new with VBscript, and the guy who wrote this has left. I'm not sure exactly whats happening when Wscript.shell is being created. Can i specify the location of Wscript.exe?

I've already tried specifiying the location of cmd.exe to both the x64 and x32 versions, to no avail.


One other thought, i was thinking its possibly related to administrative privileges. Even thought on my machine, UAC is set to none, and i'm on the admin account. Could that still be causing problems on Visual Build?

kinook
10-09-2013, 11:31 AM
WScript.Shell is an object available in script code (provided by Microsoft).
http://msdn.microsoft.com/en-us/library/aew9yb99%28v=vs.84%29.aspx

There's also a wscript.exe and cscript.exe (again, from Microsoft) for invoking scripts from a command-line.
https://support.microsoft.com/kb/232211

WScript.Shell is not even needed in Visual Build to run a program. You can use a Run Program action or a Builder.RunProgramEx call (from script code).
http://www.kinook.com/VisBuildPro/Manual/runprogramaction.htm
http://www.kinook.com/VisBuildPro/Manual/runprogramexmethod.htm

As to the actual problem, I still don't know what it is so can only guess. A privilege issue is one possibility. At any rate, it sounds like a Windows issue, not a Visual Build problem per se.