Strange issues with writing files.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pxl
Posts: 9
Joined: 07 Nov 2014, 02:52

Strange issues with writing files.

04 May 2015, 05:31

Hey there!

A little background..
I've written and deployed a script for my workplace that saves us countless of hours of work each day. It's an application running on top of one of our database tools enabling us to interact with orders in ways that before took several time consuming steps. It also communicates with a web service by means of a RESTful API and for this I'm using httprequest and that works swimmingly. I can't upload raw text in the form of XML as the service expects a *.xml file, but that's really the only gripe. I need to write a lot of temporary files, upload them, and delete them. In all - it's been awesome.

But as you go along, you learn new stuff and after some time you realize that your now quite old code isn't really fit for updating. So I started from scratch, rewriting, optimizing and adding new features. Development wen't along great. I tried everything, and it all worked. Writing and uploading files was smooth.

Then my computer started acting up, to the point where IT had to do a complete wipe. This is where everything goes sour.
I restored my backups (always backup) and tried my script. No luck. It just wouldn't talk to the API. After quite a lot of debugging I realized that no xml-files were written whatsoever.
That turned out to be a problem with administrative rights on my computer, which were solved pretty easily. However, the program must now be run as administrator, regardless of computer. My colleagues won't really notice since our computers have admin rights per default, but when we work in our cloud environment (win7 via citrix) these rights are revoked. So, basically, the new script won't work in the cloud because it can't write files. I write and read files for local settings as well, so basically nothing works.

I would have let this go by now, seeing as it seems plausible that programs can't just write files all willy-nilly without proper rights, but there is one thing that keeps gnawing at my brain.

... The old program still runs fine in the cloud environment, happily writing files left and right, doing its business.
I can't wrap my head around this so I come here, to you guys, hoping that someone might know what's up.


TLDR
My old script can read/write files without specific permissions but my new one can't. Why?
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: Strange issues with writing files.

04 May 2015, 06:48

Please if you wish us to help debug this we will need something to debug...

When you just tell us something new vs something old is/ is not working we have nothing to work with.

Please post all or at least the shareable parts of your scripts code so we can try and help.
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
pxl
Posts: 9
Joined: 07 Nov 2014, 02:52

Re: Strange issues with writing files.

04 May 2015, 07:26

Well, yeah, I realize that might be necessary, but the thing is that there should be nothing that different between versions.
for example

FileAppend, %content%, %file% does exactly what it should in the old version and yet does nothing in the new.
Also, the new version did work fine before my computer was wiped and my user rights got messed up.

So if I start with an (hopefully) easy question:
Does user rights for the compiling machine somehow affect the compiled script?
User avatar
Chunjee
Posts: 1499
Joined: 18 Apr 2014, 19:05
Contact:

Re: Strange issues with writing files.

04 May 2015, 07:29

Might try a different directory. like C:/temp

Sometimes I run into issues where the running user does not have permission to write (or read!) certain network locations or certain user directories. Recently I had trouble because admin permission is needed to mess with C:/Program Files/
pxl
Posts: 9
Joined: 07 Nov 2014, 02:52

Re: Strange issues with writing files.

04 May 2015, 08:07

I have tried most locations, ranging from C:\Temp to AppData and a networked drive. Nothing :(
User avatar
Chunjee
Posts: 1499
Joined: 18 Apr 2014, 19:05
Contact:

Re: Strange issues with writing files.

04 May 2015, 08:27

Is it possible to use task manager or perfmon in your cloud environment to see which user is running the old .exe and see if that matches the new one?
https://msdn.microsoft.com/en-us/librar ... 71%29.aspx

Perhaps worth playing with RunAs to launch the program?
http://ahkscript.org/docs/commands/RunAs.htm


Maybe a different method of writing files might be successful!?
http://ahkscript.org/docs/objects/File.htm#Write_2

Code: Select all

XML = very strong
File_Path = %A_ScriptDir%\foobar.txt

File := FileOpen(File_Path, "w")
File.Write(XML), File.Close()
jpginc
Posts: 124
Joined: 29 Sep 2013, 22:35

Re: Strange issues with writing files.

04 May 2015, 08:30

I had a similar issue because I was running the executable from the program files directory, which has become more special in windows 7.

I moved my executable into another file (something like c:/myfolder) and it ran fine.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Spawnova and 225 guests