Jump to content

Map a drive in WINPE using a variable from the first line of a text file


slaney30
 Share

Go to solution Solved by EndFunc,

Recommended Posts

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

  • Moderators

"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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...