Discussion Locked

Start-Up Script

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

My Fellow Administrators:

I respectfully resquest your assistance with a script. My objective is to use GPO to deploy a startup script which will delete a file in the root directory, then run a program located on a network share.

I have succesfully created a script that worked when manually launched. However; When I added it to a GPO, it doesn't work. I have narrowed it down to the script itself because when I replace the script with another one, it worked beautifully.

The script is:

Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const DeleteReadOnly = TRUE
objFSO.DeleteFile("C:\deletethisfile.txt"), DeleteReadOnly
WshShell.Run("\\server\share\program.exe")

I can do this same thing through a login script batch fileand have it work perfectly but I would prefer to do it through a startup script as my users tend be more patient before they login.

Any help on this would be much appreciated.

Blitz

6 replies

by sgt_shultz

i am just guessing but maybe it is a rights issue. the script works when you use it upon login because the account has sufficent permissions on the shares and local file/folders.
but maybe as a startup script it needs the 'runas' command so it can be run using an account with sufficent rights?

by blitzsonik

Doesn't appear to be a security issue! Nothing appearent in the Event logs on either the worksation or server. If I put the GPO in verbose mode, I can see that it does in fact run but it doesn't actually run the program I need it to.

I am thinking that my script is not worded correctly.

by blitzsonik

I have updated my script as follows:

Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const DeleteReadOnly = TRUE
If objFSO.FileExists("C:\deletethisfile.txt") Then
objFSO.DeleteFile("C:\deletethisfile.txt"), DeleteReadOnly
End If
WshShell.Run("runas /user:domain\User ""\\server\share\program.exe""")
WScript.Sleep(100)
WshShell.Sendkeys("password" & VbCr)

by Member 25348569

with the syntax of the line used to delete the file:

objFSO.DeleteFile("C:\deletethisfile.txt"), DeleteReadOnly

The parentheses are incorrect and aren't required:

objFSO.DeleteFile "C:\deletethisfile.txt", DeleteReadOnly

You should be able to confirm this as your script performs two actions so it should be easy to confirm whether it deletes the file and fails on the "run" or exits the script with an error before deleting the file.

Neil :)

by Member 25348569

I've just answered a question from 2005 after following a "posts like this one" link from a current question.

Ah well, no harm done but I wonder if he ever got his script debugged...

This discussion is closed to new replies.