Easiest way to make perl application for windows run on startup in code - windows

What is the easiest way to make a perl app run at startup in perl code?
For example: to copy it to the "allusers" startup folder. How do I do this?

Use Task Scheduler. In Windows 7 (older Win versions are very similar):
Start -> All Programs -> Accessories -> System Tools -> Task Scheduler
Top menu: Action -> Create Task. You will get a task configuration window.
Specify a name
Choose the radio button: Run whether the user is logged on or not
Click on the checkbox: Run with highest privileges (if necessary)
Select the Trigger tab on top. Click on the New button.
From the Begin the task drop down, select At startup.
Select the Action tab on top. Click on the New button.
The Action drop down must specify Start a program. Browse and select your Perl script. Add any arguments if necessary.
The other tabs can probably be left alone. But this is the cleanest UI for creating a start up program. I believe you can also edit the registry and specify start up programs/scripts to run there, which is pretty standard practice for installation scripts.
Hope this helps.

Related

WMIC Product GET Name - Invalid Class

I am trying to list all of the programs currently on my Windows 8.1 machine. I believe recently installed software is preventing windows from booting up. I have access to the command line and I have been trying to use the wmic product GET Name to see what I can uninstall from the command line. I read that you have to enable the WMI support tools in Management & Monitoring Tools, but I don't have access to that. Does anyone know if I can enable that from the command line so I can figure out why I am ultimately getting a EDIT:0x000021a error on start up.
Try
This is not a full list (wmic). This is only products installed with Windows Installer. There is no feature for everything.
However as I said in my previous post nearly everything is listed in the registry.
So to see it in a command prompt
reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s
Also your error code seems invalid. There is no 27a windows error or 0xc000027a NT Status code. It seems wrong for a COM containing NTSTatus 0xd000027a or COM with Windows error 0x8007027a.
Clean Booting
Each of the three steps turns of programs, services, and drivers in increasing amounts. Thus narrowing down the possible culprits.
Clean Boot
Click Start - All Programs - Accessories - Run and type
msconfig
Then go to the Startup tab. Untick everything. Then go to the Services tab. Tick Hide All Microsoft Services and untick everything that's left.
Reboot. If this solves your problem reenable ½ of the services/startup items until you find which one.
Advanced Clean Boot
If the above doesn't help.
Download Autoruns from http://technet.microsoft.com/en-us/sysinternals/bb963902.aspx
Start the program by right clicking and choosing Run As Administrator and click Options menu - Filter Options and tick Hide Microsoft entries and clear Include Empty Locations. Untick everything left.
Reboot. If this solves your problem reenable ½ of the items until you find which one.
Safe Mode
If the above doesn't help.
Use Safe Mode with Networking if you need internet access.
Click Start - All Programs - Accessories - Run and type
msconfig
Then go to the Boot tab and click Safe Boot (also tick Network if needed). Reboot. Come back here and untick Safe Boot to return to normal mode.
or
If your computer has a single operating system installed, repeatedly press the F8 key as your computer restarts. You need to press F8 before the Windows logo appears. If the Windows logo appears, you will need to try again. [From Start - Help and Support]
Startup Repair
If your computer has a single operating system installed, repeatedly press the F8 key as your computer restarts. You need to press F8 before the Windows logo appears. If the Windows logo appears, you will need to try again. [From Start - Help and Support].
On the Advanced Boot Options screen, use the arrow keys to highlight Repair your computer, and then press ENTER.
Select Startup Repair.
Startup repair makes a log file. See C:\Windows\System32\LogFiles\Srt\SrtTrail.txt.
To access if Windows won't start, on the Advanced Boot Options screen, use the arrow keys to highlight Repair your computer, and then press ENTER.
Select Command Prompt.
Type
type C:\Windows\System32\LogFiles\Srt\SrtTrail.txt |more
Also type explorer in your command prompt and see what happens.
My Explorer fixes listsways of using windows without the graphical shell.
To See if a Fix is Available
In Control Panel (and select Classic view in the left hand pane) choose Problem Reports and Solutions (type problem in Start's search box), go to Problem History, right click your error and choose Check For Solution.
You may also right click and choose Details for more info. Post those details here. The Fault Module Name is the important information.
If the problem affects Control Panel press Winkey + R and type wercon (or type it in a command prompt).
Close Explorer and Start a Command Prompt
Close any Explorer windows
Start - All Programs - Accessories - Right click Command Prompt and choose Run As Administrator.
Click Start. Ctrl + Shift + Right click a blank spot (just above the power buttons is one place) then Exit Explorer.
Press Ctrl + Alt + Delete then Task Manager.
Check all explorer processes are closed. On the Process tab select explorer and right click and choose End Process, repeat if more than one explorer in the list.
Then to restart explorer after trying each of the following
Press Ctrl + Alt + Delete and choose Task Manager
In Task Manager click the File menu then New Task (Run) and type explorer
If You Can't Start Explorer at All
Press Ctrl + Alt + Delete and choose Task Manager
On the Process tab click Show Processes From All Users to elevate to Administrator
In Task Manager click the File menu then New Task (Run) and type cmd
Other things you can try typing
Explorer
Explorer c:\
Explorer /e,c:\
wercon
control
iexplore
rstrui
If you can't start a folder window use the Browse button in the New Task dialog. Remember you need to right click and choose Open rather than double clicking.

Counting computer login times for the week

I am probably asking this question in the wrong place (Maybe I should go to an OS forum) - but I still want to know this.
I am using a windows- 7 machine for my work. I log in everyday, do some work and then log off. I take a few short breaks in between when I Lock (Windows+L) my laptop.
I have to account for the number of hours worked by the end of the week which means the time for which I was logged in to this machine.
The problem is that I do complete all the work that is assigned to me, but I forget to keep track of the exact hours I was logged into this machine. I may have logged in at 5 am in the morning and then logged off at 3 in the afternoon- and I dont have any manual logs of my time.
Is there someplace where windows keep a weekly track of
Say per day:
"The Latest log-off time - The Earliest Log in time" into that system for a particular day. I only need these logs for a week.
any heads up would be appreciated. Thanks
I have tried to solve this problem for years, but only recently found a solution that:
May be implemented without administrative privileges
Does not require extra software
Kudos to Guiding Tech for providing the solution shown below. Change the suggested folder and filenames as you desire, but adjust the batch file code and Task Scheduler commands accordingly.
Part One: Create the script
Create the folder where you would like the script and text log file of login and lock/logoff to reside. For this example, I will presume the desired folder is "C:!Scripts\Login\"
Create a new text file in the folder and name it login.bat. A quick way to do this is to right-click a blank space in the folder view, and select New > Text Document, then name it login.bat.
Open the text file and copy and paste in the following code:
echo off
set datecode=%date:~-4%-%date:~7,2%-%date:~4,2% %time:~0,2%:%time:~3,2%:%time:~6,2%
if "%1"=="i" echo %datecode% - Logged in >> C:\!Scripts\Login\login.txt
if "%1"=="o" echo %datecode% - Locked computer >> C:\!Scripts\Login\login.txt
Save the new batch file
Part Two: Create the login task
Open Task Scheduler. Press the Windows key, and then type "Task Scheduler" and click on the application that appears with that name. Alternatively, use Start > Run (Win + R), type taskschd.msc and press Enter.
Select Create Task... from the actions on the right hand side
Enter a task name like "Log the login date and time"
Click on the Triggers tab and add a new trigger. Select:
Begin the task: At log on
Specific user: This should be your Windows account name.
Click OK to add the trigger.
Add another trigger, except this time select Begin the task: On workstation unlock. Click OK to add the trigger.
Click on the Actions tab. Add a new action and point it to your login script with the argument i.
Click OK to add the action.
7. (Optional – Only required if you are using a laptop) Click on the Conditions tab and uncheck the box that says Start the task only if the computer is on AC power. Click on OK to create the task.
Part Three: Create the lock task
In Task Scheduler, select Create Task… from the actions on the right hand side.
Enter a task name like Log the lock date and time.
Click on the Triggers tab and add a new trigger. Select:
Begin the task: On workstation lock
Specific user: This should be your Windows account
Click OK to add the trigger.
Click on the Actions tab. Add a new action and point it to your login script with the argument o.
Click OK to add the action.
(Optional – Only required if you are using a laptop) Click on the Conditions tab and uncheck the box that says Start the task only if the computer is on AC power. Click on OK to create the task.
Part Four: Testing that everything is working as expected
Your work is now complete. You just need to test that everything is working as expected. Just lock your computer by hitting WIN+L and log back in. If you followed the instructions properly, you should now have a file called login.txt in the same folder as your script. This file should contain a log of each time you log in and out of your computer.
You can use the event log to check when you logged in and logged put (or locked the PC for that matter) but you would have to do that by hand.. You could write a program to do that but that would be hard.
BTW: You will need to enable a group policy or something to enable login events. Have a look here

login to remote windows machine through batch file from another windows machine

My remote windows server restarts at fixed time , i need to login daily after restart , since i have scheduled few tasks in the server and they run only when loged in , please help me to automate the login process , can we do this through batch files ? like we can do the restart
If you have Windows 2008 or above you can use Task Scheduler. Open Control Panel and run the Task Scheduler. Right click on Action menu and run Create Task. Create the task as usual select "Run whether user is logged on or not" and (if need) select the "Run with hightest privileges" checkbox. Then go to Triggers tab and click the "New" button. There are many conditions for run this task. Select "At stratup" and click OK. Then in the Action tab select the "New" button. There select in Action "Start a program". Click Browse button and select your script or batch file. Click OK. Repeat as necessary. Click OK again and create the new Task.
Good luck.

Console Application with task scheduler

I have created a console and I want to run it every 1-minute nonstop
I try to put in a scheduler task but I think that my configuration is done badly can someone help, please?
I want to finish this task
thank
You can follow the tutorial here How to Create a Automated Task that Runs at a Set Time in Windows 7
The steps outlined are as follows:
Open up Task Scheduler by either typing "task" into the Start Menu search bar, or by opening All Programs -> Accesories > System Tools.
Select 'Create Basic Task' from the right hand pane and the 'Create Basic Task' Wizard will open.
With the Wizard open, type a 'Name' and 'Description' for your new task and click Next.
NOTE: The Next button will only be accessible once a 'Name' has been entered.
Select the event/task to run DAILY and click Next.
Select the time as 00:00 and date at which you wish the first task to start (each task afterward will run based on your selection in step 4) then click Next.
Choose the action you with the task to execute from the list then click Next.
NOTE: For your query, select 'Start a program'.
Click 'Browse' and navigate to the executable (exe) file of the console app you wish to run then click Next. You can choose to ignore 'Add arguments' and 'Start in'.
Review the task and make sure that you've set all your required information correctly. If satisfied click Finish.
Click the Advanced button on the Schedule tab. There is a checkbox for Repeat task. The default is every 10 minutes. You can change that to 1 minute.
The key here is to find the advanced properties. If you are using the XP wizard, it will only offer you to launch the advanced dialog once you created the task.

Running Applescript: WorkFlowServiceRunner will not terminate

I am trying to make a keyboard shortcut to launch terminal in OS X Mountain Lion.
After some research I found out that I can use Automator to achieve this:
http://mac.tutsplus.com/tutorials/tips-shortcuts/how-to-launch-any-app-with-a-keyboard-shortcut/
It works, but I noticed that whenever I launch a terminal using this method, a process called WorkFlowServiceRunner starts and never terminates. To make matters worse when I launch more terminals (or launch different applications using shortcuts, again, through Automator) multiple WorkFlowServiceRunner processes start and quickly eat up the memory.
I've also tried writing my own applescripts but the problem does not go away. This clearly looks like a memory leak. Is this a bug in OS X Automator? Is there a way to write an applescript so that the WorkFlowServiceRunner terminates after doing its job (e.g. launch a terminal)? Automator seems to be the most "native" way of getting this done and I do not want to use any 3rd party apps.
I have noticed this from time to time.
One way around it would be to make your own service apps with a Cocoa-AppleScript Applet.
It is not very hard to do. And I will try and guide you through it. It should only take you a couple of minutes.
Step 1.
Open your Application Applescript Editor. And go to the "File" Menu -> "New from Template" -> Cocoa-AppleScript Applet.app
Step 2,
Paste this code into the new documents.
property NSWorkspace : class "NSWorkspace"
tell current application's NSApp to setServicesProvider_(me)
NSUpdateDynamicServices()
my runAService()
on runAService()
NSWorkspace's sharedWorkspace()'s launchAppWithBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifier_("com.apple.Terminal", current application's NSWorkspaceLaunchDefault, missing value, missing value)
tell me to quit
end runAService
Step 3,
Compile
(click this to compile)
and Save the app.
*Make sure the show startup screen is unchecked in the Save dialogue.
Giving the app a name like LaunchTerminal.app
Step 4,
Click the "Bundle Contents" button on the top right hand side of the document.
This will open the applications contents view.
Click the Action button and then "Reveal in finder" sub menu.
step 5,
In the contents folder that opens in the finder you will see a file name "info.plist"
Open Terminal.app and type and run this code using the path to this file:
BUT make sure you do not include the ".plist" part of the name when entering it in Terminal.app
/usr/bin/defaults write /Users/YourUserNameHere/myServiceApps/LaunchTerminal.app/Contents/Info NSServices -array-add '{NSMenuItem={default="Launch Terminal";}; NSMessage="runAService"; NSSendTypes=();}'
( You can drag n drop the file into terminal to get the posix path string )
The path part looks like this: /Users/YourUserNameHere/myServiceApps/LaunchTerminal.app/Contents/Info
This code should add an array to the plist file which is part of the apps way of broadcasting it has a service.
step 6,
Compile and Save the App again.
Just to make sure it picks up the changes. ( I found I had to do this even though I should not have to)
step 7,
Double click the app to run it for the first time.
The App will quit straight away. But the first run should have broadcast that it has a service that should be registered with the system
step 8,
Open system Preferences and go to Services -> General (section)
And you will see the "Launch Terminal" service.
Set up your short cut as normal.
Hope this helps..
UPDATE :
I noticed that the tell application "Terminal" to activate. Would not open my default Window groups if I had closed them all and quit Terminal before. The normal behaviour if I have done this is for my default window group to open. ( I have two Tabs open at startup each cd'd to a different path).
So I have change the open application to a cocoa way of doing it.
A do shell script with open the/application/path/. will work also.
Try using Butler or QuicKeys. They both have endless "Trial periods."

Resources