Jump to content

Run program as Shell


xzaz
 Share

Recommended Posts

Yhee! Another problem, well i laung my program

- without being compiled > Runs fine on Windows Vista computer

- being compiled > Runs fine on Windows Vista computer

- being compiled in Windows XP -> Runs fine

- being compiled in Shell Modes (windows XP) -> "Autoit Error: Line -1: Error: Variable used without being declared"

Why is that, cant windows use the @documentsdir enc funtions when you laung a other program then explorer as a shell?

Link to comment
Share on other sites

Yhee! Another problem, well i laung my program

- without being compiled > Runs fine on Windows Vista computer

- being compiled > Runs fine on Windows Vista computer

- being compiled in Windows XP -> Runs fine

- being compiled in Shell Modes (windows XP) -> "Autoit Error: Line -1: Error: Variable used without being declared"

Why is that, cant windows use the @documentsdir enc funtions when you laung a other program then explorer as a shell?

posting your code would make it possible to help you, but I suspect that you need to add some error checking to your script.

[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

posting your code would make it possible to help you, but I suspect that you need to add some error checking to your script.

Well i tell the truth, i dont like to post my code yet. But it aint the problem The code works fine until i run it as a shell. Normal uncompiled and compiled it works fine. So theres nothing wrong with the script.
Link to comment
Share on other sites

Like @ScriptDir @Compiled @AutoItExe @ScriptFullPath @Username?

And what does the line -1 means, thats the including files? And why doesnt he shows the var that isn't be declared?

Edit2: Wierd, @XXX does seems to work normaly, i got every var that i use in a include file declared on a Global.

And when i press Ctrl+alt+delte and press "New task" and then let my program run it works..

Edited by xzaz
Link to comment
Share on other sites

There is nothing wrong with the code :)

#include <GUIConstants.au3>
#include <File.au3>
#include <String.au3>
#include <functions.au3>

;Gemaakt door Eise van der Spoel © oktober 2007
;Versie     1.2
    
        _mapping()                                                              ;==> Begin mapping

