00serk29 Posted November 13, 2018 Share Posted November 13, 2018 (edited) Let's cut straight to the chase, im bad at autoit and i can't get my script to open a file from a removable USB. I have tried to open mmc.msc , notepads and powershell script from the usb with no results. The simple code i use is Run ("F:\S.K\m") As i mentioned before i have tried everything i can think of: Run ("F:\S.K\m.exe") MMC saved path file Run ("F:\S.K\m.msc") MMC saved path file Run ("F:\S.K\m") MMC saved path file Run ("F:\S.K\mmc") Just a plain copy of MMC that i copied over to the USB Run ("F:\S.K\test1") Tried opening notepad from the USB Run("F:\S.K\mmcstart.ps1") Even this powershell notepad code is not starting I even included #RequireAdmin at the very top of my acript, no results. I have also tried giving a varible the pathway to the file i want to run and then tried to run the variable, bad eng sorry. #RequreAdmin Global $Test $Test = ("F:\S.K\test1.exe") //The simple notepad file on the USB, this explanation text is not included in the script. Run ($Test) I am clueless :/ Edited November 13, 2018 by 00serk29 Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted November 13, 2018 Share Posted November 13, 2018 (edited) Hi @00serk29, and welcome to the AutoIt forums Sometimes bad syntax could mess your script... Try this: Global $Test $Test = "F:\S.K\test1.exe" ; The simple notepad file on the USB, this explanation text is not included in the script. ; Comments are started with ; (single line), or #cs and #ce for multi-line ; You could even check if the file exists If FileExists($Test) Then ConsoleWrite("The file exists and it will be runned." & @CRLF) Run ($Test) Else ConsoleWrite("The file doesn't exist and it won't be runned." & @CRLF) EndIf Edited November 13, 2018 by FrancescoDiMuro Corrected variable name Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
00serk29 Posted November 13, 2018 Author Share Posted November 13, 2018 Thanks for the fast reply. I tried you'r suggestion in my code and then in a new empty saved code page and i got the same error in both. MC FRÅN FORUMS.au3"(5,19) : error: Test(): undefined function. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted November 13, 2018 Share Posted November 13, 2018 @00serk29 Look at the code above (edited), and try to run it once again Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
00serk29 Posted November 13, 2018 Author Share Posted November 13, 2018 @FrancescoDiMuro My bad. The code is in fact working, or atleast it runs but with no results. I made sure that the file "test1.exe" exists and that the path and name to and of the file is correct. I tried changing tha path so the code would run the other files in the same folder but once again, the code runs and stops without any result or a launched program/file. I tried adding and removing #RequireAdmin at the top aswell as trying all the files twice: Just plain name "test1" and the name with the specified filetype "test1.exe", still no results. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted November 13, 2018 Share Posted November 13, 2018 (edited) @00serk29 We can't know what "test1.exe" effectively does. Try to compile a script which you are secure it will give some feedback in case of being run. You could compile this #include <MsgBoxConstants.au3> MsgBox($MB_ICONINFORMATION, "", "Runned!") name it as you want, and try to run this script. If it will run, than you'll see a MsgBox appear Edited November 13, 2018 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
00serk29 Posted November 13, 2018 Author Share Posted November 13, 2018 @FrancescoDiMuro The message box does in fact appear stating that the script ran. To make sure there isn't a problem with the USB i created a folder in C: and placed a notepad.exe in it. i Specified the path to the notepad file and made sure it was correct. The notepad file only has the number 3 sign in it. When running the script with the F5 key i get the "Runned!" MsgBox. The script is working but the files aren't opening. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted November 13, 2018 Share Posted November 13, 2018 @00serk29 Maybe you're doing a little bit of confusion... Run() is used to run an external program (.exe, .com, .bat...); ShellExecute() is used to run a program too, but to open a text file, you have to use this function. If you try to open (visually) a text file with Run(), then it won't do anything; indeed, if you use ShellExecute(), it will be opened. Try it and let us know P.S.: always post your code! 00serk29 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
00serk29 Posted November 13, 2018 Author Share Posted November 13, 2018 (edited) @FrancescoDiMuro ShellExecute() was the function i was looking for, now everything works just fine, thanks. And i will probably start posting my code to stop wasting peoples time, sorry. Is there a way to mark this topic as SOLVED? Edited November 13, 2018 by 00serk29 Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted November 13, 2018 Share Posted November 13, 2018 1 minute ago, 00serk29 said: And i will probably start posting my code to stop wasting peoples time, sorry. People are here trying to help other people, so no waste of time 1 minute ago, 00serk29 said: Is there a way to mark this topic as SOLVED? Just edit your first post, and write in the title "Solved - Title of the thread". Have a good day Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
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