|
-
Aug 26th, 2023, 03:38 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Cant run VBS script over Application
Hi there,
I'm trying to run external CMD over VBS code inside VB6 application, but I got error message:
Code:
Error: 11
You cannot service a running 64-bit operating system with a 32-bit version of DISM.
Please use the version of DISM that corresponds to your computer's architecture.
The code follows:
Code:
Call RunCmd2("DISM /Online /Cleanup-Image /ScanHealth")
Code:
Public Sub RunCmd2(stCmd As String)
Dim objShell As Object
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "cmd.exe", "/k " & stCmd, "", "runas", 1
Set objShell = Nothing
Exit Sub
End Sub
I'm using VB6 on Microsoft Windows 7 64-bit edition.
Any help / suggestions would be appreciated!
-
Aug 26th, 2023, 03:52 PM
#2
Re: Cant run VBS script over Application
 Originally Posted by beic
Code:
Error: 11
You cannot service a running 64-bit operating system with a 32-bit version of DISM.
Please use the version of DISM that corresponds to your computer's architecture.
I'm using VB6 on Microsoft Windows 7 64-bit edition.
Any help / suggestions would be appreciated! 
Follow the very clear instructions given in the first error message you posted.
-
Aug 26th, 2023, 04:11 PM
#3
Thread Starter
Addicted Member
Re: Cant run VBS script over Application
 Originally Posted by OptionBase1
Follow the very clear instructions given in the first error message you posted.
I tried with:
Code:
Call RunCmd2("C:\Windows\system32\DISM.exe /Online /Cleanup-Image /ScanHealth")
Code:
Public Sub RunCmd2(stCmd As String)
Dim objShell As Object
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "C:\Windows\system32\cmd.exe", "/k " & stCmd, "", "runas", 1
Set objShell = Nothing
Exit Sub
End Sub
But I got the same result.
-
Aug 26th, 2023, 04:15 PM
#4
Re: Cant run VBS script over Application
Sorry, I didn't catch that this was a Windows utility, I thought it was just some random 32-bit exe that you were trying to run.
Last edited by OptionBase1; Aug 26th, 2023 at 04:26 PM.
-
Aug 26th, 2023, 04:20 PM
#5
Re: Cant run VBS script over Application
Yeah, this isn't a VB6 programming issue. You can't get around it by doing anything different in VB6.
I'm not sure why an application would ever be trying to perform these kinds of administrative actions. You'd normally only run Deployment Image Servicing and Management from a Command Prompt or "PowerShell" script.
Not only does this command line tool come in separate 32- and 64-bit versions, there are different versions that work in different Windows versions.
https://learn.microsoft.com/en-us/wi...iew=windows-11
-
Aug 26th, 2023, 04:22 PM
#6
Thread Starter
Addicted Member
Re: Cant run VBS script over Application
 Originally Posted by OptionBase1
Of course you did. Did you read the error message?
I'm running 64-bit Windows, so, "C:\Windows\system32\DISM.exe" should correspond to the 64-bit architecture path, or did I miss something?
-
Aug 26th, 2023, 04:24 PM
#7
Re: Cant run VBS script over Application
 Originally Posted by beic
I'm running 64-bit Windows, so, "C:\Windows\system32\DISM.exe" should correspond to the 64-bit architecture path, or did I miss something?
You could try C:\Windows\SysNative\DISM.exe
-
Aug 26th, 2023, 04:28 PM
#8
Thread Starter
Addicted Member
Re: Cant run VBS script over Application
 Originally Posted by dilettante
Yeah, this isn't a VB6 programming issue. You can't get around it by doing anything different in VB6.
I'm not sure why an application would ever be trying to perform these kinds of administrative actions. You'd normally only run Deployment Image Servicing and Management from a Command Prompt or "PowerShell" script.
Not only does this command line tool come in separate 32- and 64-bit versions, there are different versions that work in different Windows versions.
https://learn.microsoft.com/en-us/wi...iew=windows-11
I don't know about that, but if you paste this code into "test.vbs" file and run it, it will execute as it should...
Code:
Dim objShell
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "cmd.exe", "/k " & "DISM.exe /Online /Cleanup-Image /ScanHealth", "", "runas", 1
-
Aug 26th, 2023, 04:31 PM
#9
Thread Starter
Addicted Member
Re: Cant run VBS script over Application
 Originally Posted by OptionBase1
