slaney30 Posted December 10, 2014 Share Posted December 10, 2014 I'm having some issues with an AUTOIT script and was wondering if someone could help me troubleshoot what I am doing wrong. I've looked through all the help files and can't seem to find out where I'm going wrong. I have a script that maps the z drive successfully if I do not pull the variable from the text file. The following below works fine in the PE environment. Unfortunately I need to pull the variable from a text file on the machine that runs it because the server.domain.com will change depending upon machine. Script 1 (works) Global $server = 'server.domain.com' MsgBox( 0, "variable value", $server) DriveMapAdd("Z:", "\\" & $server & "\deployment", 0, "domain.com\useraccount", "(password)") The script does not work: Global $sFilePath = @ScriptDir & "\servervar.txt" FileOpen($sFilePath, 0) Global $server = FileReadLine( "servervar.txt" ) MsgBox(0, "variable value", $server) DriveMapAdd("Z:", "\\" & $server & "\deployment", 0, "domain.com\useraccount", "(password)") I added the Msgbox to confirm that the $server variable was indeed gathering the correct data, and it does have the correct data that i would expect. Can anyone tell me why first script would work, but the 2nd will not? Like I said the 2nd script MsgBox is displaying the same data that i set manually with in the first script. I am new to autoit so if it's something really silly I apologize in advance. Any help would be much appreciated! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 10, 2014 Moderators Share Posted December 10, 2014 "doesn't work"; doesn't help much What error does the DriveMapAdd exit with? Throw a MsgBox after it, looking for @error. "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! Link to comment Share on other sites More sharing options...
Solution EndFunc Posted December 10, 2014 Solution Share Posted December 10, 2014 Make sure there are no spaces or new lines in the file. That might be causing some issues. Maybe try Global $server = StringStripWS(FileReadLine( "servervar.txt" ), 8) slaney30 1 EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
slaney30 Posted December 10, 2014 Author Share Posted December 10, 2014 "doesn't work"; doesn't help much What error does the DriveMapAdd exit with? Throw a MsgBox after it, looking for @error. By "doesn't work" i meant it doesn't map the drive. The @error that is displaying is 1. Link to comment Share on other sites More sharing options...
Spider001 Posted December 10, 2014 Share Posted December 10, 2014 else do a ConsoleWrite("" & $server & "deployment") maybe the fault come up if its a char problem Link to comment Share on other sites More sharing options...
slaney30 Posted December 10, 2014 Author Share Posted December 10, 2014 Make sure there are no spaces or new lines in the file. That might be causing some issues. Maybe try Global $server = StringStripWS(FileReadLine( "servervar.txt" ), 8) You are awesome! This is exactly what solved my problem. It must have been grabbing to many characters instead of only the characters listed. Thanks so much for your help! 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