Siva88 Posted November 22, 2019 Share Posted November 22, 2019 Hi, I need to create a folder under "C:\Program Files\Mozilla firefox". But the challenge is i'm running the script as non-elevated user and even i can mention the username and password of admin credentials. I need a script for creating a folder under that directory and need to paste one file from network. Link to comment Share on other sites More sharing options...
Developers Jos Posted November 22, 2019 Developers Share Posted November 22, 2019 Moved to the appropriate forum. Moderation Team 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...
rudi Posted November 22, 2019 Share Posted November 22, 2019 the folder "C:\Program Files" is protected by windows itself against write access without elevated rights ("Run as administrator", it's even not sufficent to be locally logged on as member of the local group "Administrators"!) add the line ... #RequireAdmin ... on top of your script, *IF* you really need to write to that folder. Another option would be not to "pull" the file from the workstation, but to "push" it from the server side. Either by a Script, or using GPO. CU, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Siva88 Posted November 22, 2019 Author Share Posted November 22, 2019 Hi, #RequireAdmin while adding this it's asking a popup username and password is it possible to mention the local administrator credentials in script itself and pass it? Link to comment Share on other sites More sharing options...
rudi Posted November 22, 2019 Share Posted November 22, 2019 Have a look at this post: Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Siva88 Posted November 25, 2019 Author Share Posted November 25, 2019 can you please tell me why this script is not working.. #include <AutoItConstants.au3> #include <StringConstants.au3> #include <File.au3> #include <array.au3> $file = "C:\mscript\ips.txt" FileOpen($file, 0) $fileuser = "C:\mscript\username.txt" FileOpen($fileuser, 0) $uname = FileReadLine($fileuser, 1) $passwd = FileReadLine($fileuser, 2) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) Local $sOutput = "" Local $sOutPath = "C:\mscript" $sFileName = $sOutPath &"\browseroutput" $hFilehandle = FileOpen($sFileName, $FO_APPEND) Global $sData = FileRead("C:\mscript\browseroutput.txt") ; Read the RSS File you will need to change the path to match the location on your PC $sRemoteLocalPath = "c:\TNI\" $LocalFile = "browser.bat" Local $testing = Run('D:\Downloads\PSTools\PsExec.exe -nobanner \\' & $line & ' "' & $sRemoteLocalPath & $LocalFile & '"', '', @SW_SHOWDEFAULT) ConsoleWrite("Browser :" & $testing) Do Sleep(100) Until @error ; error occurs when command has finished $sOutput = StringStripWS($sOutput, $STR_STRIPALL) ; remove all @cr and spaces from output FileWrite($hFilehandle, @CRLF & "Name="&$line& ' ' & $sOutput & @CRLF) Next FileClose($file) Link to comment Share on other sites More sharing options...
ripdad Posted November 25, 2019 Share Posted November 25, 2019 You're not using FileOpen properly. It returns a handle to the file that you write and read with. Take a close look at the examples in the HelpFile... https://www.autoitscript.com/autoit3/docs/functions/FileOpen.htm "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
Musashi Posted November 25, 2019 Share Posted November 25, 2019 33 minutes ago, ripdad said: You're not using FileOpen properly. It returns a handle to the file that you write and read with. Yes ! Note from The Help : "Do not mix filehandles and filenames, i.e., don't FileOpen() a file and then use a filename in this function. Use either filehandles or filenames in your routines, not both!" A proper variable declaration could also not do any harm . Place the following statement at the beginning of the script : #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 6 -w 7 or at least use : Opt("MustDeclareVars", 1) Global and Local declarations within loops are not recommended. Last but not least : Read Best_coding_practices "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." 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