Can't successfully run batch file
- Jac de Lad
- Enthusiast
- Posts: 106
- Joined: Wed Jul 15, 2020 7:10 am
- Contact:
Can't successfully run batch file
Hello,
I have a strange problem. I want to run a batch file from my program. If I run the batch file in the explorer it works find, but if I run it from program I get the "... is not recognized as internal or external command" error.
- the path variable is ok, I even added the full paths
- I can run the batch file in the windows explorer. I let succeeds always.
- I also tried calling it via ShellExec_(), that doesn't work.
- I tried calling the program directly, that doesn't work too.
The corresponding programs are qwinsta.exe and tscon.exe in the system folder. Do I need special rights to execute them?
I have a strange problem. I want to run a batch file from my program. If I run the batch file in the explorer it works find, but if I run it from program I get the "... is not recognized as internal or external command" error.
- the path variable is ok, I even added the full paths
- I can run the batch file in the windows explorer. I let succeeds always.
- I also tried calling it via ShellExec_(), that doesn't work.
- I tried calling the program directly, that doesn't work too.
The corresponding programs are qwinsta.exe and tscon.exe in the system folder. Do I need special rights to execute them?
- NicTheQuick
- Addict
- Posts: 1224
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: Can't successfully run batch file
Are you trying to run a 64 bit program from a 32 bit Purebasic program?
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
- Jac de Lad
- Enthusiast
- Posts: 106
- Joined: Wed Jul 15, 2020 7:10 am
- Contact:
Re: Can't successfully run batch file
I think so. I mean, I'm executing a batch file, shouldn't this be possible?
- Jac de Lad
- Enthusiast
- Posts: 106
- Joined: Wed Jul 15, 2020 7:10 am
- Contact:
Re: Can't successfully run batch file
I can't compile in x64 because:
produces an error and I don't know how to fix it because I copied it from a thread somewhere here.
Code: Select all
Import
GetConsoleWindow_() As "_GetConsoleWindow@0"
EndImport
- Jac de Lad
- Enthusiast
- Posts: 106
- Joined: Wed Jul 15, 2020 7:10 am
- Contact:
Re: Can't successfully run batch file
Ok, so, cutting the code and trying again worked, it was indeed a 86/64 problem. Thanks, now I know how to go on. If anybody can help me with the snippet above everything would be alright.
- NicTheQuick
- Addict
- Posts: 1224
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: Can't successfully run batch file
Well, I have only guessed because I heard issues with that already. The permission model of Windows is split into x86 and x64 and running 64 bit programs from an 32 bit program usually does not work without workarounds.
Because I am not using Windows I can not help you with GetConsoleWindow_. I hope someone else can help you there. Maybe it also helps if you can write where you found than original code.
Because I am not using Windows I can not help you with GetConsoleWindow_. I hope someone else can help you there. Maybe it also helps if you can write where you found than original code.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
- Jac de Lad
- Enthusiast
- Posts: 106
- Joined: Wed Jul 15, 2020 7:10 am
- Contact:
Re: Can't successfully run batch file
Yeah, strange. But I guess MS had something in mind.
I found it here:
viewtopic.php?f=12&t=59618
I guess it's some API import, but I'm not firm with that.
I found it here:
viewtopic.php?f=12&t=59618
I guess it's some API import, but I'm not firm with that.
- NicTheQuick
- Addict
- Posts: 1224
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: Can't successfully run batch file
Well, it looks like the function will not be supported anymore and it is not recommended to use: https://docs.microsoft.com/en-us/window ... solewindow
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Re: Can't successfully run batch file
Try this:
Code: Select all
Import "kernel32.lib"
CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
GetConsoleWindow_() As "GetConsoleWindow"
CompilerElse
GetConsoleWindow_() As "_GetConsoleWindow@0"
CompilerEndIf
EndImport
- Jac de Lad
- Enthusiast
- Posts: 106
- Joined: Wed Jul 15, 2020 7:10 am
- Contact:
Re: Can't successfully run batch file
Yeah, just read that too. EnumWindows does the trick too.
@mijikai Thanks, that's working too. Now I have two options.
Thanks for your help!
@mijikai Thanks, that's working too. Now I have two options.
Thanks for your help!