tonycst Posted March 19, 2016 Author Share Posted March 19, 2016 Never mind, i tried to push arguments from autoit directly into net.exe ShellExecuteWait (@SystemDir & "/NET.exe", "USE N: /DELETE",@SystemDir) ShellExecuteWait (@SystemDir & "/NET.exe", "USE N: " & $Address,@SystemDir) Still does not work. Only works when script is executed at start up from C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup Executing script from "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" at start up does not work. Clearly, there is a problem with autoit because it does not like to be executed from registry. It likes to be executed from a shortcut. End of story. Link to comment Share on other sites More sharing options...
spudw2k Posted March 19, 2016 Share Posted March 19, 2016 8 hours ago, tonycst said: End of story. Hey, I appreciate you taking the painstaking time to detail the problem with your Batman scenario. I got it, I really did. It works from startup folder, doesn't work from Run key in Registry; 'nuff said. I am interested in / unclear with what you meant in the second scenario when Batman said he is 'some user' to paraphrase and not 'I am Batman'. I don't understand whyt the script would run in that manner. I'll do some testing on my computer and see if I spot something. Have you tried alternative methods / scripts besides AutoIt (BAT, vbscript, powershell, etc.)? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
tonycst Posted March 19, 2016 Author Share Posted March 19, 2016 By the second scenario user is exactly the same in both cases, but because it was executed from a different location, its treated as someone who has rights to execute but not a known user. Its just a speculation but i think autoit either does not like to run from registry or when it does, it does not forward user credentials correctly. I cant confirm that other then by looking at the failed commands. Someone who has the autoit source and understand it, needs to look at it and see how it operates running from registry VS from start menu start up. DEBUG autoit. Link to comment Share on other sites More sharing options...
JohnOne Posted March 19, 2016 Share Posted March 19, 2016 Since you're so certain this is an AutoIt bug, and so insistent about what needs to be done, how how come you have not opened a bug ticket? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Juvigy Posted March 21, 2016 Share Posted March 21, 2016 1. C:\Users\Administrator\ (administrator local account) 2."HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" (currently logged in user/Any user) are 2 different things. Are you sure that when you test you do it by logging with the same account ? Link to comment Share on other sites More sharing options...
MuffinMan Posted March 21, 2016 Share Posted March 21, 2016 @tonycst Have you tried a simpler script that just runs NET USE with a hard coded mapping (just for testing purposes) through the registry? After looking over your script, I wonder if the script is having a problem finding Address.txt to set your $Address variable when ran from the registry. Link to comment Share on other sites More sharing options...
tonycst Posted March 28, 2016 Author Share Posted March 28, 2016 On 3/21/2016 at 2:06 AM, Juvigy said: 1. C:\Users\Administrator\ (administrator local account) 2."HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" (currently logged in user/Any user) are 2 different things. Are you sure that when you test you do it by logging with the same account ? No other users on the computer. Only Administrator. On 3/21/2016 at 5:56 AM, MuffinMan said: @tonycst Have you tried a simpler script that just runs NET USE with a hard coded mapping (just for testing purposes) through the registry? After looking over your script, I wonder if the script is having a problem finding Address.txt to set your $Address variable when ran from the registry. It does, but script generates it if its missing. Funny thing, it generated it in the C:\Windows\SysWOW64 folder. That tells me that something is wrong at the execution lever of autoit. If file is missing, it should generate it in where the script ran from instead of from where it was executed. So if script is executed by a user from D:\Script, it generates the address.txt in D:\Script\Address.txt But if script is generated by registry, Address.txt is then generated in C:\Windows\SysWOW64 I've seen this before. I cant trace it so i cant post a bug. All i know is that when it executes via registry, its executed differently then from a shortcut in start up menu, and thats where the problem is located, at its execution behavior. Link to comment Share on other sites More sharing options...
tonycst Posted March 28, 2016 Author Share Posted March 28, 2016 When script runs from registry here it whats happening. MsgBox (0,'',@ScriptDir) says "D:\Script\Network Drive Startup.exe" The D:\Script DOES have Address.txt in it with valid address, yet next line of code $Address = FileReadLine ("Address.txt",1) says it does not. So that tells me absolutely nothing. It tells me that the scriptdir is correct, yet its not executed from where scriptdir returns its value. This problem existed for long time and needs to be fixed. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 28, 2016 Developers Share Posted March 28, 2016 (edited) 4 hours ago, tonycst said: Funny thing, it generated it in the C:\Windows\SysWOW64 folder. That tells me that something is wrong at the execution lever of autoit. Not sure what you want to prove with this snippet: MsgBox (0,'',@ScriptDir) says "D:\Script\Network Drive Startup.exe" but it only proves to you what the scriptdirectory is, not the workdir where the subsequent FileReadLine() will try to find the file. So you better change that to: MsgBox (0,'',@WorkingDir) Jos Edited March 28, 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. Link to comment Share on other sites More sharing options...
willichan Posted March 28, 2016 Share Posted March 28, 2016 You lucked out. My test network was between projects, and I had a few minutes on my hands. The problem is definitely your script, and not AutoIt. With only a couple of fixes, I was able to make the script work on my text network double clicking to launch, running in a startup folder, AND from within the registry. Before I tell you what I had to fix, I would like to point out that your major problem was that you were not willing to listen to any suggestions that people were giving you. You seem to be suffering from the "I know what I know. You are the problem, not me" syndrome. A little humility will go a long way. I was guilty of it in my earlier years, so I won't hold it against you. But, I would suggest you avoid phrases like "I am not going to try that" (I read a few too may of those in this thread). Now to the solution. As Jos alluded to, you are not specifying paths for you "Address.txt" file, so the path it looks in will depend on how you launch it. I would recommend using @AppDataCommonDIr, since it is available regardless how you launch your script. $Address = FileReadLine (@AppDataCommonDir & "\Address.txt",1) If $Address = "" Then FileDelete (@AppDataCommonDir & "\Address.txt") FileWrite (@AppDataCommonDir & "\Address.txt","192.168.1.1" & @CRLF & "Avobe address is used to connect to network drive") Next, your NET USE command is not correct. You were not preceding the IP address with the double backslash, nor were you pointing to a share. In effect, you were just executing %ComSpec% /K NET USE N: 192.168.1.1 By adding the double backslash and adding a share, the command worked properly RunWait('"' & @ComSpec & '" /K NET USE N: \\' & $Address, '\sharename', @SW_SHOW) Giving the effective command as %ComSpec% /K NET USE N: \\192.168.1.1\sharename After those two simple changes, the script works regardless which method you use to launch it. Good luck. My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
JohnQSmith Posted March 30, 2016 Share Posted March 30, 2016 Instead of "NET USE", have you tried AutoIt's DriveMapAdd and DriveMapDel? Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Link to comment Share on other sites More sharing options...
tonycst Posted March 30, 2016 Author Share Posted March 30, 2016 (edited) Quote you are not specifying paths for you "Address.txt" $Address = FileReadLine ("Address.txt",1) If $Address = "" Then FileDelete ("Address.txt") FileWrite ("Address.txt","192.168.1.1" & @CRLF & "Avobe address is used to connect to network drive") MsgBox (16,"Error","No valid address was found." & @CRLF & "New Address.txt file was written. Please edit it for correct address and restart this application.") EndIf This means that if file is not found (where ever scrips is executed from) it will generate it and will read the address next time, yet it does not happen. I also dont want to change file path, i want it in the script directory. Quote Next, your NET USE command is not correct It works when i double click the script or run the script from the editor, how is that incorrect ? My counter comment to you is that YOU are not even trying to run the script to know better. You probably dont even have a network drive to try to map it using my script to confirm that it only works when double clicked or ran from start up folder. All most of people do is just look at the script and try to find a problem. Its plane simple code. ShellExecuteWait (@SystemDir & "/NET.exe", "USE N: /DELETE",@SystemDir) ShellExecuteWait (@SystemDir & "/NET.exe", "USE N: \\readyshare\USB_Storage",@SystemDir) RegWrite ("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","Network Drive StartUp","REG_SZ",@ScriptFullPath) #1 Compile the code (Edit the address if needed), and run it once. It will add its self to start from registry. #2 Restart the computer and observe that network drive is not mapped. #3 Double click the script and observe, network drive is mapped. #4 Resolve the problem without changing the location from which script starts (registry) Unless you run it, i cant take your comments seriously because they are based on a theory of observation but not actual test. Kinda like evolution with the exception that no one even observed it. Edited March 30, 2016 by tonycst Link to comment Share on other sites More sharing options...
Developers Jos Posted March 30, 2016 Developers Share Posted March 30, 2016 59 minutes ago, tonycst said: Unless you run it, i cant take your comments seriously because they are based on a theory of observation but not actual test. Kinda like evolution with the exception that no one even observed it. I like the attitude. Just tried this compiled as x86 script both Logout-Login and restart and worked fine: FileDelete(@ScriptDir & "\test.log") FileWriteLine(@ScriptDir & "\test.log","ShellExecute:") $rc=ShellExecuteWait (@SystemDir & "/NET.exe", "USE S: /DELETE",@SystemDir) FileWriteLine(@ScriptDir & "\test.log",$rc) $rc=ShellExecuteWait (@SystemDir & "/NET.exe", "USE S: \\server\Backups",@SystemDir) FileWriteLine(@ScriptDir & "\test.log",$rc) RegWrite ("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","Network Drive StartUp","REG_SZ",@ScriptFullPath) test.log: ShellExecute: 0 0 Your turn. 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. Link to comment Share on other sites More sharing options...
willichan Posted March 30, 2016 Share Posted March 30, 2016 (edited) tonycst You might want to try re-reading my post. On Monday, March 28, 2016 at 3:17 PM, willichan said: You lucked out. My test network was between projects, and I had a few minutes on my hands. The problem is definitely your script, and not AutoIt. With only a couple of fixes, I was able to make the script work on my text network double clicking to launch, running in a startup folder, AND from within the registry. So ... yes, I did run your code. I do understand your code on a practical (tested) level, not just theoretical, even if I don't agree with most of your methodologies. Alhough, it did not take actually running your code for me to identify what your problems are. If you don't want to use the folder I suggested, that is fine. I really don't care where you store it. It was a practical suggestion based on recommended standards and personal experience, but just a suggestion none the less. You still should specify the path to the file, wherever you put it, but it is your script ... your decision. You've been handed the answer on a platter, and had several people attempt to help and guide you. I wish you luck. You are on your own now. Edited March 30, 2016 by willichan My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
tonycst Posted March 31, 2016 Author Share Posted March 31, 2016 Perhaps my problem is that windows 7 is on Administrator account instead of regular user with administrative privileges ? I had issues with scripts because of that when i jumped back and forth from 7 to 10. Link to comment Share on other sites More sharing options...
JohnOne Posted March 31, 2016 Share Posted March 31, 2016 There is nothing special about administrator account as opposed to user account, it is just a username. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
AutoBert Posted March 31, 2016 Share Posted March 31, 2016 2 hours ago, tonycst said: I had issues with scripts because of that when i jumped back and forth from 7 to 10. Then make a new clean installation of your OS. Link to comment Share on other sites More sharing options...
Danny35d Posted April 1, 2016 Share Posted April 1, 2016 (edited) 6 hours ago, tonycst said: Perhaps my problem is that windows 7 is on Administrator account instead of regular user with administrative privileges ? I had issues with scripts because of that when i jumped back and forth from 7 to 10. Perhaps your problem is what willichan point out in post #30 "your NET USE command is not correct." Post #20 you said "net command returns error 67 (i looked it up) which means absolutely nothing wrong with the arguments" Do the following steps: 1) Open command prompt 2) Type net helpmsg 67 press enter You get the following message "The network name cannot be found." Once you fix the NET USE in your script because you are executing the script on the Administrator account you may get error 5 meaning "Access is denied." Edited April 1, 2016 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
tonycst Posted April 1, 2016 Author Share Posted April 1, 2016 (edited) On 3/30/2016 at 3:08 PM, Jos said: test.log: ShellExecute: 0 0 Your turn. Jos ShellExecute: 2 2 Danny35d Quote Perhaps your problem is what willichan point out in post #30 "your NET USE command is not correct." You make no sense. Command is 100% correct because it does what it suppose to do when i run the script. It returns 0's on shellexecute as per Jos attempt, but returns 2's when its ran from registry. Edited April 1, 2016 by tonycst Link to comment Share on other sites More sharing options...
Developers Jos Posted April 1, 2016 Developers Share Posted April 1, 2016 (edited) Lets do another experiment and try running this compiled script at login, doing it the old fashioned way: FileDelete(@ScriptDir & "\test.bat") FileWriteLine(@ScriptDir & "\test.bat",'Echo @ALL') FileWriteLine(@ScriptDir & "\test.bat",'Echo NET USE N: /DELETE > "' & @ScriptDir & '\test.log" 2>&1') FileWriteLine(@ScriptDir & "\test.bat",'NET USE N: /DELETE>> "' & @ScriptDir & '\test.log" 2>&1') FileWriteLine(@ScriptDir & "\test.bat",'Echo NET USE N: \\readyshare\USB_Storage >> "' & @ScriptDir & '\test.log" 2>&1') FileWriteLine(@ScriptDir & "\test.bat",'NET USE N: \\readyshare\USB_Storage >> "' & @ScriptDir & '\test.log" 2>&1') RunWait(@ComSpec & ' /c "' & @ScriptDir & '\test.bat"') Curious how the test.log will look for you. Jos Edited April 1, 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. 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