Sign in to follow this  
Followers 0

Ini Read, Runas, _restart Script, And Errors

3 posts in this topic

Hi, have a script that gathers information from an ini file that does a runas install of applications listed in ini file. This works fine when an "App" entry is present in ini file.

When there is no "App" entry in ini file user is prompted to 'browse' for 'App" and this entry is written to "App" section of ini file. This is implemented and working in script. However im struggling to make the script _restart(), in the example below (on the latest beta) script will keep looping after _restart() without detecting the (newly created through browse) "App" ini file entry (which is created and present in ini file)

Anyone able to take a look?

Credit to all the code ive used from forum users, appreciated thanks

;;;;;;;;; Code starts Here

#include <File.au3>

#include <Array.au3>

$myUser=IniRead(@ScriptDir & "\runAs.ini","User","Admin","")

$myPass=IniRead(@ScriptDir & "\runAs.ini","User","AdminPass","")

$myDom=IniRead(@ScriptDir & "\runAs.ini","User","Domain","")

$testApps = IniReadSection("runAs.ini", "App")

If @error Then

$iMsgBoxAnswer = MsgBox(1,"No apps listed in App section of ini file", "Check your ini file's App section for entries to install")


Case $iMsgBoxAnswer = 1 ;OK



Case $iMsgBoxAnswer = 2 ;Cancel






Func _noApp()

$myNewApp = FileOpenDialog("Browse for setup file", @DesktopDir, "All (*.*)",1 + 2)

$myIni = IniWrite(@ScriptDir & "\runAs.ini","App", "myApp1",$myNewApp)


Func _myApp()

$myApps = IniReadSection("runAs.ini", "App")

For $i = 1 To $myApps[0][0]


RunAsSet ($myUser ,$myDom ,$myPass)


RunAsSet();<-- To restore initial account



Func _restart()

If @Compiled = 1 Then

Run( FileGetShortName(@ScriptFullPath))


Run( FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath))




;;;;;;;;;Code ends

;;;Ini file example (runAs.ini)







;;end ini example

; Eg if you provide good above user/domain/pass then comment out myApp1 entry you are prompted for browse for application to install then that app is written to ini file and script _restart then its as if the entry isnt being found for 'App' although it exists from 'browsed selection.

regards and tio

Share this post

Link to post
Share on other sites

Do you think it has anything to do with the fact that you're using @ScriptDir & "\runAs.ini" for every other Ini function, but just "runAs.ini" for the IniReadSection function? I would suggest making your ini a variable at the top, like $runAsIni = @ScriptDir & "\runAs.ini", and then using the var $runAsIni for the rest of the ini function calls.

Share this post

Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks greenmachine, thats fixed it

Sloppy on my behalf to have missed that, not sure why it affects it but it obviously does, have to have a think about it when i have some time

Regards :)

Edited by zichy

Share this post

Link to post
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
Sign in to follow this  
Followers 0