Hello,
I'm trying to use AMS to map a drive(s). The code I have works, however on File.RunAs the command complete successfully but no drive is mapped. If I click on the batch file that File.RunAs is linked to, it's maps just fine. No errors when executed in AMS.
Code is below - What am I missing to make the batch file execute correctly in AMS?
I'm trying to use AMS to map a drive(s). The code I have works, however on File.RunAs the command complete successfully but no drive is mapped. If I click on the batch file that File.RunAs is linked to, it's maps just fine. No errors when executed in AMS.
Code is below - What am I missing to make the batch file execute correctly in AMS?
Code:
RunUID = TextFile.ReadToString("AutoPlay\\Content\\Common\\CommonA.dat"); RunPWD = TextFile.ReadToString("AutoPlay\\Content\\Common\\CommonP.dat"); Drive = Input.GetText("Dletter"); IP = Input.GetText("ip"); User = Input.GetText("User"); PWD = Input.GetText("Password"); qut = Input.GetText("qut"); --set = Input.SetText("CMD", "net use " ..Drive.. " " ..IP.. " /user:" ..User.. " " ..qut ..PWD ..qut.. ""); set = Input.SetText("CMD", "net use " ..Drive.. " " ..IP.. " /user:" ..User.. " " ..qut ..PWD ..qut.. "\r\npause"); get = Input.GetText("CMD"); TextFile.WriteFromString("C:\\TSAT\\MapDrive.bat", get.. "", false); File.RunAs("C:\\TSAT\\MapDrive.bat", "", "", SW_SHOWNORMAL, false, RunUID, RunPWD, "", LOGON_NO_OPTION, nil, nil); --Check to see if an error occurred. error = Application.GetLastError(); -- If an error occurred, display the error message. if (error ~= 0) then Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION); end TextFile.WriteFromString("AutoPlay\\Docs\\SystemLog.txt", System.GetDate(DATE_FMT_US).." | "..System.GetTime(TIME_FMT_AMPM).." | Map Drive was run\r\n", true); -- Write out the IP and UID to a text file TextFile.WriteFromString("AutoPlay\\Docs\\IP.txt", IP, false); TextFile.WriteFromString("AutoPlay\\Docs\\User.txt", User, false); TextFile.WriteFromString("AutoPlay\\Docs\\Drive.txt", Drive, false); TextFile.WriteFromString("AutoPlay\\Docs\\PWD.txt", PWD, false);
Comment