Jump to content

converted vb to autoit script


Briandr
 Share

Recommended Posts

Global Const $CSIDL_COMMON_PROGRAMS = 0x17
Global Const $CSIDL_PROGRAMS = 0x2
Global $objShell = ObjCreate("Shell.Application")
Global $objAllUsersProgramsFolder = $objShell.NameSpace($CSIDL_COMMON_PROGRAMS)
$strAllUsersProgramsPath = $objAllUsersProgramsFolder.Self.Path
Global $objFolder = $objShell.Namespace($strAllUsersProgramsPath)
Global $objFolderItem = $objFolder.ParseName("IP Address.lnk")
Global $colVerbs = $objFolderItem.Verbs
For $objVerb in $colVerbs
    If stringReplace($objVerb.name, "&", "") = "Pin to Start Menu" Then $objVerb.DoIt
Next

Global $objShell = ObjCreate("Shell.Application")
Global $objAllUsersProgramsFolder = $objShell.NameSpace($CSIDL_COMMON_PROGRAMS)
$strAllUsersProgramsPath = $objAllUsersProgramsFolder.Self.Path
Global $objFolder = $objShell.Namespace($strAllUsersProgramsPath)
Global $objFolderItem = $objFolder.ParseName("TeamViewer 9 Host.lnk")
Global $colVerbs = $objFolderItem.Verbs
For $objVerb in $colVerbs
    If stringReplace($objVerb.name, "&", "") = "Pin to Start Menu" Then $objVerb.DoIt
Next

Hi,

How would I add a section of code that would delete my compiled EXE from its current location?

Edited by Briandr
Link to comment
Share on other sites

  • Moderators

In other languages, I've approached this a different way entirely.

But this way is probably safer if I'm understanding the request.

'?do=embed' frameborder='0' data-embedContent>>

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Hi,

Follow up question. How would I get this line under roaming user (This is my target---->C:UsersDefaultAppDataRoamingMicrosoftWindowsStart MenuProgramsStartup)

If Not FileExists ( @AppDataCommonDir & "PinTVIPInfotoStartMenu.exe.lnk" ) Then FileCreateShortcut ("C:WindowsPinTVIPInfotoStartMenu.exe", @AppDataCommonDir & "PinTVIPInfotoStartMenu.exe.lnk", "C:Windows" )

Thanks.

Link to comment
Share on other sites

The FileDelete @ScriptName did not delete the EXE (The shortcut did not have a .lnk) from its current location. The user was a restricted user (user account type: user)

Path: 

C:UsersDefaultAppDataRoamingMicrosoftWindowsStart MenuProgramsStartup

Also, struggling with creating the shortcut I will be deleting at a later time.

If Not FileExists ( @AppDataDir & "\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\PinTVIPInfotoStartMenu.exe.lnk" ) Then FileCreateShortcut ("\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\PinTVIPInfotoStartMenu.exe.lnk", @AppDataDir & "\Roaming\Microsoft\Windows\Start Menu\Programs\StartupPinTVIPInfotoStartMenu.exe.lnk", "C:\Windows" )

Ideas on both?

Thanks.

Edited by Briandr
Link to comment
Share on other sites

  • Moderators

I gave you the answer to your first question in post #2.

2nd question:  @StartupDir

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I will look at your function in greater detail tonight. Not sure which one work best for me. As far as my 2nd question I tried using @StartupDir and if memory serves me right it deletes out of C:ProgramDataMicrosoftWindowsStart MenuProgramsStartup. I already tried that. I have to assume there will be multiple users on a given computer. That is why I want the shortcut in the Roaming user folder. That way it gets copied to the user's startup folder. As mentioned earlier I will deal with deleting the shortcut after the fact. Unless I am wrong and I very well may be I don't want @startupdir.

Link to comment
Share on other sites

  • Moderators

C:ProgramDataMicrosoftWindowsStart MenuProgramsStartup

That's @StartupCommonDir

Just run this in a test.au3:

ConsoleWrite(@StartupCommonDir & @CRLF & @StartupDir & @CRLF)
 
Always best to test rather than post more without knowing if something even works or not.  Believe it or not, this isn't my first rodeo.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

>Running:(3.3.12.0):C:Program Files (x86)AutoIt3autoit3_x64.exe "C:test.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
C:ProgramDataMicrosoftWindowsStart MenuProgramsStartup
C:UsersmeAppDataRoamingMicrosoftWindowsStart MenuProgramsStartup
+>20:16:09 AutoIt3.exe ended.rc:0
+>20:16:09 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 0.7426
 
Here is the output
Link to comment
Share on other sites

  • Moderators

Is the 2nd one @StartupDir not the directory you're looking for?  It appears to be from what you posted earlier.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Sorry if my other posts were confusing. This is the one I'd like, if possible:

C:UsersDefaultAppDataRoamingMicrosoftWindowsStart MenuProgramsStartup

If Not FileExists ( @StartupDir & "\PinTVIPInfotoStartMenu.exe.lnk" ) Then FileCreateShortcut ( "C:\Windows\PinTVIPInfotoStartMenu.exe", @AppDataDir & "\Microsoft\Windows\Start Menu\Programs\Startup\PinTVIPInfotoStartMenu.exe.lnk", @StartupDir)

This line works, but as the AutoIT help file indicates @AppDataDir is Path to current user's Roaming Application Data. (I want the one for all Roaming Users, but it does  not appear to be one)

I am trying to get the default one (basically the one for the roaming user that upon login of a new user passes this down)

Not sure if I am close or way off still.

Edited by Briandr
Link to comment
Share on other sites

There's no Startup folder in the "Default" user profile.

You're probably looking for the AllUsers startup folder. which is located here: "C:ProgramDataMicrosoftWindowsStart MenuProgramsStartup" and the AutoIt macro for that one is @StartupCommonDir.

I don't know if creating the folder will apply it to all user's profiles that are created after you've created that folder. The settings in Default are usually only applied once, the very first time a user logs onto a machine, after that it's never used again.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I think this will work (been testing over last half hour) and if someone wishes (not asking (more if you are curious) you can test with something similiar). The reason I want Default is basically the 'Set and Forget It' as you said. Once I do the intial task once it is no longer needed it can get deleted so it don't run repeatedly in the Start Up folder. I will handle getting it deleted later. For now it was just getting the shortcut created in the desired location.

If Not FileExists ( @StartupDir & "\PinTVIPInfotoStartMenu.exe.lnk" ) Then FileCreateShortcut ( "C:\Windows\PinTVIPInfotoStartMenu.exe", "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\PinTVIPInfotoStartMenu.exe.lnk", "C:\Windows")
Edited by Briandr
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...