Powershell script runs OK on the desktop but not when it's runningunder machine startup

Discussion in 'Scripting' started by fortran_guy, Apr 1, 2011.

  1. fortran_guy

    fortran_guy Guest

    Windows 7 32 bit but the intended target is a Windows Server 2008 R2
    as an inbound and outbound FTP server. I've run Set-ExecutionPolicy
    unrestricted, set it to run with gpedit.msc, and both RSOP.MSC and
    sysinternals AUTORUNS show it running through local group
    policy. .ps1 is associated with PowerShell, the script is in c:
    \windows\system32\grouppolicy\machine\scripts\startup (which I believe
    is the default location) and the file even shows under the PowerShell
    "Show Files" button. So what tweaks/changes/etc. am I missing.

    The script is:

    # Check for changes every 60 seconds
    $currentFiles = Get-ChildItem D:\inetpub\ftproot\localuser\username
    \UNEDITEDIMAGES
    while(-1){
    $newFiles = Get-ChildItem D:\inetpub\ftproot\localuser\username
    \UNEDITEDIMAGES
    if($newFiles.count -ne $currentFiles.count){
    $currentFiles = $newFiles
    (new-object Media.SoundPlayer "C:\WINDOWS\Media\notify.wav").play()
    }
    Start-Sleep(60)
    }
     
    fortran_guy, Apr 1, 2011
    #1
    1. Advertisements

  2. From: "fortran_guy" <>

    | Windows 7 32 bit but the intended target is a Windows Server 2008 R2
    | as an inbound and outbound FTP server. I've run Set-ExecutionPolicy
    | unrestricted, set it to run with gpedit.msc, and both RSOP.MSC and
    | sysinternals AUTORUNS show it running through local group
    | policy. .ps1 is associated with PowerShell, the script is in c:
    | \windows\system32\grouppolicy\machine\scripts\startup (which I believe
    | is the default location) and the file even shows under the PowerShell
    | "Show Files" button. So what tweaks/changes/etc. am I missing.

    | The script is:

    | # Check for changes every 60 seconds
    | $currentFiles = Get-ChildItem D:\inetpub\ftproot\localuser\username
    | \UNEDITEDIMAGES
    | while(-1){
    | $newFiles = Get-ChildItem D:\inetpub\ftproot\localuser\username
    | \UNEDITEDIMAGES
    | if($newFiles.count -ne $currentFiles.count){
    | $currentFiles = $newFiles
    | (new-object Media.SoundPlayer "C:\WINDOWS\Media\notify.wav").play()
    | }
    | Start-Sleep(60)
    | }

    Look at the POV the script is running under and the privileges provided.

    When you run it it uses your credentials.
    If it is failing it may be because of the credentials of the environment it is running
    under.
     
    David H. Lipman, Apr 1, 2011
    #2
    1. Advertisements

  3. fortran_guy

    fortran_guy Guest

    Can't really be credentials of mine since the problem is at machine
    startup with no one logged in.
    Other suggestions?
     
    fortran_guy, Apr 11, 2011
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.