$desktopw = 1024
$desktoph = 768
;chance_res("1024","768","32","60")
$config_file =  "config/config.ini"                                             ;==> Configuratie bestand
if FileExists(@ScriptDir&"\"&$config_file) = False Then
    msgBox(16,"Fout!","Configuratiebestand niet gevonden! Informatie: 1"&@CRLF&$configfile)
Endif
$path = "programmas/progs.ini"                                                  ;==> Pad van de INI files; Programma'S
Global $avSecNames = IniReadSectionNames($path)                                 ;==> Tel de programma's
Global $Afvraag,$iInt,$path,$font,$backgroundimg,$pass,$internet,$internethome,$doccheck,$hoogte                                                    
if FileExists($path) = False Then
    msgBox(16,"Fout!","Configuratiebestand niet gevonden! Informatie: 2"&@CRLF&$configfile)
Endif
$font = IniRead($config_file,"algemeen","font","verdana")                       ;==> Font verdana gebruiken
$backgroundimg = IniRead($config_file,"algemeen","bg","back.jpg")               ;==> Achtergrond afbeelding
$pass = IniRead($config_file,"algemeen","pass","")                              ;==> Administrator wachtwoord
$internet = IniRead($config_file,"algemeen","internet","aan")                   ;==> Internet aan/uit
$internethome = IniRead($config_file,"algemeen","internethome","")              ;==> Internet startpagina
$doccheck = IniRead($config_file,"algemeen","doccheck","aan")                   ;==> Documenten
$hoogte = IniRead($config_file,"algemeen","icohoogte",720)                      ;==> Hoogte van de iconen
If @error Or $avSecNames[0] < 1 Then Exit
    
$rsn = IniReadSectionNames($path)                                               ;==> Alle programma's uit de database halen
Global $avButtons[$avSecNames[0] + 1][2] = [[$avSecNames[0], ""]]               ;==> Voor elke sectie uit de INI file een button
                                                                                ;==> Start MainGUI
                                                                                
                                                                            $Gui = GUICreate("", 1024, 768, 0, 0 , $WS_POPUP)
                                                                            $bg = GUICtrlCreatepic("img/"&$backgroundimg, 0,0,1024,768 )
                                                                            GUICtrlSetState($bg, $GUI_DISABLE)
                                                                            GUISetBkColor(0x58E64D, $Gui)
                                                                            GUICtrlSetBkColor(Default, $GUI_BKCOLOR_TRANSPARENT)
                                                                            
                                                                        
                                                                                    
                                                                                        
                                                                            For $i = 1 To $avSecNames[0]
                                                                                    $avReadSec = IniReadSection($path, $avSecNames[$i])
                                                                                    If @error = 0 And $avReadSec[0][0] > 0 Then
                                                                                            if $i = 1 Then 
                                                                                                $buttonpl = $buttonpl + 100 ;==> Begin hoogte
                                                                                            Else
                                                                                                $buttonpl = $buttonpl +32 ;==> Hoeveel pix zit er tussen de knoppen
                                                                                            Endif
                                                                                                GuiCtrlCreateLabel("", 10, $buttonpl, 30, 30,$BS_DEFPUSHBUTTON + $BS_FLAT)
                                                                                                GUICtrlSetBkColor(-1,$avReadSec[3][1])
                                                                                        $avButtons[$i][0] = GUICtrlCreateButton(" " & $avReadSec[1][1], 40, $buttonpl, 100, 30,$BS_DEFPUSHBUTTON + $BS_FLAT + $BS_LEFT)
                                                                                    EndIf
                                                                            Next

                                                                            $Documenten = GUICtrlCreateButton("",10, $hoogte, 48, 48, $BS_ICON + $BS_FLAT)
                                                                                            GUICtrlSetImage(-1, "ico\doc.ico", 0, 0)
                                                                            $Browser = GUICtrlCreateButton("",60,$hoogte , 48, 48, $BS_ICON + $BS_FLAT )
                                                                                            GUICtrlSetImage(-1, "ico\internet.ico", 0, 0)
                                                                            $Refresh = GUICtrlCreateButton("Vernieuwen",110,$hoogte,48,48, $BS_ICON + $BS_FLAT )
                                                                                            GUICtrlSetImage(-1, "ico\refresh.ico", 0, 0)
                                                                            $Word = GUICtrlCreateButton("Word",160,$hoogte,48,48, $BS_ICON + $BS_FLAT)
                                                                                            GUICtrlSetImage(-1, "ico\word.ico", 0, 0)
                                                                            $Admin = GUICtrlCreateButton("Admin",210,$hoogte,48,48, $BS_ICON + $BS_FLAT)
                                                                                            GUICtrlSetImage(-1, "ico\admin.ico", 0, 0)
                                                                            $Afsluiten = GUICtrlCreateButton("Afsluiten",975,$hoogte,48,48, $BS_ICON + $BS_FLAT)
                                                                                            GUICtrlSetImage(-1, "ico\uit.ico", 0, 0)
                                                                            $Namelbl = GUICtrlCreateLabel("Hallo " & @UserName & "!",10,10,400,200)
                                                                                    GUICtrlSetFont (-1,30, 400, 1, $font)
                                                                                    GUICtrlSetColor(-1,0xffffff)
                                                                                    guiCtrlSetBkColor($Namelbl, $GUI_BKCOLOR_TRANSPARENT)
                                                                            GUISetState (@SW_SHOW)  


    
Do 
 Sleep(10)
        
    $msg = GUIGetMsg()
    For $n = 1 To $avButtons[0][0]
        If $Msg = $avButtons[$n][0] Then
            Switch $avButtons[$n][1]
                Case 0
                    _ButtonFuncEven($n)
            EndSwitch
            ExitLoop
        EndIf
    Next
    
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit 0 ;_By()
        
        
        Case $Afsluiten
            _Afsluiten()
        Case $Browser
                    if $internet = "aan" Then
                    _Browser()
                    Else
                        msgBox(0,"Helaas","Sorry internet is uitgeschakeld")
                    Endif
        Case $Documenten
                    if $doccheck = "aan" Then
                    _Documenten()
                    Else
                        msgBox(0,"Helaas","Sorry mijn documenten is uitgeschakeld")
                    Endif
        Case $Word
                    _Word()
        Case $Refresh
            _refresh()
        Case $Admin
    $passinput = InputBox("Admin verificatie","Typ wachtwoord in...","123","*")
    if $passinput == $pass Then
                                                                                                        GuiSetState($Gui,@SW_Hide)
                                                                                                        $Gui2 = GUICreate("", 1024, 768, 0, 0 , $WS_POPUP)
                                                                                                        $bg = GUICtrlCreatepic("img/back_admin.jpg", 0,0,1024,768 )
                                                                                                        GUICtrlSetState($bg, $GUI_DISABLE)
                                                                                                        GUISetBkColor(0x94F6FF, $Gui2)
                                                                                                        GUICtrlSetBkColor(Default, $GUI_BKCOLOR_TRANSPARENT)
                                                                                                        
                                                                                                        
                                                                                                            
                                                                                                        
                                                                                                        $Namelbl = GUICtrlCreateLabel("Hallo administrator!",10,10,600,200)
                                                                                                        GUICtrlSetFont (-1,30, 400, 1, $font)
                                                                                                        GUICtrlSetColor(-1,0x000000)
                                                                                
                                                                                                        $Sluiten = GUICtrlCreateButton("Uit",975,$hoogte,48,48, $BS_ICON + $BS_FLAT)
                                                                                                        GUICtrlSetImage(-1, "ico\terug.ico", 0, 0)
                                                                                                        $Software = GUICtrlCreateButton("Software",10,$hoogte,48,48, $BS_ICON + $BS_FLAT)
                                                                                                        GUICtrlSetImage(-1, "ico\software.ico", 0, 0)
                                                                                                        $Instellingen = GUICtrlCreateButton("Uit",60,$hoogte,48,48, $BS_ICON + $BS_FLAT)
                                                                                                        GUICtrlSetImage(-1, "ico\cp.ico", 0, 0)
                                                                                                            guiCtrlSetBkColor($Namelbl, $GUI_BKCOLOR_TRANSPARENT)
                                                                                                        GUISetState (@SW_Show)      
                                                                                                        Do
                                                                                                            Sleep(10)
                                                                                                            $nMsg = GUIGetMsg()
                                                                                                                Switch $nMsg
                                                                                                                Case $Sluiten
                                                                                                                        GUIDelete($Gui2)
                                                                                                                        GUISetState($Gui, @SW_SHOW)
                                                                                                                        ExitLoop
                                                                                                                Case $Software
                                                                                                                    ShellExeCute(@ScriptDir&"/"&$path)
                                                                                                                Case $Instellingen
                                                                                                                    ShellExeCute(@ScriptDir&"/"&$config_file)
                                                                                                                EndSwitch
                                                                                                        Until $nMsg = $Gui_Event_Close; Here also I want to Close this Gui and Restore First Gui
                                                                                                        GUIDelete($Gui2)
                                                                                                        GUISetState($Gui, @SW_SHOW)
        Else 
            msgBox(16,"Fout!","Fout wachtwoord!")
        Endif
        
    EndSwitch     
Until $msg = $GUI_EVENT_CLOSEoÝ÷ Ø   ݶºw-ìjëh×6#include-once
#Region Functions
Local $var,$openmydoc
Func _Browser()
            DllCall("shell32.dll", "long", "ShellExecute", "hwnd", 0, "string", 'open', "string", $internethome, "string", '', "string", @ScriptDir, "long", @SW_SHOWNORMAL)
EndFunc

Func _Afsluiten()
    $Afvraag = MsgBox(4,"Aflsuiten","Weet je zeker dat je de computer wilt afsluiten?")
    If $Afvraag = 6 Then
        Shutdown(9)
    EndIf
EndFunc

Func _Refresh()
If @Compiled Then
        Run('"' & @ScriptFullPath & '"')
    Else
        Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptFullPath & '"')
    EndIf
    Exit
