ahlm Posted November 27, 2019 Posted November 27, 2019 Hello, I'm new in the world of Autoit and have a questen about the Run-Command: I have to write a program to "delay" the start of programs in the StartUp-folder as long as the pc has no connection to the network. My problem is that the first program starts with no difficulties, but that's it. The other two programs don't start and I dont't get an error-message. I tried to write the program in C# before, but got an error-message that the file couldn't be found. The name and the path are both correct so i don't know why i get this message. Here is my current code: #include<Inet.au3> #include<MsgBoxConstants.au3> $ip = @IPAddress1 While $ip = "127.0.0.1" MsgBox(0, "IP-Adresse", "Client not connected to the network yet") $ip = @IPAddress1 WEnd If $ip <> "127.0.0.1" Then Run("C:\Program Files\HOBLinkTE\hoblinkl.exe") Run('"C:\Windows\System32\Empirum\EmpInventory.exe" "/CEmpInvScan_Windows.xml" "/O%Domainname%.%ComputerName%_%SysTime%.xml" /E /V2 /M /T /ZIP') ;~ Run("Desktop - Germany – Prod.exe.lnk","C:\Program Files (x86)\Citrix\ICA Client\SelfServicePlugin") EndIf Does anyone know how to fix this issue? Thanks in advance. ahlm
Nine Posted November 27, 2019 Posted November 27, 2019 (edited) If you want to use environment variables in strings, you need to add this line : Opt ("ExpandEnvStrings", 1) You could also use the different macros available in AutoIt (e.g. @LogonDomain, @ComputerName, etc.) instead of relying on environment vars. In all cases, make sure you check for success or failure (@error) after each statement, so you know what kind of error you're having. When posting code, please use this tool. Edited November 27, 2019 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
ahlm Posted November 27, 2019 Author Posted November 27, 2019 I did a check after Run('"C:\Windows\System32\Empirum\EmpInventory.exe" "/CEmpInvScan_Windows.xml" "/O%Domainname%.%ComputerName%_%SysTime%.xml" /E /V2 /M /T /ZIP') and got the error code "1" back. What does this mean? Is it the same problem as with my C# program, that the exe could not be found?
Earthshine Posted November 27, 2019 Posted November 27, 2019 (edited) https://www.autoitscript.com/autoit3/docs/functions/Run.htm Return Value Success: the PID of the process that was launched. Failure: 0 and sets the @error flag to non-zero. look, you have to read the documentation, check the @error flag to see if any errors after operation. make sure your command runs on the command line properly first so you can get the syntax right you can pm me your c# code, i will have a look at that. Edited November 27, 2019 by Earthshine My resources are limited. You must ask the right questions
Nine Posted November 27, 2019 Posted November 27, 2019 Hmmm. You might need to set the working directory of the run command. You can check before run : if FileExists ("C:\Windows\System32\Empirum\EmpInventory.exe") then ConsoleWrite ("EXE is OK" & @CRLF) If it is ok, then it is the parameters that cause the problem. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
ahlm Posted November 27, 2019 Author Posted November 27, 2019 I've checked if the path C:\Windows\System32\Empirum does exist. It does, but when i add the exe file to the path it doesn't. There must be any problem with the exe but i can't figuere out what it is 😐
Nine Posted November 27, 2019 Posted November 27, 2019 Try #RequireAdmin at the beginning of your script. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Earthshine Posted November 27, 2019 Posted November 27, 2019 so this file does or does not exist? is it there under windows? C:\Windows\System32\Empirum\EmpInventory.exe My resources are limited. You must ask the right questions
AdamUL Posted November 27, 2019 Posted November 27, 2019 Are you running your script as 32 or 64 bit? If you are running it as 32 bit, redirection could be your issue. Also, if %SysTime% returns colons, they are invalid characters in a file name. Based on your given code, give this a try. #include<MsgBoxConstants.au3> #include <WinAPIFiles.au3> ;Turn off redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False) $ip = @IPAddress1 While $ip = "127.0.0.1" MsgBox($MB_OK, "IP-Adresse", "Client not connected to the network yet") $ip = @IPAddress1 WEnd If $ip <> "127.0.0.1" Then Run("C:\Program Files\HOBLinkTE\hoblinkl.exe") Run('"C:\Windows\System32\Empirum\EmpInventory.exe" "/CEmpInvScan_Windows.xml" "/O' & @LogonDomain & '.' & @ComputerName & '_' & @HOUR & @MIN & @SEC & '.xml" /E /V2 /M /T /ZIP') EndIf Adam
Musashi Posted November 27, 2019 Posted November 27, 2019 Try : ;~ #RequireAdmin ConsoleWrite ("> ==> @SystemDir = " & @SystemDir & @CRLF) If FileExists (@SystemDir & "\Empirum\EmpInventory.exe") Then ConsoleWrite ("+ EmpInventory.exe found" & @CRLF) Else ConsoleWrite ("! EmpInventory.exe not found" & @CRLF) EndIf "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
ahlm Posted November 27, 2019 Author Posted November 27, 2019 21 minutes ago, Nine said: Try #RequireAdmin at the beginning of your script. I tried.. file still does not exist I'm currently checking the files in C:\Windows\System32\Empirum\.. #include <MsgBoxConstants.au3> #RequireAdmin If FileExists("C:\Windows\System32\Empirum\lang") Then MsgBox(0,"", "Path exists.") Else MsgBox(0,"", "Path does not exist.") EndIf "Lang" is another folder in the directory but even this folder does not exist.
ahlm Posted November 27, 2019 Author Posted November 27, 2019 7 minutes ago, AdamUL said: Are you running your script as 32 or 64 bit? If you are running it as 32 bit, redirection could be your issue. Also, if %SysTime% returns colons, they are invalid characters in a file name. Based on your given code, give this a try. #include<MsgBoxConstants.au3> #include <WinAPIFiles.au3> ;Turn off redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False) $ip = @IPAddress1 While $ip = "127.0.0.1" MsgBox($MB_OK, "IP-Adresse", "Client not connected to the network yet") $ip = @IPAddress1 WEnd If $ip <> "127.0.0.1" Then Run("C:\Program Files\HOBLinkTE\hoblinkl.exe") Run('"C:\Windows\System32\Empirum\EmpInventory.exe" "/CEmpInvScan_Windows.xml" "/O' & @LogonDomain & '.' & @ComputerName & '_' & @HOUR & @MIN & @SEC & '.xml" /E /V2 /M /T /ZIP') EndIf Adam It worked! Thank you all very much for your help. Espacally you especially Adam! 😊
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now