Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help running a program at startup 3

Status
Not open for further replies.

jtcdesigns

IS-IT--Management
Oct 22, 2007
26
0
0
US
I have searched the internet via google for a solution to my problem and yet I have found nothing of use. I am trying to run a script that will run a data collection program on 10 computers. Currently I have the computer auto login when the computer boots and set the rights to power user. Upon start up the program will start and automatically login and open up. To do that I have set the username and password in the shortcut icon on the desktop. The trouble I am having is I found a script to run the program but it keeps coming up with errors from windows script host. Could someone help me out? Or direct me to where I can get tutorials on vbscript? It has been a few years since I have done any programming so I am feeling a bit rusty. Thanks.
 
I suggest you do some reading,there is no [for]

Dim objFSO:Set objFSO CreateObject("Scripting.FileSystemObject")

Code:
set WshShell = WScript.CreateObject("WScript.Shell")
         WshShell.Run "Notepad.exe"
         WScript.Sleep 100
         WshShell.AppActivate "Notepad.exe"
         WScript.Sleep 100
         WshShell.SendKeys "I"
         WScript.Sleep 500
         WshShell.SendKeys " Need"
		WScript.Sleep 100
         WshShell.SendKeys " to"
         WScript.Sleep 500
         WshShell.SendKeys " read"
		  WScript.Sleep 100
         WshShell.SendKeys " about"
         WScript.Sleep 500
         WshShell.SendKeys " scripting"
		 wscript.quit
 
Thanks I have been reading up on scripting and have been gettin progress but not much with google until I found this forum which I have found very helpful. I just realised my plan will not be of use to me since I wanted this to work for every computer but forgot every computer has it's own login for the app. I atleast had some good practice.
 
every computer or every userName

here is how you can pull the computer Name or UserName

Code:
Dim WshNetwork, objDomain, DomainString 
Dim strFullname,  Username, SysDrive


Dim WshShell:Set WshNetwork = CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
Dim WshSysEnv:Set WshSysEnv = WshShell.Environment("Process")
Dim objFSO:Set objFSO = CreateObject("Scripting.FileSystemObject")

SysDrive = WshShell.ExpandEnvironmentStrings("%SYSTEMDRIVE%")
SysRoot = WshShell.ExpandEnvironmentStrings ("%SystemRoot%")
UserProfile = WshShell.ExpandEnvironmentStrings ("%UserProfile%")
'Automatically find the domain name
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")

'Grab the user name
Dim UserString :UserString = WshNetwork.UserName
Dim objADSysInfo:Set objADSysInfo = CreateObject("ADSystemInfo")
Dim objCurrentUser:Set objCurrentUser = GetObject("LDAP://" & objADSysInfo.UserName)

'Bind to the user object to get user name and check for group memberships later
Dim UserObj:Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)

'Grab the computer name for use in add-on code later
strComputer = WshNetwork.ComputerName

wscript.echo WshNetwork.ComputerName
wscript.echo UserString
 
That would work but all 10 computers login with the same username as dcstation but the login name for the program is different so I would have to write the same script for each computer and just change the username. Basically thinking it over it's not that anymore efficient than having my modified shortcut in the start menu. The computer name is different for each computer but the username is all the same. I could write a bunch of if then statements to do it but I think this is a failed plan I must retire.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top