Link to home
Start Free TrialLog in
Avatar of Cruizectrl
Cruizectrl

asked on

One time startup script for certain computers in a domain

Is there a way to run a ONE TIME startup script for certain comptuers in a domain.

I'm installing a monitoring system on a select group of computers.  There a quick easy way to do this?
Avatar of sharkbot221984
sharkbot221984
Flag of United States of America image

In Active Directory Users and Computers, select all the users you want to apply the logon script to -> right click -> properties -> profile tab -> check logon script, enter location of script.  after the script runs, repeat the process but disable the script.
Avatar of Mike Kline
There is no way to do it natively using group policy that I know of (no run once setting).

In your script create a small text file on the machine the first time the script runs.  Then you have the script check for that file.  If it is there the script won't run again.  

I'm sure others will provide other ways to do it too.

Avatar of Cruizectrl
Cruizectrl

ASKER

Isn't there a script step that will check if a specific file (or registry entry) exsists? I'd like this to be a computer startup script (Doesn't that run with admin rights?
the package you are trying to deply...is it in .msi format?  If so you can use Software Installation in the GPO located under Computer Config --> Software Settings
No.. its an exe.. I need it to run the following script.  This is the only option I have for a silent mode install if I dont want to go to each computer.
mkdir c:\somedir
copy \\server\stmonitor.exe c:\somedir\.
copy \\server\stmonitor.dll c:\somedir\.
@start c:\somedir\stmonitor -stealth -server:servername -port:8090

Open in new window

Yes, you can run the script in startup (this uses SYSTEM credentials which is local admin type rights. When the script runs, it writes a flag in the registry - such a minor tiny step. then the script can check if this reg entry ezists and end script if it does.

Also, it can be a form of audit too :)

Krystian
How do I run this on a select few stations.. Not all of them.
You create a group
Then assigb this group to the GPO

Then just drop the computers in the group

I can provide steps if you require
Krystian
That would be great! just a little confused on how to do that. =(
Try this VBScript.  It does exactly what your batch file does but adds a reg entry on install and checks for the reg entry before the install.  You have the change the values for

strSrc1 (change to the actual share path)
strSrc2 (change to actual share path)
strDestFolder (this is the folder the app will be installed to)

Option Explicit
On Error Resume Next
Set wshell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
 
strSrc1 = "\\server\share\stmonitor.exe"
strSrc2 = "\\server\share\stmonitor.dll"
strDestFolder = "C:\Somefolder"
Const reg1 = "HKLM\Software\stmonitor\installed"
 
If wshell.RegRead(reg1) <> 1 Then
	If Not fso.FolderExists(strDestFolder) then
		fso.CreateFolder strDestFolder
		fso.CopyFile strSrc1, strDestFolder, True
		fso.CopyFile strsrc2, strDestFolder, True
		wshell.Run "cmd /c " & strDestFolder & "\stmonitor -stealth -server:servername port:8090"
		wshell.RegWrite reg1,"1",REG_SZ
	End If
End If

Open in new window

SOLUTION
Avatar of Bradley Fox
Bradley Fox
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The script above also checks if the folder exists, if it does it dies
Disregard the script above, correct one below.  Getting late in the day...
On Error Resume Next
Set wshell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
 
strSrc1 = "\\server\share\stmonitor.exe"
strSrc2 = "\\server\share\stmonitor.dll"
strDestFolder = "C:\Somefolder"
Const reg1 = "HKLM\Software\stmonitor\installed"
 
If wshell.RegRead(reg1) <> 1 Then
	If Not fso.FolderExists(strDestFolder) then
		fso.CreateFolder strDestFolder
		fso.CopyFile strSrc1, strDestFolder, True
		fso.CopyFile strsrc2, strDestFolder, True
		wshell.Run "cmd /c " & strDestFolder & "\stmonitor -stealth -server:servername port:8090"
		wshell.RegWrite reg1,"1",REG_SZ
	End If
End If

Open in new window

Well Its creating the directory but its not copying the files over.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, i have a feeling you may need to put a backslash at the end of the destination string

strDestFolder = "C:\Somefolder"

needs to be

strDestFolder = "C:\Somefolder\"

Regards
Krystian
Why not just check if the program is installed instead of do a registry write?

I modified mcsween's script a little bit.


SG
' On Error Resume Next
Set wshell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
 
strSrc1 = "\\server\share\stmonitor.exe"
strSrc2 = "\\server\share\stmonitor.dll"
strDestFolder = "C:\Somefolder\"
 
If (fso.FileExists(strDestFolder & "stmonitor.exe")) Then
     ' do nothing since it's already installed
Else ' install the program
   fso.CreateFolder strDestFolder
   fso.CopyFile strSrc1, strDestFolder, True
   fso.CopyFile strsrc2, strDestFolder, True
   wshell.Run "cmd /c " & strDestFolder & "stmonitor -stealth -server:servername port:8090"
End If

Open in new window