Sarah2016 Posted December 2, 2016 Posted December 2, 2016 (edited) Hi, I am facing a very annoying and confusing problem... I made a script, one of its function is to create a file in the working directory having the date and time of running the script and it starts once the windows start (by adding registry key).. Tested my script on my PC and it worked perfectly... Took this script to another PC and when I run (myself by double click!), it also work perfectly... BUT when it runs by the windows in start, it does not create any files in the directory (although the script is running as I found in task manager).. Spent HOURS (or DAYS !!) trying to figure out this puzzle... May be it's something related to user permission or something like that? but the user I'm running the script on is an admin! EDIT: facing the problem on Windows 7 Edited December 2, 2016 by Sarah2016
Developers Jos Posted December 2, 2016 Developers Posted December 2, 2016 (edited) Pretty sure line 13 is wrong but could confirm that when you post your script portion that creates the file. there is likely something wrong with the WorkDir. Jos Edited December 2, 2016 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Sarah2016 Posted December 2, 2016 Author Posted December 2, 2016 2 minutes ago, Jos said: Pretty sure line 13 is wrong but could confirm that when you post your script portion that creates the file. there is likely something wrong with the WorkDir. Jos not only with working dir tried multiple things added to that, it works perfectly on my PC! So it's not script issue for sure
Developers Jos Posted December 2, 2016 Developers Posted December 2, 2016 Ok ... Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Moderators JLogan3o13 Posted December 2, 2016 Moderators Posted December 2, 2016 So if it isn't a script issue I guess we're done here, right? How do you expect anyone to help you without posting the code you're using? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Sarah2016 Posted December 2, 2016 Author Posted December 2, 2016 (edited) Here it is: #NoTrayIcon #include <Date.au3> FileDelete(@WorkingDir & "\start.log") FileWrite(@WorkingDir & "\start.log", _NowDate() & " // " & _NowTime() & @CRLF) EDIT: also tried something other than @WorkingDIr Edited December 2, 2016 by Sarah2016
Developers Jos Posted December 2, 2016 Developers Posted December 2, 2016 So why are you using the @Workdir as target instead of defining a more explicit directory? Where are you expecting the file to be created? What happens when you hardcode a directory on the computer that doesn't work? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Juvigy Posted December 8, 2016 Posted December 8, 2016 Put the file on the desktop and try it. Did you try to run it as admin? (right click and chose run as administrator)
Tankbuster Posted December 8, 2016 Posted December 8, 2016 3 minutes ago, Juvigy said: Put the file on the desktop and try it. Did you try to run it as admin? (right click and chose run as administrator) Agree with your assumption, but even Admin may not have to right to write to certain dirs (depend on each system). And keep in mind also the way of "run by Windows" might be of interested, autostart, Scheduled, RegistryRun(once).... He did not named the method. So also mine is just a guess...
Tripredacus Posted December 9, 2016 Posted December 9, 2016 Yes, first thought "run by Windows" may mean the exe is executed in another session, or the file is being created in a location other than where the OP expects, based on the context of the account running the program. Twitter | MSFN | VGCollect
Sarah2016 Posted January 3, 2017 Author Posted January 3, 2017 Got the exact problem.. It is because the path is not defined explicitly (as Jos stated, strangely I couldn't figured it out despite he mentioned it from the beginning). "Run by windows" means when I put the file in startup folder, or when I put it in registry in "Run" Did some googling .. some ppl have the same problem http://stackoverflow.com/questions/2700015/why-cant-my-c-sharp-app-create-files-in-windows-7 So, it is not autoit problem! but how to solve it? in case I don't want to use explicit directory
Developers Jos Posted January 3, 2017 Developers Posted January 3, 2017 (edited) 1 hour ago, Sarah2016 said: in case I don't want to use explicit directory What is the issue with including the fully qualified path to shell the exe? Jos Edited January 3, 2017 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Sarah2016 Posted January 3, 2017 Author Posted January 3, 2017 1 hour ago, Jos said: What is the issue with including the fully qualified path to shell the exe? Jos The exe file will have different directory! I might run the exe file from my USB Drive ... it will be F:\ for example, or it may be on the desktop etc etc I want to keep the created file with the exe in the same folder
Developers Jos Posted January 3, 2017 Developers Posted January 3, 2017 So what is the logic to find the exe for the script? is it the PATH env variable you want to depend upon? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Sarah2016 Posted January 3, 2017 Author Posted January 3, 2017 28 minutes ago, Jos said: So what is the logic to find the exe for the script? is it the PATH env variable you want to depend upon? Jos didn't understand what you meant well.. the idea is that I have several computers .. i want to know when the computers were turned on and when they were shut down.. all have dropbox in them.. but the directory of dropbox differ.. I will keep this simple script in the dropbox folder of all computers so that I can see the "event log" easily... that's why I want to use @workingdir to locate the dropbox P.S. just knew that there are @workingdir and @scirptdir .. do they diffeR?
Developers Jos Posted January 3, 2017 Developers Posted January 3, 2017 I would expect the dropbox directory to be in a standard place as well. doesn't it by default exits in @UserProfileDir\dropbox? 4 minutes ago, Sarah2016 said: P.S. just knew that there are @workingdir and @scirptdir .. do they diffeR? We have a pretty nice helpfile that explains that. @ScriptDir: Directory containing the running script. Only includes a trailing backslash when the script is located in the root of a drive. @WorkingDir: Current/active working directory. Only includes a trailing backslash when the script is located in the root of a drive. So the workdir is the default directory for the shelled program. All clear? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Sarah2016 Posted January 3, 2017 Author Posted January 3, 2017 2 minutes ago, Jos said: I would expect the dropbox directory to be in a standard place as well. doesn't it by default exits in @UserProfileDir\dropbox? We have a pretty nice helpfile that explains that. @ScriptDir: Directory containing the running script. Only includes a trailing backslash when the script is located in the root of a drive. @WorkingDir: Current/active working directory. Only includes a trailing backslash when the script is located in the root of a drive. So the workdir is the default directory for the shelled program. All clear? Jos dropbox has default directory as you said but: 1) not all pc have dropbox in the default directory 2) even the default directory differs... as not all pc's have the same user account (e.g. some will be c:\user11\dropbox forexample others will hhave c:\user4444\dropbox) so I will need to use @userprofile and not explicit directory so we will get back to the same problem!
Developers Jos Posted January 3, 2017 Developers Posted January 3, 2017 Using @userprofile & "\dropbox" is as pretty explicit to me and would be a good approach. You somehow have to identify where the program is located before you can properly shell it or guess I am still missing what you are trying to get done here other than magic. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Sarah2016 Posted January 3, 2017 Author Posted January 3, 2017 3 minutes ago, Jos said: Using @userprofile & "\dropbox" is as pretty explicit to me and would be a good approach. You somehow have to identify where the program is located before you can properly shell it or guess I am still missing what you are trying to get done here other than magic. Jos I'm beginner... Sorry.. but what does "shell" mean?
Developers Jos Posted January 3, 2017 Developers Posted January 3, 2017 Sorry for the IT talk but hey, that's what I've been infected with over the last 40 years. Maybe this wiki is a good way to explain it in detail: https://en.wikipedia.org/wiki/Shell_(computing) What I simply mean with Shell is to run the program. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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