You could try C:\Windows\SysNative\DISM.exe
You meant C:\Windows\SysWow64\DISM.exe ?
-
Aug 26th, 2023, 04:31 PM
#10
Re: Cant run VBS script over Application
Why don't you run DISM directly without going through cmd.exe first?
Last edited by VanGoghGaming; Oct 13th, 2023 at 04:19 PM.
-
Aug 26th, 2023, 04:31 PM
#11
Re: Cant run VBS script over Application
 Originally Posted by beic
You meant C:\Windows\SysWow64\DISM.exe ?
Nope, I meant exactly what I posted. Did you try it? SysNative is an alias that allows a 32 bit application to access the 64 bit System files.
-
Aug 26th, 2023, 04:41 PM
#12
Thread Starter
Addicted Member
Re: Cant run VBS script over Application
 Originally Posted by VanGoghGaming
Why don't you run DISM directly without going through cmd.exe first?
It wont run either like that.
-
Aug 26th, 2023, 05:04 PM
#13
Thread Starter
Addicted Member
Re: Cant run VBS script over Application
 Originally Posted by OptionBase1
Nope, I meant exactly what I posted. Did you try it? SysNative is an alias that allows a 32 bit application to access the 64 bit System files.
How is this possible in real case? I know of course about System, System32 and SysWow64 paths, but never heard about "virtual" SysNative path!
So, basically, SysNative is only available on 64-bit systems and above Windows 7 (Vista) ?
Btw, it's working, thank you!
-
Aug 26th, 2023, 05:30 PM
#14
Addicted Member
Re: Cant run VBS script over Application
Note well that running cmd.exe via shell from VB6 will always run the 32-bit cmd.exe.
Code:
Option Explicit
Private Sub Form_Load()
Dim stCmd As String
Dim objShell As Object
Set objShell = CreateObject("Shell.Application")
stCmd = "echo %PROCESSOR_ARCHITECTURE%"
' Results from running on my;
' Windows 10 X64
' VB6 SP6
objShell.ShellExecute "C:\Windows\system32\cmd.exe", "/k " & stCmd, "", "runas", 1
'Returns x86
objShell.ShellExecute "C:\Windows\sysnative\cmd.exe", "/k " & stCmd, "", "runas", 1
'Returns AMD64
objShell.ShellExecute "C:\Windows\syswow64\cmd.exe", "/k " & stCmd, "", "runas", 1
'Returns x86
Set objShell = Nothing
Unload Me
End Sub
Thus, I've always been explicit in the version of cmd.exe that I shell to.
Joe
Ref: The 'Sysnative' folder in 64-bit Windows explained
Ref: How-to: Detecting 64 bit vs 32 bit
-
Aug 26th, 2023, 06:17 PM
#15
Thread Starter
Addicted Member
Re: Cant run VBS script over Application
 Originally Posted by Joe Caverly
Note well that running cmd.exe via shell from VB6 will always run the 32-bit cmd.exe.
Code:
Option Explicit
Private Sub Form_Load()
Dim stCmd As String
Dim objShell As Object
Set objShell = CreateObject("Shell.Application")
stCmd = "echo %PROCESSOR_ARCHITECTURE%"
' Results from running on my;
' Windows 10 X64
' VB6 SP6
objShell.ShellExecute "C:\Windows\system32\cmd.exe", "/k " & stCmd, "", "runas", 1
'Returns x86
objShell.ShellExecute "C:\Windows\sysnative\cmd.exe", "/k " & stCmd, "", "runas", 1
'Returns AMD64
objShell.ShellExecute "C:\Windows\syswow64\cmd.exe", "/k " & stCmd, "", "runas", 1
'Returns x86
Set objShell = Nothing
Unload Me
End Sub
Thus, I've always been explicit in the version of cmd.exe that I shell to.
Joe
Ref: The 'Sysnative' folder in 64-bit Windows explained
Ref: How-to: Detecting 64 bit vs 32 bit
Thank you for the explanation example!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|