General discussion

Locked

Start-Up Script

By BlitzSonik ·
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

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by sgt_shultz In reply to Start-Up Script

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?

Collapse -

by sgt_shultz In reply to

anything in the security event logs on either the workstation or the server?

Collapse -

by BlitzSonik In reply to

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.

Collapse -

by BlitzSonik In reply to Start-Up Script

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)

Collapse -

I'm a little unhappy

by neilb@uk In reply to

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 :)

Collapse -

WTF AM I DOING?

by neilb@uk In reply to I'm a little unhappy

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

Back to Windows Forum
6 total posts (Page 1 of 1)  

Related Discussions

Related Forums