"Run these programs at user logon" GP

Home Forums Microsoft Networking and Management Services GPO "Run these programs at user logon" GP

This topic contains 6 replies, has 4 voices, and was last updated by Avatar Anonymous 9 years, 9 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • Avatar
    toastman
    Member
    #147246

    Hi everyone,

    I have a question regarding the “Run these programs at user logon” group policy.

    The policy works great with notepad.exe or Winrar, but it doesn’t work with our in-house application because the application we developped require a working directory in the shortcut. (the Start In: field in the shortcut)

    Is there any way to start our application with this policy or another way while specifying a working directory?

    Many thanks,
    Toast

    Rems
    Rems
    Moderator
    #227659

    Re: "Run these programs at user logon" GP

    At “Run these programs at user logon” try this syntax to run your app:

    Code:
    cmd /c pushd “[COLOR=”DarkSlateBlue”][B]w:orkingdirectory[/B][/COLOR]” &&start “”/normal [COLOR=”darkslateblue”][B]in-house-app.exe[/B][/COLOR]

    Rems

    Avatar
    Anonymous
    #369880

    Re: "Run these programs at user logon" GP

    Rems, you are a genius! Works like a charm.

    Btw, do you know how to do the same thing (run a program while specifying a working directory from a batch file [x.bat]) ?

    Thank you!!!
    ~Toast

    Rems
    Rems
    Moderator
    #227662

    Re: "Run these programs at user logon" GP

    toastman;194788 wrote:
    , do you know how to do the same thing (run a program while specifying a working directory from a batch file [x.bat]) ?

    In a batch you can use the exact same command line (but there you don’t use cmd /c in front of the line):
    pushD “[COLOR=”DarkSlateBlue”]w:orkingdirectory[/COLOR]” &&(
    start “” “[COLOR=”darkslateblue”]in-house-app.exe[/COLOR]”
    popD
    )[/CODE]

    [B]pushD[/B] makes the defined path working directory. If the path would be a UNC networkpath (UNC paths can never set as the working directory) then pushD will [U]by itself[/U] assign a drive letter to it and set the mapped drive as te working directory.

    [B]&&[/B] makes the application run only if pushD was successfull.

    [B]popD[/B] (optional) returns the working directory of the batch to the directory before the latter pushD action. note, if the pushD stament had caused the creation of a drive mapping, then popD will not only set the previous working directory it’ll also disconnect that mapped drive.

    cheers,
    Rems[CODE]pushD “w:orkingdirectory” &&(
    start “” “in-house-app.exe
    popD
    )[/CODE]

    pushD makes the defined path working directory. If the path would be a UNC networkpath (UNC paths can never set as the working directory) then pushD will by itself assign a drive letter to it and set the mapped drive as te working directory.

    && makes the application run only if pushD was successfull.

    popD (optional) returns the working directory of the batch to the directory before the latter pushD action. note, if the pushD stament had caused the creation of a drive mapping, then popD will not only set the previous working directory it’ll also disconnect that mapped drive.

    cheers,
    Rems

    Avatar
    Anonymous
    #369883

    Re: "Run these programs at user logon" GP

    Rems, once again thank you, worked perfectly!

    I have one last question, any idea how to launch “logoff” command when the app in question is terminated?

    Example: When I use the following it works, the app starts, and when I close it the system logs off:

    @echo off
    cd %ApplicationRoot%bin
    cmd /C application.exe
    goto exit

    :exit
    logoff[/CODE]

    I tried something like this but as you can imagine it doesn’t work , it just logs off right away:
    [CODE]pushD “C:Program FilesPositronPower911Bin” &&(
    start “” “p911.exe”
    popD
    )
    goto exit

    :exit
    logoff[/CODE]

    Thank you very much!
    Toast[CODE]@echo off
    cd %ApplicationRoot%bin
    cmd /C application.exe
    goto exit

    :exit
    logoff[/CODE]

    I tried something like this but as you can imagine it doesn’t work , it just logs off right away:
    pushD “C:Program FilesPositronPower911Bin” &&(
    start “” “p911.exe”
    popD
    )
    goto exit

    :exit
    logoff[/CODE]

    Thank you very much!
    Toast[CODE]pushD “C:Program FilesPositronPower911Bin” &&(
    start “” “p911.exe”
    popD
    )
    goto exit

    :exit
    logoff[/CODE]

    Thank you very much!
    Toast

    Avatar
    Silver23
    Member
    #292255

    Re: "Run these programs at user logon" GP

    For that you could use something like

    start “title” “%yourcommand or app%” && logoff

    What this does is run the logoff command after the initial start value has been processed. This also means that your batch file remains active as long as your application is.

    Maybe I’ll come up with something else(better) later.

    Rems
    Rems
    Moderator
    #227664

    Re: "Run these programs at user logon" GP

    Silver23;195019 wrote:
    For that you could use something like

    start “title” “%yourcommand or app%” && logoff
    .

    No, that will not work icw/ Start command.

    Instead use,
    Start “”/w p911.exe
    logoff.exe[/CODE]
    OR don’t use Start :
    [CODE]p911.exe
    logoff.exe[/CODE]

    Instead of using PushD – for your batch, since this app is local you could also use this,
    [CODE]cd /d “%ApplicationRoot%bin”[/CODE]

    note,
    [B]I would like to suggest to [U]close this thread[/U] in the GPO forum, and continue[URL=”http://forums.petri.com/showthread.php?t=43637”][I][U] here… [/U][/I][/URL](existing thread of you already in scripting forum).[/B]

    Rems[CODE]Start “”/w p911.exe
    logoff.exe[/CODE]
    OR don’t use Start :
    p911.exe
    logoff.exe[/CODE]

    Instead of using PushD – for your batch, since this app is local you could also use this,
    [CODE]cd /d “%ApplicationRoot%bin”[/CODE]

    note,
    [B]I would like to suggest to [U]close this thread[/U] in the GPO forum, and continue[URL=”http://forums.petri.com/showthread.php?t=43637”][I][U] here… [/U][/I][/URL](existing thread of you already in scripting forum).[/B]

    Rems[CODE]p911.exe
    logoff.exe[/CODE]

    Instead of using PushD – for your batch, since this app is local you could also use this,
    cd /d “%ApplicationRoot%bin”[/CODE]

    note,
    [B]I would like to suggest to [U]close this thread[/U] in the GPO forum, and continue[URL=”http://forums.petri.com/showthread.php?t=43637”][I][U] here… [/U][/I][/URL](existing thread of you already in scripting forum).[/B]

    Rems[CODE]cd /d “%ApplicationRoot%bin”[/CODE]

    note,
    I would like to suggest to close this thread in the GPO forum, and continue here… (existing thread of you already in scripting forum).

    Rems

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.