EndFunc

Func _ButtonFuncEven($iInt)
    $var = IniRead($path, $iInt, "path", "NotFound")
    if FileExists($var) Then
        ShellExeCute($var)
    Else
        MSgBox(16,"Fout!","Programma niet gevonden!"&@CRLF&$iInt&" = "&$var)
    EndiF
EndFunc   ;==>_ButtonFuncEven

Func _mapping()
    Run("Progs/map.bat")
EndFunc

Func _Documenten()
if FileExists("u:\"&@Username) Then
            $openmydoc = ShellExecute("u:\"&@UserName) 
            Else
                DirCreate("u:\"&@Username)
                $openmydoc = ShellExecute("u:\"&@UserName) 
            Endif
        EndFunc
Func _Word()
        MsgBox(0,"Fout","Functie nog niet aangemaakt")
EndFunc
#endregion
Link to comment
Share on other sites

There is nothing wrong with the code :)

I had a similar problem when I was trying to get windows to shell execute a file with my text editor, it turned out I needed error checking on my ini read functions, the code worked fine until I ran the command line parameters into it, just try error checking your ini reads

Edited by maqleod
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

:) I realy think its shell execute. I made this:

$Arraycheck = _ArrayCreate($font,$backgroundimg1,$pass,$internet,$internethome,$doccheck,$hoogte)
        For $e = 0 To 6
            if $Arraycheck[$e] = "1" Then
                MsgBox(16,"Fout!","Kan ini file of configuratie eigenschap niet vinden!" & @CRLF& $Arraycheck[$e])
            EndIf
        Next

To check the ini files, and nothing is wrong. He loads the ini files and the data within it without any problems.

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...