Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBSCRIPT dont work windows 11 23h2 ???

Status
Not open for further replies.

kamicasu

Programmer
Oct 18, 2024
1
Hello i used this code for years, but with new version of windows 11 23H2 this macro dont work i dont know what to do, becaue with old version 22H2 work perfect, but my company wants update my system and cant because needed this for work

[PCOMM SCRIPT HEADER]
LANGUAGE=VBSCRIPT
DESCRIPTION=
[PCOMM SCRIPT SOURCE]
OPTION EXPLICIT
autECLSession.SetConnectionByName(ThisSessionName)

REM This line calls the macro subroutine
subSub1_

sub subSub1_()
dim pdv
dim itmi
dim cx

dim x, a
dim fim
dim finded
dim lista(5000000,3)

Dim oFSO, sFile, oFile, sText, objxls
Set oFSO = CreateObject("Scripting.FileSystemObject")
sFile = "C:\Program Files (x86)\IBM\Personal Communications\private\dadosMEA.txt"
REM' dados para teste, estes dados deverão de entrar diretamente de uma BD
REM' *******************************************************************************************

'************************DESCRICOES ************************
lista(1109954,1) = "LIMAO CL 3/5 ARG VNC C 2 "
'" "

'************************FILIAIS ************************


lista(1109954,2) = "043"



'************************FAMILIAS ************************
lista(1109954,3) = "405"





If oFSO.FileExists(sFile) Then
Set oFile = oFSO.OpenTextFile(sFile, 1)
Do While Not oFile.AtEndOfStream
sText = oFile.ReadLine
If Trim(sText) <> "" Then
a = sText
End If

REM' Entrada de dados manual para teste


a = Split(a,",")
pdv = a(0)
itmi = a(1)
cx = a(2)
REM' *******************************************************************************************
REM' *******************************************************************************************
autECLSession.autECLPS.SetCursorPos 10,21 REM' colocar o cursor para carregar o PDV
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys pdv
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[ENTER]"
autECLSession.autECLPS.SendKeys "[ENTER]"
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SetCursorPos 20,66 REM' colocar o cursor para carregar a filial e familia
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys lista(itmi,2) REM' BUGFIX - 22072016 - Allow to use all branches
autECLSession.autECLPS.SendKeys lista(itmi,3) REM' carregar familia
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[ENTER]"
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady

fim = "false"

do while fim <> "FIN DE LISTE" REM' loop do while para precorrer as paginas disponiveis
REM' ciclo para correr as linhas de cada pagina
for x = 7 to 18
REM' carregar em "finded" o conteudo dos 30 caracteres da linha
finded = autECLSession.autECLPS.GetText(x, 5, 30)
if finded = lista(itmi,1) then
REM' comparar a linha com o que se está a procurar
autECLSession.autECLPS.SetCursorPos x,54 REM' se encontrar a string certa carregar o valor
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
REM implementar função para detetar se já há algum valor na linha
autECLSession.autECLPS.SendKeys cx
autECLSession.autECLPS.SendKeys "[ENTER]"
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
fim = "FIN DE LISTE"
end if
next


fim = autECLSession.autECLPS.GetText(21, 2, 12) REM procurar e carregar em "fim" a string que aparece quando é a ultima pagina
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[pf8]"
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
loop

autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[pf3]"
autECLSession.autECLPS.SendKeys "[pf11]"

loop
End If

end sub
 
Why no punctuation or CODE tags to make your post at least readable?
 
You didn't show the error? At any rate, try Run this program in compatibility mode for: and select a previous version of Windows to get you past this error.

Next, start rebuilding the macro until you find the function or line causing the error.

Or, if you're not seeing errors, then it's likely an account execution policy or Windows 11 might have restrictive security settings for running scripts...

Check the Script Execution Policy by running gpedit.msc and looking under Administrative Templates > Windows Components > Windows Script Host.
Make sure that the folder where the script is located has appropriate permissions and is not restricted by the new Windows security settings.

It could also be User Account Control setting issue.
Try lowering UAC settings to see if the script executes correctly. If it works with lower UAC settings, you may need to adjust the execution policy or run the application with elevated permissions.

To lower the User Account Control (UAC) settings in Windows 11, follow these steps:

  1. Open the Start Menu:
    • Click on the Start button or press the Windows key.
  2. Search for UAC Settings:
    • In the search bar, type "UAC" or "User Account Control".
    • From the search results, select "Change User Account Control settings".
  3. Adjust the UAC Slider:
    • A window will open with a vertical slider that controls UAC notifications.
    • The slider has four settings:
      1. Always notify (most secure) – UAC will notify you for any changes to the computer.
      2. Notify me only when apps try to make changes to my computer (default setting).
      3. Notify me only when apps try to make changes to my computer (do not dim my desktop) – You will be notified but without the secure desktop dimming.
      4. Never notify (least secure) – Disables UAC, and Windows won’t notify you of any changes.
  4. Lower the Slider:
    • To reduce UAC sensitivity, move the slider down toward "Never notify". This will disable UAC notifications.
  5. Confirm Your Choice:
    • After adjusting the slider, click OK.
    • If prompted by UAC to confirm, click Yes.
  6. Restart Your Computer:
    • To apply the changes fully, you might need to restart your computer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top